From: mistachkin Date: Wed, 28 Aug 2013 02:26:48 +0000 (+0000) Subject: Remove hard-coding of the directory separator in the Win32 VFS. Fixes to OSTRACE... X-Git-Tag: version-3.8.1~122^2~5 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=533fb6de5bfb86930e58718200b7b8eea34764dc;p=thirdparty%2Fsqlite.git Remove hard-coding of the directory separator in the Win32 VFS. Fixes to OSTRACE macros. FossilOrigin-Name: fc98092f4bd42d64059024f09547904c1d70a517 --- diff --git a/manifest b/manifest index 4916545b93..c3dde0dc4f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sseveral\sharmless\scompiler\swarnings.\s\sFix\sa\scouple\scompiler\sissues\swith\sthe\sshell. -D 2013-08-28T01:54:12.702 +C Remove\shard-coding\sof\sthe\sdirectory\sseparator\sin\sthe\sWin32\sVFS.\s\sFixes\sto\sOSTRACE\smacros. +D 2013-08-28T02:26:48.559 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 52bbfe7f96fdb61fa71ba6f96eac43bcdc5c29a8 +F src/os_win.c 7f8cabe0ae13bf6303543197c349bd13a1aaaa0f 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 ec99224b0c9cf1ccd64b3dc93252556d888e93a3 -R 83bbd06201b37fcfd4ba93e170854819 +P 8917e9f9a0802cbfb6f33e2ab1c2f98e4df5babd +R 596c11dfb76cd23db3586c983e12df43 U mistachkin -Z 7a5beb9b27a8339428285f5cf59d377b +Z 1567302589a948f8e7270192d6781870 diff --git a/manifest.uuid b/manifest.uuid index 58a03672d6..3b379e9316 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8917e9f9a0802cbfb6f33e2ab1c2f98e4df5babd \ No newline at end of file +fc98092f4bd42d64059024f09547904c1d70a517 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index e07883a611..c9dd187ff8 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -91,6 +91,25 @@ # define SQLITE_WIN32_MAX_ERRMSG_CHARS (1024) #endif +/* +** Returns non-zero if the character should be treated as a directory +** separator. +*/ +#ifndef winIsDirSep +# define winIsDirSep(a) (((a) == '/') || ((a) == '\\')) +#endif + +/* +** Returns the string that should be used as the directory separator. +*/ +#ifndef winGetDirDep +# ifdef __CYGWIN__ +# define winGetDirDep() "/" +# else +# define winGetDirDep() "\\" +# endif +#endif + /* ** Do we need to manually define the Win32 file mapping APIs for use with WAL ** mode (e.g. these APIs are available in the Windows CE SDK; however, they @@ -2456,6 +2475,7 @@ static int winSync(sqlite3_file *id, int flags){ ** no-op */ #ifdef SQLITE_NO_SYNC + OSTRACE(("SYNC-NOP file=%p, rc=SQLITE_OK\n", pFile->h)); return SQLITE_OK; #else rc = osFlushFileBuffers(pFile->h); @@ -2749,10 +2769,10 @@ static int winLock(sqlite3_file *id, int locktype){ if( res ){ rc = SQLITE_OK; }else{ - OSTRACE(("LOCK-FAIL file=%p, wanted=%d, got=%d\n", - pFile->h, locktype, newLocktype)); pFile->lastErrno = lastErrno; rc = SQLITE_BUSY; + OSTRACE(("LOCK-FAIL file=%p, wanted=%d, got=%d\n", + pFile->h, locktype, newLocktype)); } pFile->locktype = (u8)newLocktype; OSTRACE(("LOCK file=%p, lock=%d, rc=%s\n", @@ -3995,12 +4015,12 @@ static int getTempname(int nBuf, char *zBuf){ return SQLITE_ERROR; } - for(i=nTempPath; i>0 && zTempPath[i-1]=='\\'; i--){} + for(i=nTempPath; i>0 && winIsDirSep(zTempPath[i-1]); i--){} zTempPath[i] = 0; sqlite3_snprintf(nBuf-18, zBuf, (nTempPath > 0) ? - "%s\\"SQLITE_TEMP_FILE_PREFIX : SQLITE_TEMP_FILE_PREFIX, - zTempPath); + "%s%s" SQLITE_TEMP_FILE_PREFIX : SQLITE_TEMP_FILE_PREFIX, + zTempPath, winGetDirDep()); j = sqlite3Strlen30(zBuf); sqlite3_randomness(15, &zBuf[j]); for(i=0; i<15; i++, j++){ @@ -4124,7 +4144,7 @@ static int winOpen( pFile->h = INVALID_HANDLE_VALUE; #if SQLITE_OS_WINRT - if( !sqlite3_temp_directory ){ + if( !zUtf8Name && !sqlite3_temp_directory ){ sqlite3_log(SQLITE_ERROR, "sqlite3_temp_directory variable should be set for WinRT"); } @@ -4134,7 +4154,7 @@ static int winOpen( ** temporary file name to use */ if( !zUtf8Name ){ - assert(isDelete && !isOpenJournal); + assert( isDelete && !isOpenJournal ); rc = getTempname(SQLITE_WIN32_MAX_PATH_BYTES+2, zTmpname); if( rc!=SQLITE_OK ){ OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc))); @@ -4148,7 +4168,7 @@ static int winOpen( ** sqlite3_uri_parameter(). */ assert( (eType!=SQLITE_OPEN_MAIN_DB) || (flags & SQLITE_OPEN_URI) || - zUtf8Name[strlen(zUtf8Name)+1]==0 ); + zUtf8Name[sqlite3Strlen30(zUtf8Name)+1]==0 ); /* Convert the filename to the system encoding. */ zConverted = convertUtf8Filename(zUtf8Name); @@ -4349,6 +4369,7 @@ static int winDelete( zConverted = convertUtf8Filename(zFilename); if( zConverted==0 ){ + OSTRACE(("DELETE name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename)); return SQLITE_IOERR_NOMEM; } if( isNT() ){ @@ -4530,7 +4551,7 @@ static BOOL winIsVerbatimPathname( ** the final two cases; therefore, we return the safer return value of TRUE ** so that callers of this function will simply use it verbatim. */ - if ( zPathname[0]=='/' || zPathname[0]=='\\' ){ + if ( winIsDirSep(zPathname[0]) ){ return TRUE; } @@ -4582,8 +4603,8 @@ static int winFullPathname( zRelative); return SQLITE_CANTOPEN_FULLPATH; } - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s", - sqlite3_data_directory, zOut); + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", + sqlite3_data_directory, winGetDirDep(), zOut); }else{ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path", @@ -4605,8 +4626,8 @@ static int winFullPathname( ** for converting the relative path name to an absolute ** one by prepending the data directory and a backslash. */ - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s", - sqlite3_data_directory, zRelative); + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", + sqlite3_data_directory, winGetDirDep(), zRelative); }else{ sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); } @@ -4638,8 +4659,8 @@ static int winFullPathname( ** for converting the relative path name to an absolute ** one by prepending the data directory and a backslash. */ - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s", - sqlite3_data_directory, zRelative); + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", + sqlite3_data_directory, winGetDirDep(), zRelative); return SQLITE_OK; } zConverted = convertUtf8Filename(zRelative);