mirror of
				https://github.com/sqlite/sqlite.git
				synced 2025-11-03 16:53:36 +03:00 
			
		
		
		
	Set binary mode for output on Windows when writing a quoted string that
might contain newline characters. FossilOrigin-Name: 7096e6c06d9a3e48d3f0d134f5f3275dde796be2
This commit is contained in:
		
							
								
								
									
										12
									
								
								manifest
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								manifest
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
				
			|||||||
C Set\sthe\scommand-line\sshell\sstdin\sto\sbinary\smode\son\swindows.
 | 
					C Set\sbinary\smode\sfor\soutput\son\sWindows\swhen\swriting\sa\squoted\sstring\sthat\nmight\scontain\snewline\scharacters.
 | 
				
			||||||
D 2015-01-18T01:50:54.333
 | 
					D 2015-01-18T20:30:23.778
 | 
				
			||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 | 
					F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 | 
				
			||||||
F Makefile.in 5407a688f4d77a05c18a8142be8ae5a2829dd610
 | 
					F Makefile.in 5407a688f4d77a05c18a8142be8ae5a2829dd610
 | 
				
			||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
 | 
					F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
 | 
				
			||||||
@@ -230,7 +230,7 @@ F src/random.c ba2679f80ec82c4190062d756f22d0c358180696
 | 
				
			|||||||
F src/resolve.c f6c46d3434439ab2084618d603e6d6dbeb0d6ada
 | 
					F src/resolve.c f6c46d3434439ab2084618d603e6d6dbeb0d6ada
 | 
				
			||||||
F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
 | 
					F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
 | 
				
			||||||
F src/select.c e4c38c75e36f28aed80a69a725d888751bfd53df
 | 
					F src/select.c e4c38c75e36f28aed80a69a725d888751bfd53df
 | 
				
			||||||
F src/shell.c 96c40c85467552025d81505310efcf3679303d3a
 | 
					F src/shell.c 4958f393be95eaf223dd51f7eb799f6c5e800060
 | 
				
			||||||
F src/sqlite.h.in 9dfc99d6533d36d6a549c4f3f01cacc8be956ada
 | 
					F src/sqlite.h.in 9dfc99d6533d36d6a549c4f3f01cacc8be956ada
 | 
				
			||||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 | 
					F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 | 
				
			||||||
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
 | 
					F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
 | 
				
			||||||
@@ -1236,7 +1236,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 | 
				
			|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 | 
					F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 | 
				
			||||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 | 
					F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 | 
				
			||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 | 
					F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 | 
				
			||||||
P ceac571f53bdbc02616b21a4404cb1250030dea8
 | 
					P 80541e8b94b713e8f9e588ae047ffc5ae804ef1c
 | 
				
			||||||
R af1132932e63d89318ed108ce444bb3a
 | 
					R 8c7ae3a28cebe6c4cd8f1efeb860b8e0
 | 
				
			||||||
U drh
 | 
					U drh
 | 
				
			||||||
Z 8c65f5a7bb0fabe2bc52b8a9296117bf
 | 
					Z d712af0bd91c24c0e42eda8fb9513bd5
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
80541e8b94b713e8f9e588ae047ffc5ae804ef1c
 | 
					7096e6c06d9a3e48d3f0d134f5f3275dde796be2
 | 
				
			||||||
							
								
								
									
										36
									
								
								src/shell.c
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								src/shell.c
									
									
									
									
									
								
							@@ -106,6 +106,26 @@ extern int pclose(FILE*);
 | 
				
			|||||||
#define IsDigit(X)  isdigit((unsigned char)X)
 | 
					#define IsDigit(X)  isdigit((unsigned char)X)
 | 
				
			||||||
