From ea5989276aae181a73687e6198c58af0c99346f6 Mon Sep 17 00:00:00 2001 From: shane Date: Wed, 21 Oct 2009 02:00:47 +0000 Subject: [PATCH] For Windows VFS, modified xGetLastError() to call FormatMessage() with the FORMAT_MESSAGE_IGNORE_INSERTS option. Additionally updated to ensure strings are returned as UTF8. Ticket 39c85e8a4e. FossilOrigin-Name: 761396f8cb79be34853ba698a65af54874c3c10e --- configure | 0 install-sh | 0 manifest | 54 ++++++++++++----------------- manifest.uuid | 2 +- src/os_win.c | 68 +++++++++++++++++++++++++++---------- tool/fragck.tcl | 0 tool/mkopts.tcl | 0 tool/mkspeedsql.tcl | 0 tool/mksqlite3c.tcl | 0 tool/mksqlite3h.tcl | 0 tool/mksqlite3internalh.tcl | 0 tool/omittest.tcl | 0 tool/soak1.tcl | 0 tool/space_used.tcl | 0 tool/spaceanal.tcl | 0 tool/speedtest.tcl | 0 tool/speedtest2.tcl | 0 tool/vdbe-compress.tcl | 0 18 files changed, 73 insertions(+), 51 deletions(-) mode change 100755 => 100644 configure mode change 100755 => 100644 install-sh mode change 100755 => 100644 tool/fragck.tcl mode change 100755 => 100644 tool/mkopts.tcl mode change 100755 => 100644 tool/mkspeedsql.tcl mode change 100755 => 100644 tool/mksqlite3c.tcl mode change 100755 => 100644 tool/mksqlite3h.tcl mode change 100755 => 100644 tool/mksqlite3internalh.tcl mode change 100755 => 100644 tool/omittest.tcl mode change 100755 => 100644 tool/soak1.tcl mode change 100755 => 100644 tool/space_used.tcl mode change 100755 => 100644 tool/spaceanal.tcl mode change 100755 => 100644 tool/speedtest.tcl mode change 100755 => 100644 tool/speedtest2.tcl mode change 100755 => 100644 tool/vdbe-compress.tcl diff --git a/configure b/configure old mode 100755 new mode 100644 diff --git a/install-sh b/install-sh old mode 100755 new mode 100644 diff --git a/manifest b/manifest index 7a06ba63c7..ce09ea343f 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,5 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -C Clarify\sthe\suse\sof\ssqlite3_shutdown().\s\s\nTicket\s[f9af981dd2a2].\nComment\schanges\sonly\s-\sno\schanges\sto\scode. -D 2009-10-20T15:27:55 +C For\sWindows\sVFS,\smodified\sxGetLastError()\sto\scall\sFormatMessage()\s\nwith\sthe\sFORMAT_MESSAGE_IGNORE_INSERTS\soption.\s\sAdditionally\supdated\nto\sensure\sstrings\sare\sreturned\sas\sUTF8.\s\sTicket\s39c85e8a4e. +D 2009-10-21T02:00:48 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4ca3f1dd6efa2075bcb27f4dc43eef749877740d F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -22,7 +19,7 @@ F art/src_logo.gif 9341ef09f0e53cd44c0c9b6fc3c16f7f3d6c2ad9 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 868fdb48c028421a203470e15c69ada15b9ba673 F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 30e33c9dee7000cfa82fae0a2fe51b90a1c24bac x +F configure 30e33c9dee7000cfa82fae0a2fe51b90a1c24bac F configure.ac 14740970ddb674d92a9f5da89083dff1179014ff F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html f0f682f50210928c07e562621c3b7e8ab912a538 @@ -87,7 +84,7 @@ F ext/rtree/rtree_perf.tcl 0fabb6d5c48cb8024e042ce5d4bb88998b6ec1cb F ext/rtree/rtree_util.tcl ee0a0311eb12175319d78bfb37302320496cee6e F ext/rtree/tkt3363.test 6662237ea75bb431cd5d262dfc9535e1023315fc F ext/rtree/viewrtree.tcl 09526398dae87a5a87c5aac2b3854dbaf8376869 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk c3c5c6d038512603c4c8a2599955a86fbd9e6973 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -150,7 +147,7 @@ F src/os.h 00a1334a4eecee7f7bef79ac606b88d325119f21 F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5 F src/os_unix.c 5686c0e4f0aa2c93b43b66c563ea1d5b80cd4b9b -F src/os_win.c 49a360be4f42d5a63d00be9aa44449ed4d6717e0 +F src/os_win.c d02908847f3ad350fb9fd0804b7722627d30860d F src/pager.c ebd0a8f2421e8f0ad5b78201440004bf3e1c96d8 F src/pager.h 11852d044c86cf5a9d6e34171fb0c4fcf1f6265f F src/parse.y 2b75a329a5b3cdcb188609d9a30bb339aecfeddd @@ -740,38 +737,31 @@ F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5 F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b -F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 x +F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c 0eb9829c494dfcea449de36ad677efe7f0742801 F tool/lempar.c 2ed70b3fc896a47e07fedfe543324f008f53d223 F tool/mkkeywordhash.c 8c9f8e3253555101aaa4bf7a0459cbfc8ddc41cc -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x -F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 x -F tool/mksqlite3c.tcl 69dc8842a88d1f84c141e1a0bd2e42d8e859397f x -F tool/mksqlite3h.tcl eb100dce83f24b501b325b340f8b5eb8e5106b3b x -F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 x -F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a x +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e +F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 +F tool/mksqlite3c.tcl 69dc8842a88d1f84c141e1a0bd2e42d8e859397f +F tool/mksqlite3h.tcl eb100dce83f24b501b325b340f8b5eb8e5106b3b +F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 +F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/showdb.c 8ab8b3b53884312aafb7ef60982e255a6c31d238 F tool/showjournal.c ec3b171be148656827c4949fbfb8ab4370822f87 -F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe x -F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b x -F tool/spaceanal.tcl b87db46ae29e3116411b1686e136b9b994d7de39 x -F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 x +F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe +F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b +F tool/spaceanal.tcl b87db46ae29e3116411b1686e136b9b994d7de39 +F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 -F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff x +F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f x -P 0bbd8d72ec66cbe11c2548a04ad478202b2b69b6 -R e05c440be677d211f2825a857424fbcf -U drh -Z 35c6ef37b9a5953f94a41f5c5ef22654 ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.6 (GNU/Linux) - -iD8DBQFK3db+oxKgR168RlERAludAJ9qFRDQq+bdJV8pseixnH1c8NKiIQCeLf2F -lLzEUPB4zY338K+RqSCCBrg= -=asdE ------END PGP SIGNATURE----- +F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f +P b2aa48b52f140ad722001de686c5b2f802e9babd +R 88fe3851909db662467ab0ab67772332 +U shane +Z 511d63a6d62dacb90291925f2c8c96c3 diff --git a/manifest.uuid b/manifest.uuid index 00dab9a504..e9a11cdf0b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b2aa48b52f140ad722001de686c5b2f802e9babd \ No newline at end of file +761396f8cb79be34853ba698a65af54874c3c10e \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index bc03a4bc66..c8240f1c9e 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -73,7 +73,7 @@ */ #if SQLITE_OS_WINCE # define AreFileApisANSI() 1 -# define GetDiskFreeSpaceW() 0 +# define FormatMessageW(a,b,c,d,e,f,g) 0 #endif /* @@ -1248,27 +1248,59 @@ static int getTempname(int nBuf, char *zBuf){ ** otherwise (if the message was truncated). */ static int getLastErrorMsg(int nBuf, char *zBuf){ - DWORD error = GetLastError(); - -#if SQLITE_OS_WINCE - sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error); -#else /* FormatMessage returns 0 on failure. Otherwise it ** returns the number of TCHARs written to the output ** buffer, excluding the terminating null char. */ - if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - error, - 0, - zBuf, - nBuf-1, - 0)) - { + DWORD error = GetLastError(); + DWORD dwLen = 0; + char *zOut; + + if( isNT() ){ + WCHAR *zTempWide = NULL; + dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + error, + 0, + (LPWSTR) &zTempWide, + 0, + 0); + if( dwLen > 0 ){ + /* allocate a buffer and convert to UTF8 */ + zOut = unicodeToUtf8(zTempWide); + /* free the system buffer allocated by FormatMessage */ + LocalFree(zTempWide); + } +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. +** Since the ASCII version of these Windows API do not exist for WINCE, +** it's important to not reference them for WINCE builds. +*/ +#if SQLITE_OS_WINCE==0 + }else{ + char *zTemp = NULL; + dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + error, + 0, + (LPSTR) &zTemp, + 0, + 0); + if( dwLen > 0 ){ + /* allocate a buffer and convert to UTF8 */ + zOut = sqlite3_win32_mbcs_to_utf8(zTemp); + /* free the system buffer allocated by FormatMessage */ + LocalFree(zTemp); + } +#endif + } + if( 0 == dwLen ){ sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error); + }else{ + /* copy a maximum of nBuf chars to output buffer */ + sqlite3_snprintf(nBuf, zBuf, "%s", zOut); + /* free the UTF8 buffer */ + free(zOut); } -#endif - return 0; } @@ -1636,14 +1668,14 @@ static int getSectorSize( &dwDummy); }else{ /* trim path to just drive reference */ - CHAR *p = (CHAR *)zConverted; + char *p = (char *)zConverted; for(;*p;p++){ if( *p == '\\' ){ *p = '\0'; break; } } - dwRet = GetDiskFreeSpaceA((CHAR*)zConverted, + dwRet = GetDiskFreeSpaceA((char*)zConverted, &dwDummy, &bytesPerSector, &dwDummy, diff --git a/tool/fragck.tcl b/tool/fragck.tcl old mode 100755 new mode 100644 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100755 new mode 100644 diff --git a/tool/mkspeedsql.tcl b/tool/mkspeedsql.tcl old mode 100755 new mode 100644 diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl old mode 100755 new mode 100644 diff --git a/tool/mksqlite3h.tcl b/tool/mksqlite3h.tcl old mode 100755 new mode 100644 diff --git a/tool/mksqlite3internalh.tcl b/tool/mksqlite3internalh.tcl old mode 100755 new mode 100644 diff --git a/tool/omittest.tcl b/tool/omittest.tcl old mode 100755 new mode 100644 diff --git a/tool/soak1.tcl b/tool/soak1.tcl old mode 100755 new mode 100644 diff --git a/tool/space_used.tcl b/tool/space_used.tcl old mode 100755 new mode 100644 diff --git a/tool/spaceanal.tcl b/tool/spaceanal.tcl old mode 100755 new mode 100644 diff --git a/tool/speedtest.tcl b/tool/speedtest.tcl old mode 100755 new mode 100644 diff --git a/tool/speedtest2.tcl b/tool/speedtest2.tcl old mode 100755 new mode 100644 diff --git a/tool/vdbe-compress.tcl b/tool/vdbe-compress.tcl old mode 100755 new mode 100644 -- 2.47.2