From: drh Date: Wed, 10 Jan 2018 22:15:37 +0000 (+0000) Subject: An attempt to get ".once -e" working reliably on Windows. X-Git-Tag: version-3.22.0~56^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a92a01a77eadf7a582f2973efe2fd371c38fe92b;p=thirdparty%2Fsqlite.git An attempt to get ".once -e" working reliably on Windows. FossilOrigin-Name: 9b97f9d2c876162139dbd9485fcf68412d1572d9ddc179b08938b8a602e895d6 --- diff --git a/manifest b/manifest index 6b08444735..acd4d81085 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\spotential\sSQLITE_MISUSE\sin\sthe\s.excel\scommand\swhen\sno\sdatabase\sis\sopen. -D 2018-01-10T21:50:08.964 +C An\sattempt\sto\sget\s".once\s-e"\sworking\sreliably\son\sWindows. +D 2018-01-10T22:15:37.810 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 38f84f301cbef443b2d269f67a74b8cc536469831f70df7c3e912acc04932cc2 @@ -484,7 +484,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74 -F src/shell.c.in 362e3af76b80c3bd688f1f6fc8df407e651b71a65f0d919287eb6db5c357260c +F src/shell.c.in 8ac56c0e57d87f04c7c021d17d541063fd4cd9e5cd558caf40a63bf42875b8a9 F src/sqlite.h.in 1f1a2da222ec57465794e8984d77f32d0bd0da80cdc136beadda461a0be9d80c F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1697,7 +1697,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 23fa7c57c2b204d1ddcc2a939b5271628cf26689ad4ede6976038113095a9801 -R ba511ddf16c10fcf8fdff3518b957cd4 +P 9b95ff1abfb8d49bbe5a727f5c917a455e4289b4d69196377dc9294409341d70 +R 0c911dcb6179b38e957861df043bdcc3 U drh -Z 0681d6d553d7112baca91b9b1918eb9d +Z 8c9fcb0a09d556e95bbd5b8371ae82b1 diff --git a/manifest.uuid b/manifest.uuid index 4442a7e3cf..e5bf4629ab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b95ff1abfb8d49bbe5a727f5c917a455e4289b4d69196377dc9294409341d70 \ No newline at end of file +9b97f9d2c876162139dbd9485fcf68412d1572d9ddc179b08938b8a602e895d6 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index c76b305450..fae70a1ece 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -3507,7 +3507,7 @@ static void output_file_close(FILE *f){ ** recognized and do the right thing. NULL is returned if the output ** filename is "off". */ -static FILE *output_file_open(const char *zFile){ +static FILE *output_file_open(const char *zFile, int bTextMode){ FILE *f; if( strcmp(zFile,"stdout")==0 ){ f = stdout; @@ -3516,7 +3516,7 @@ static FILE *output_file_open(const char *zFile){ }else if( strcmp(zFile, "off")==0 ){ f = 0; }else{ - f = fopen(zFile, "wb"); + f = fopen(zFile, bTextMode ? "w" : "wb"); if( f==0 ){ utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile); } @@ -3953,7 +3953,9 @@ static void output_reset(ShellState *p){ #endif char *zCmd; zCmd = sqlite3_mprintf("%s %s", zXdgOpenCmd, p->zTempFile); - system(zCmd); + if( system(zCmd) ){ + utf8_printf(stderr, "Failed: [%s]\n", zCmd); + } sqlite3_free(zCmd); p->mode = p->doXdgOpen - 1; p->doXdgOpen = 0; @@ -6058,7 +6060,7 @@ static int do_meta_command(char *zLine, ShellState *p){ }else{ const char *zFile = azArg[1]; output_file_close(p->pLog); - p->pLog = output_file_open(zFile); + p->pLog = output_file_open(zFile, 0); } }else @@ -6172,6 +6174,7 @@ static int do_meta_command(char *zLine, ShellState *p){ || (c=='e' && n==5 && strcmp(azArg[0],"excel")==0) ){ const char *zFile = nArg>=2 ? azArg[1] : "stdout"; + int bTxtMode = 0; if( azArg[0][0]=='e' ){ /* Transform the ".excel" command into ".once -x" */ nArg = 2; @@ -6205,6 +6208,7 @@ static int do_meta_command(char *zLine, ShellState *p){ sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_CrLf); }else{ newTempFile(p, "txt"); + bTxtMode = 1; } zFile = p->zTempFile; } @@ -6224,7 +6228,7 @@ static int do_meta_command(char *zLine, ShellState *p){ } #endif }else{ - p->out = output_file_open(zFile); + p->out = output_file_open(zFile, bTxtMode); if( p->out==0 ){ if( strcmp(zFile,"off")!=0 ){ utf8_printf(stderr,"Error: cannot write to \"%s\"\n", zFile); @@ -7101,7 +7105,7 @@ static int do_meta_command(char *zLine, ShellState *p){ /* Begin redirecting output to the file "testcase-out.txt" */ if( c=='t' && strcmp(azArg[0],"testcase")==0 ){ output_reset(p); - p->out = output_file_open("testcase-out.txt"); + p->out = output_file_open("testcase-out.txt", 0); if( p->out==0 ){ raw_printf(stderr, "Error: cannot open 'testcase-out.txt'\n"); } @@ -7307,7 +7311,7 @@ static int do_meta_command(char *zLine, ShellState *p){ goto meta_command_exit; } output_file_close(p->traceOut); - p->traceOut = output_file_open(azArg[1]); + p->traceOut = output_file_open(azArg[1], 0); #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) if( p->traceOut==0 ){ sqlite3_trace_v2(p->db, 0, 0, 0);