From: drh <> Date: Tue, 28 Jan 2025 01:37:49 +0000 (+0000) Subject: The new SQLITE_USE_W32_FOR_CONSOLE_IO macro causes Win32 APIs X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d5d941c36adf16ddb153116a1b74027741c144a1;p=thirdparty%2Fsqlite.git The new 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: bfb7f49954f8ea376179e82ef2cdce1fe6a36cf7690a8d9c39084e2fef4935de --- 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 1390d7dd1b..c6e690bfb2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sfts5\sbetter\shandle\sOOM\serrors\sfrom\ssqlite3_blob_close(). -D 2025-01-23T11:42:21.210 +C The\snew\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:37:49.966 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 @@ -2205,9 +2205,9 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 92b06a4c91ee8f2efa4450bd6f01588139248048f32a6a7918dd10cd6a8e7837 -Q +f418350f3f83147bc5817a885be6e39ff9ff5722742a88d17600729c53c65010 -R 4c166982e9081628f13a0964d220e1c5 -U dan -Z b93ab420abc842718c6eea6e05360b74 +P 7ffa7e0244bb70a24a9248e477738c6e88176f7bd24294f808a666a1fc5ac3e0 +Q +925e97e6f4238f02259a0c95b1fc668ae32a95329242f8eeae236ef207aca112 +R 52b5f6fb516dc1109aa6788467a015f4 +U drh +Z 314c784d298017f58045c2b92b573c87 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3401d7d8f3..745f3b7e1b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7ffa7e0244bb70a24a9248e477738c6e88176f7bd24294f808a666a1fc5ac3e0 +bfb7f49954f8ea376179e82ef2cdce1fe6a36cf7690a8d9c39084e2fef4935de