From: mistachkin Date: Mon, 26 Aug 2013 20:45:50 +0000 (+0000) Subject: Change MAX_PATH related defines to use character lengths where WCHARs are used. X-Git-Tag: version-3.8.1~122^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=31706a2d940459e1de326942fcf2080d33cde398;p=thirdparty%2Fsqlite.git Change MAX_PATH related defines to use character lengths where WCHARs are used. FossilOrigin-Name: 0a497083e915520c0807cb6611264b1a35ff62b7 --- diff --git a/manifest b/manifest index e9f6e2333f..43a3a04a88 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\supdates\sfrom\strunk. -D 2013-08-26T19:36:18.286 +C Change\sMAX_PATH\srelated\sdefines\sto\suse\scharacter\slengths\swhere\sWCHARs\sare\sused. +D 2013-08-26T20:45:50.504 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -203,7 +203,7 @@ F src/os.c b4ad71336fd96f97776f75587cd9e8218288f5be F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c c27a14a05061e4e690bd3949dc0246bda35e399d -F src/os_win.c 339cdb887654f805a3e7225dd67f210cd5c831d3 +F src/os_win.c c05cd62a7af20004414a425c0f798cf5db36ba9f F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f @@ -1105,7 +1105,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P bda4c47df8e80b4cc9e8aac8fd74482869f96107 edd5dbdc3239fc88799b822941603fcc828ecbb6 -R f8b228db3f91433cfd67191a80e72ad7 +P 9d6860098f96efc7ea60e2d6116fb7d0e2685a55 +R 299a595b50bdbcb5444938600e71cf89 U mistachkin -Z d72989ebb46558e2aa62256a6f0f9391 +Z 552a2531f97ec783e6ad2f14086120a6 diff --git a/manifest.uuid b/manifest.uuid index ed4f6aa8e8..24daa7a0ef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d6860098f96efc7ea60e2d6116fb7d0e2685a55 \ No newline at end of file +0a497083e915520c0807cb6611264b1a35ff62b7 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 0f27ac43f2..7bf8828dbc 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -50,22 +50,28 @@ # define SQLITE_WIN32_HAS_WIDE #endif +/* +** Maximum pathname length (in chars) for Win32. This should normally be +** MAX_PATH. +*/ +#ifndef SQLITE_WIN32_MAX_PATH_CHARS +# define SQLITE_WIN32_MAX_PATH_CHARS (MAX_PATH) +#endif + /* ** Maximum pathname length (in bytes) for Win32. The MAX_PATH macro is in ** characters, so we allocate 3 bytes per character assuming worst-case of ** 3-bytes-per-character for UTF8. */ -#ifndef SQLITE_WIN32_MAX_PATH -# define SQLITE_WIN32_MAX_PATH (MAX_PATH*3) +#ifndef SQLITE_WIN32_MAX_PATH_BYTES +# define SQLITE_WIN32_MAX_PATH_BYTES (SQLITE_WIN32_MAX_PATH_CHARS*3) #endif /* -** Maximum error message length (in bytes) for WinRT. The MAX_PATH macro is -** in characters, so we allocate 3 bytes per character assuming worst-case of -** 3-bytes-per-character for UTF8. +** Maximum error message length (in chars) for WinRT. */ -#ifndef SQLITE_WIN32_MAX_ERRMSG -# define SQLITE_WIN32_MAX_ERRMSG (MAX_PATH*3) +#ifndef SQLITE_WIN32_MAX_ERRMSG_CHARS +# define SQLITE_WIN32_MAX_ERRMSG_CHARS (1024) #endif /* @@ -1481,14 +1487,14 @@ static int getLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){ if( isNT() ){ #if SQLITE_OS_WINRT - WCHAR zTempWide[SQLITE_WIN32_MAX_ERRMSG+1]; /* NOTE: Somewhat arbitrary. */ + WCHAR zTempWide[SQLITE_WIN32_MAX_ERRMSG_CHARS+1]; dwLen = osFormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, lastErrno, 0, zTempWide, - SQLITE_WIN32_MAX_ERRMSG, + SQLITE_WIN32_MAX_ERRMSG_CHARS, 0); #else LPWSTR zTempWide = NULL; @@ -3897,7 +3903,7 @@ static int getTempname(int nBuf, char *zBuf){ "0123456789"; size_t i, j; int nTempPath; - char zTempPath[SQLITE_WIN32_MAX_PATH+2]; + char zTempPath[SQLITE_WIN32_MAX_PATH_BYTES+2]; /* It's odd to simulate an io-error here, but really this is just ** using the io-error infrastructure to test that SQLite handles this @@ -3906,20 +3912,20 @@ static int getTempname(int nBuf, char *zBuf){ SimulateIOError( return SQLITE_IOERR ); if( sqlite3_temp_directory ){ - sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", + sqlite3_snprintf(SQLITE_WIN32_MAX_PATH_BYTES-30, zTempPath, "%s", sqlite3_temp_directory); } #if !SQLITE_OS_WINRT else if( isNT() ){ char *zMulti; - WCHAR zWidePath[SQLITE_WIN32_MAX_PATH]; - if( osGetTempPathW(SQLITE_WIN32_MAX_PATH-30, zWidePath)==0 ){ + WCHAR zWidePath[SQLITE_WIN32_MAX_PATH_CHARS]; + if( osGetTempPathW(SQLITE_WIN32_MAX_PATH_CHARS-30, zWidePath)==0 ){ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n")); return SQLITE_IOERR_GETTEMPPATH; } zMulti = unicodeToUtf8(zWidePath); if( zMulti ){ - sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti); + sqlite3_snprintf(SQLITE_WIN32_MAX_PATH_BYTES-30, zTempPath, "%s", zMulti); sqlite3_free(zMulti); }else{ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); @@ -3929,14 +3935,14 @@ static int getTempname(int nBuf, char *zBuf){ #ifdef SQLITE_WIN32_HAS_ANSI else{ char *zUtf8; - char zMbcsPath[SQLITE_WIN32_MAX_PATH]; - if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){ + char zMbcsPath[SQLITE_WIN32_MAX_PATH_BYTES]; + if( osGetTempPathA(SQLITE_WIN32_MAX_PATH_BYTES-30, zMbcsPath)==0 ){ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n")); return SQLITE_IOERR_GETTEMPPATH; } zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); if( zUtf8 ){ - sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8); + sqlite3_snprintf(SQLITE_WIN32_MAX_PATH_BYTES-30, zTempPath, "%s", zUtf8); sqlite3_free(zUtf8); }else{ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); @@ -3949,7 +3955,7 @@ static int getTempname(int nBuf, char *zBuf){ ** Compiled without ANSI support and the current operating system ** is not Windows NT; therefore, just zero the temporary buffer. */ - memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2); + memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH_BYTES+2); } #endif /* SQLITE_WIN32_HAS_ANSI */ #else @@ -3958,7 +3964,7 @@ static int getTempname(int nBuf, char *zBuf){ ** Compiled for WinRT and the sqlite3_temp_directory is not set; ** therefore, just zero the temporary buffer. */ - memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2); + memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH_BYTES+2); } #endif /* !SQLITE_OS_WINRT */ @@ -4046,7 +4052,7 @@ static int winOpen( /* If argument zPath is a NULL pointer, this function is required to open ** a temporary file. Use this buffer to store the file name in. */ - char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */ + char zTmpname[SQLITE_WIN32_MAX_PATH_BYTES+2]; /* Buffer for temp filename */ int rc = SQLITE_OK; /* Function Return Code */ #if !defined(NDEBUG) || SQLITE_OS_WINCE @@ -4112,7 +4118,7 @@ static int winOpen( */ if( !zUtf8Name ){ assert(isDelete && !isOpenJournal); - rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname); + rc = getTempname(SQLITE_WIN32_MAX_PATH_BYTES+2, zTmpname); if( rc!=SQLITE_OK ){ OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc))); return rc; @@ -4543,7 +4549,7 @@ static int winFullPathname( #if defined(__CYGWIN__) SimulateIOError( return SQLITE_ERROR ); UNUSED_PARAMETER(nFull); - assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH ); + assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH_BYTES ); assert( nFull>=pVfs->mxPathname ); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* @@ -4552,9 +4558,9 @@ static int winFullPathname( ** for converting the relative path name to an absolute ** one by prepending the data directory and a slash. */ - char zOut[SQLITE_WIN32_MAX_PATH+1]; + char zOut[SQLITE_WIN32_MAX_PATH_BYTES+1]; if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut, - SQLITE_WIN32_MAX_PATH+1)<0 ){ + SQLITE_WIN32_MAX_PATH_BYTES+1)<0 ){ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path", zRelative); return SQLITE_CANTOPEN_FULLPATH; @@ -4908,7 +4914,7 @@ int sqlite3_os_init(void){ static sqlite3_vfs winVfs = { 3, /* iVersion */ sizeof(winFile), /* szOsFile */ - SQLITE_WIN32_MAX_PATH, /* mxPathname */ + SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */ 0, /* pNext */ "win32", /* zName */ 0, /* pAppData */