From: drh <> Date: Tue, 28 Jan 2025 01:10:45 +0000 (+0000) Subject: Apparently I got the logic of [abfe488ed67e2e35] confused, even backwards. X-Git-Tag: version-3.49.0~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50637ca5c5420f807b9a49a0645f5d0c31aa3523;p=thirdparty%2Fsqlite.git Apparently I got the logic of [abfe488ed67e2e35] confused, even backwards. Change it so that the SQLITE_USE_W32_FOR_CONSOLE_IO macro causes Win32 APIs to be used for console I/O and for stdio to be used otherwise. This is reported to be necessary for builds that use a C-language runtime other than the one provided by Microsoft. This changes if for Windows only. It is a bug fix, though we don't have a test case that will demonstrate a malfunction. FossilOrigin-Name: 925e97e6f4238f02259a0c95b1fc668ae32a95329242f8eeae236ef207aca112 --- diff --git a/ext/misc/sqlite3_stdio.c b/ext/misc/sqlite3_stdio.c index be3acc665e..c9bceb1942 100644 --- a/ext/misc/sqlite3_stdio.c +++ b/ext/misc/sqlite3_stdio.c @@ -46,6 +46,11 @@ ** use O_U8TEXT when writing to the Windows console (or anything ** else for which _isatty() returns true) and to use O_BINARY or O_TEXT ** for all other output channels. +** +** The SQLITE_USE_W32_FOR_CONSOLE_IO macro is also available. If +** defined, it forces the use of Win32 APIs for all console I/O, both +** input and output. This is necessary for some non-Microsoft run-times +** that implement stdio differently from Microsoft/Visual-Studio. */ #if defined(SQLITE_U8TEXT_ONLY) # define UseWtextForOutput(fd) 1 @@ -148,7 +153,7 @@ char *sqlite3_fgets(char *buf, int sz, FILE *in){ */ wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) ); if( b1==0 ) return 0; -#ifndef SQLITE_USE_STDIO_FOR_CONSOLE +#ifdef SQLITE_USE_W32_FOR_CONSOLE_IO DWORD nRead = 0; if( IsConsole(in) && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1, &nRead, 0) @@ -226,7 +231,7 @@ int sqlite3_fputs(const char *z, FILE *out){ sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz); b1[sz] = 0; -#ifndef SQLITE_STDIO_FOR_CONSOLE +#ifdef SQLITE_USE_W32_FOR_CONSOLE_IO DWORD nWr = 0; if( IsConsole(out) && WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),b1,sz,&nWr,0) @@ -236,8 +241,9 @@ int sqlite3_fputs(const char *z, FILE *out){ }else #endif { - /* For non-console I/O, or if SQLITE_USE_STDIO_FOR_CONSOLE is defined - ** then write using the standard library. */ + /* As long as SQLITE_USE_W32_FOR_CONSOLE_IO is not defined, or for + ** non-console I/O even if that macro is defined, write using the + ** standard library. */ _setmode(_fileno(out), _O_U8TEXT); if( UseBinaryWText(out) ){ piecemealOutput(b1, sz, out); diff --git a/manifest b/manifest index 1d8c3e1f3e..359b597c81 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sALWAYS()\sin\sthe\sstar-query\sheuristic\sthat\sis\ssometimes\sfalse\sif\syou\nhave\sa\scorrupt\sdatabase.\s\sdbsqlfuzz\sc37ba7728d79859b79c8341b59297e88fba017d3.\nTest\scase\sin\sTH3. -D 2025-01-28T00:48:01.787 +C Apparently\sI\sgot\sthe\slogic\sof\s[abfe488ed67e2e35]\sconfused,\seven\sbackwards.\nChange\sit\sso\sthat\sthe\sSQLITE_USE_W32_FOR_CONSOLE_IO\smacro\scauses\sWin32\sAPIs\nto\sbe\sused\sfor\sconsole\sI/O\sand\sfor\sstdio\sto\sbe\sused\sotherwise.\s\sThis\sis\nreported\sto\sbe\snecessary\sfor\sbuilds\sthat\suse\sa\sC-language\sruntime\sother\sthan\nthe\sone\sprovided\sby\sMicrosoft.\s\sThis\schanges\sif\sfor\sWindows\sonly.\s\sIt\sis\sa\nbug\sfix,\sthough\swe\sdon't\shave\sa\stest\scase\sthat\swill\sdemonstrate\sa\smalfunction. +D 2025-01-28T01:10:45.744 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -442,7 +442,7 @@ F ext/misc/shathree.c f3a778f27bf3e71b666a77f28e463a3b931c4dbe4219447e61bb678b4b F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 F ext/misc/spellfix.c bcc42ef3fd29429bc01a83e751332b8d4690e65d45008449bdffe7656371487f F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634 -F ext/misc/sqlite3_stdio.c 18160504b9348d0ebb9f5620fd61e64cd2d55fffde05ab3f7db03396add4840a +F ext/misc/sqlite3_stdio.c 0fe5a45bd332b30aef2b68c64edbe69e31e9c42365b0fa79ce95a034bca6fbb0 F ext/misc/sqlite3_stdio.h f05eaf5e0258f0573910324a789a9586fc360a57678c57a6d63cfaa2245b6176 F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321 F ext/misc/stmtrand.c 59cffa5d8e158943ff1ce078956d8e208e8c04e67307e8f249dece2436dcb7fc @@ -2208,8 +2208,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8be956383e0344fb613ec2e56fce7b518f439ae34bf9ddb424de2bd9b31c9889 -R 77d3f24a906693f579bd3b508d5195e5 +P 6b9a339628eb8bfb6dfbee02000a6ac91cc8a9ae16bd990e62c4142b9f912c36 +R 85cb8890cc290d809a1a9ad2ffbbbd4c U drh -Z 249159a5b98132893f1e97c49e03bb71 +Z 5b8003927aa3346b085a7fb5e605a55b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a380877b99..2cf98d2e84 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b9a339628eb8bfb6dfbee02000a6ac91cc8a9ae16bd990e62c4142b9f912c36 +925e97e6f4238f02259a0c95b1fc668ae32a95329242f8eeae236ef207aca112