From: larrybr Date: Sun, 29 Oct 2023 00:24:22 +0000 (+0000) Subject: Condition default UTF-8 console I/O for Windows builds on OS version 10 or more.... X-Git-Tag: version-3.44.0~13^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3017a6851ffabfbff536d233d922f2335f46a8af;p=thirdparty%2Fsqlite.git Condition default UTF-8 console I/O for Windows builds on OS version 10 or more. This is to accomodate an IsValidCodePage() API which may happily report CP_UTF8 as a valid code page when the stock console cannot, in fact, do UTF-8 I/O. FossilOrigin-Name: 6b9b2a886fd4d239c2e87c3f3809c011f77c0f60e0c279bbe4e1d1b53c609e2d --- diff --git a/manifest b/manifest index d2d1aeb7ec..1eba221ff9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Limit\sthe\srange\sof\sinteger\sunix\stimestamps\sin\sdate4.test,\ssince\ssome\ssystems\n(RaspberryPI)\scannot\sdeal\swith\stimestamp\svalues\sthat\sexceed\spow(2,31). -D 2023-10-28T16:19:21.185 +C Condition\sdefault\sUTF-8\sconsole\sI/O\sfor\sWindows\sbuilds\son\sOS\sversion\s10\sor\smore.\sThis\sis\sto\saccomodate\san\sIsValidCodePage()\sAPI\swhich\smay\shappily\sreport\sCP_UTF8\sas\sa\svalid\scode\spage\swhen\sthe\sstock\sconsole\scannot,\sin\sfact,\sdo\sUTF-8\sI/O. +D 2023-10-29T00:24:22.936 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -722,7 +722,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 31229276a8eb5b5de1428cd2d80f6f1cf8ffc5248be25e47cf575df12f1b8f23 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 64c9bc7494f3d220a27498137551762c25458282388ea9ac0a710dd6d5dc1510 -F src/shell.c.in 9b29276cb6447b4c608e77c08b49bd3315cdcb399801e08b2f15723aa5b733e8 +F src/shell.c.in 29b2abb039ddff7b512960a5396cecbaee6ab236537de36f4f972adbfc4467c1 F src/sqlite.h.in ef0e41e83ad1ac0dcc9ec9939bf541a44b1c5de821bee2d6c61754c3252f3276 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 2f30b2671f4c03cd27a43f039e11251391066c97d11385f5f963bb40b03038ac @@ -2139,8 +2139,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 33ba13c7c4b6f9c5e64ea30c819718f2caea214afca945c9ed7075864f4aaa40 -R 1be0f0e552da136234a76c43155a60a1 -U drh -Z 9c40aed2a8cf9df874dfb316aa86c044 +P 765290663b28e90a0494997baf023f9610a4ed32f0ff0099bf9fc3d485733fca +R 06beefd7b5a601159ef2b90a69791f5c +T *branch * win-utf8-io-split +T *sym-win-utf8-io-split * +T -sym-trunk * +U larrybr +Z 8b9699cbbd0e4aa806c0f866919f402f # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 4d8f453cfa..d8f3ed59bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -765290663b28e90a0494997baf023f9610a4ed32f0ff0099bf9fc3d485733fca \ No newline at end of file +6b9b2a886fd4d239c2e87c3f3809c011f77c0f60e0c279bbe4e1d1b53c609e2d \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index f1362d613d..e61887bc62 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -613,6 +613,40 @@ static struct ConsoleState { # define _O_U16TEXT 0x20000 #endif + +#if !SQLITE_OS_WINRT +static int CheckAtLeastWin10(void){ + typedef LONG (WINAPI *REG_OPEN)(HKEY,LPCSTR,DWORD,REGSAM,PHKEY); + typedef LSTATUS (WINAPI *REG_READ)(HKEY,LPCSTR,LPCSTR,DWORD, + LPDWORD,PVOID,LPDWORD); + typedef LSTATUS (WINAPI *REG_UNLOAD)(HKEY,LPCSTR); + int rv = 0; + HINSTANCE hLib = LoadLibrary(TEXT("Advapi32.dll")); + if( NULL != hLib ){ + REG_OPEN rkOpen = (REG_OPEN)GetProcAddress(hLib, "RegOpenKeyExA"); + REG_READ rkRead = (REG_READ)GetProcAddress(hLib, "RegGetValueA"); + REG_UNLOAD rkFree = (REG_UNLOAD)GetProcAddress(hLib, "RegUnLoadKeyA"); + if( rkOpen != NULL && rkRead != NULL && rkFree != NULL ){ + HKEY hk; + const char *zsk = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"; + if( ERROR_SUCCESS == rkOpen(HKEY_LOCAL_MACHINE, zsk, 0, KEY_READ, &hk) ){ + DWORD kv = 0, kvsize = sizeof(kv); + if( ERROR_SUCCESS == rkRead(hk, 0, "CurrentMajorVersionNumber", + RRF_RT_REG_DWORD, 0, &kv, &kvsize) ){ + rv = (kv >= 10); + } + rkFree(hk, 0); + } + } + FreeLibrary(hLib); + } + return rv; +} +# define IS_WIN10_OR_LATER() CheckAtLeastWin10() +#else /* defined(SQLITE_OS_WINRT) */ +# define IS_WIN10_OR_LATER() 0 +#endif + /* ** Prepare console, (if known to be a WIN32 console), for UTF-8 ** input (from either typing or suitable paste operations) and/or for @@ -12210,6 +12244,11 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ } #endif +#if SHELL_WIN_UTF8_OPT + /* If Windows build and not RT, set*/ + mbcs_opted = (IS_WIN10_OR_LATER())? 0 : 1; +#endif + /* Do an initial pass through the command-line argument to locate ** the name of the database file, the name of the initialization file, ** the size of the alternative malloc heap, options affecting commands @@ -12405,7 +12444,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ exit(1); } } - #if SHELL_WIN_UTF8_OPT /* Get indicated Windows console setup done before running invocation commands. */ if( stdin_is_interactive || stdout_is_console ){