#define ToLower(X)  (char)tolower((unsigned char)X)
 | 
					#define ToLower(X)  (char)tolower((unsigned char)X)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* On Windows, we normally run with output mode of TEXT so that \n characters
 | 
				
			||||||
 | 
					** are automatically translated into \r\n.  However, this behavior needs
 | 
				
			||||||
 | 
					** to be disabled in some cases (ex: when generating CSV output and when
 | 
				
			||||||
 | 
					** rendering quoted strings that contain \n characters).  The following
 | 
				
			||||||
 | 
					** routines take care of that.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					#if defined(_WIN32) || defined(WIN32)
 | 
				
			||||||
 | 
					static setBinaryMode(FILE *out){
 | 
				
			||||||
 | 
					  fflush(out);
 | 
				
			||||||
 | 
					  _setmode(_fileno(out), _O_BINARY);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					static setTextMode(FILE *out){
 | 
				
			||||||
 | 
					  fflush(out);
 | 
				
			||||||
 | 
					  _setmode(_fileno(out), _O_TEXT);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					# define setBinaryMode(X)
 | 
				
			||||||
 | 
					# define setTextMode(X)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* True if the timer is enabled */
 | 
					/* True if the timer is enabled */
 | 
				
			||||||
static int enableTimer = 0;
 | 
					static int enableTimer = 0;
 | 
				
			||||||
@@ -584,6 +604,7 @@ static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
 | 
				
			|||||||
static void output_quoted_string(FILE *out, const char *z){
 | 
					static void output_quoted_string(FILE *out, const char *z){
 | 
				
			||||||
  int i;
 | 
					  int i;
 | 
				
			||||||
  int nSingle = 0;
 | 
					  int nSingle = 0;
 | 
				
			||||||
 | 
					  setBinaryMode(out);
 | 
				
			||||||
  for(i=0; z[i]; i++){
 | 
					  for(i=0; z[i]; i++){
 | 
				
			||||||
    if( z[i]=='\'' ) nSingle++;
 | 
					    if( z[i]=='\'' ) nSingle++;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -606,6 +627,7 @@ static void output_quoted_string(FILE *out, const char *z){
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    fprintf(out,"'");
 | 
					    fprintf(out,"'");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  setTextMode(out);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
@@ -908,10 +930,7 @@ static int shell_callback(
 | 
				
			|||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case MODE_Csv: {
 | 
					    case MODE_Csv: {
 | 
				
			||||||
#if defined(WIN32) || defined(_WIN32)
 | 
					      setBinaryMode(p->out);
 | 
				
			||||||
      fflush(p->out);
 | 
					 | 
				
			||||||
      _setmode(_fileno(p->out), _O_BINARY);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
      if( p->cnt++==0 && p->showHeader ){
 | 
					      if( p->cnt++==0 && p->showHeader ){
 | 
				
			||||||
        for(i=0; i<nArg; i++){
 | 
					        for(i=0; i<nArg; i++){
 | 
				
			||||||
          output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
 | 
					          output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
 | 
				
			||||||
@@ -924,10 +943,7 @@ static int shell_callback(
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        fprintf(p->out, "%s", p->rowSeparator);
 | 
					        fprintf(p->out, "%s", p->rowSeparator);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
#if defined(WIN32) || defined(_WIN32)
 | 
					      setTextMode(p->out);
 | 
				
			||||||
      fflush(p->out);
 | 
					 | 
				
			||||||
      _setmode(_fileno(p->out), _O_TEXT);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    case MODE_Insert: {
 | 
					    case MODE_Insert: {
 | 
				
			||||||
@@ -4176,9 +4192,7 @@ int main(int argc, char **argv){
 | 
				
			|||||||
    exit(1);
 | 
					    exit(1);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#if defined(WIN32) || defined(_WIN32)
 | 
					  setBinaryMode(stdin);
 | 
				
			||||||
  _setmode(0, _O_BINARY);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
  Argv0 = argv[0];
 | 
					  Argv0 = argv[0];
 | 
				
			||||||
  main_init(&data);
 | 
					  main_init(&data);
 | 
				
			||||||
  stdin_is_interactive = isatty(0);
 | 
					  stdin_is_interactive = isatty(0);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user