From: mistachkin Date: Thu, 7 Nov 2013 22:11:55 +0000 (+0000) Subject: Fix temporary directory separator handling for Cygwin. X-Git-Tag: version-3.8.2~120^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2FcygDirSep;p=thirdparty%2Fsqlite.git Fix temporary directory separator handling for Cygwin. FossilOrigin-Name: 9d870d5f0d8f02e5c91396a1f98b5ddb56b40b70 --- diff --git a/manifest b/manifest index c955dd6734..4f7397798c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scompiler\swarning\sintroduced\sby\sthe\sprevious\scheck-in. -D 2013-11-07T21:32:16.228 +C Fix\stemporary\sdirectory\sseparator\shandling\sfor\sCygwin. +D 2013-11-07T22:11:55.758 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d12e4455cf7a36e42d3949876c1c3b88ff70867a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -205,7 +205,7 @@ F src/os.c b4ad71336fd96f97776f75587cd9e8218288f5be F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 143624d9eabb3b997c59cf594e0d06c56edd43e9 -F src/os_win.c b159b5249d9f70607d961bbdd1dbba789c75812c +F src/os_win.c cf9fde556e01b5f6f2e664f9abb7a59083e22c6a F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y 073a8294e1826f1b1656e84806b77e4199f4bb57 @@ -1135,7 +1135,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 215307985590c2f3f7aa0d5a0b7799155a506045 -R 71f9cd0b217f1ebad72089e906d8786f -U drh -Z 02285a59f788837fde6c69fc94247fe6 +P 404bd98fb41f71d041932d68a908570995825ec1 +R 37545b181f36caed5c7fe5390bfd2bd9 +T *branch * cygDirSep +T *sym-cygDirSep * +T -sym-trunk * +U mistachkin +Z ed8b65be89adc0112f5f37e7909c811f diff --git a/manifest.uuid b/manifest.uuid index 2befe228a2..5ecadff839 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -404bd98fb41f71d041932d68a908570995825ec1 \ No newline at end of file +9d870d5f0d8f02e5c91396a1f98b5ddb56b40b70 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index c6c567c00c..e329b553b9 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -117,14 +117,10 @@ #endif /* -** Returns the string that should be used as the directory separator. +** Returns the character that should be used as the directory separator. */ -#ifndef winGetDirDep -# ifdef __CYGWIN__ -# define winGetDirDep() "/" -# else -# define winGetDirDep() "\\" -# endif +#ifndef winGetDirSep +# define winGetDirSep() '\\' #endif /* @@ -3990,12 +3986,21 @@ static void *winConvertFromUtf8Filename(const char *zFilename){ /* ** This function returns non-zero if the specified UTF-8 string buffer -** ends with a directory separator character. +** ends with a directory separator character or one was successfully +** added to it. */ -static int winEndsInDirSep(char *zBuf){ +static int winMakeEndInDirSep(int nBuf, char *zBuf){ if( zBuf ){ int nLen = sqlite3Strlen30(zBuf); - return nLen>0 && winIsDirSep(zBuf[nLen-1]); + if( nLen>0 ){ + if( winIsDirSep(zBuf[nLen-1]) ){ + return 1; + }else if( nLen+1mxPathname; - zBuf = sqlite3MallocZero( nBuf+2 ); + zBuf = sqlite3MallocZero( nBuf+3 ); if( !zBuf ){ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); return SQLITE_IOERR_NOMEM; @@ -4035,9 +4040,8 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ */ assert( nBuf>30 ); if( sqlite3_temp_directory ){ - sqlite3_snprintf(nBuf-30, zBuf, "%s%s", sqlite3_temp_directory, - winEndsInDirSep(sqlite3_temp_directory) ? "" : - winGetDirDep()); + sqlite3_snprintf(nBuf-30, zBuf, "%s", sqlite3_temp_directory); + winMakeEndInDirSep(nBuf-30, zBuf); } #if defined(__CYGWIN__) else{ @@ -4066,8 +4070,8 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ if( zDir==0 ) continue; /* If the path starts with a drive letter followed by the colon ** character, assume it is already a native Win32 path; otherwise, - ** it must be converted to a native Win32 path prior via the Cygwin - ** API prior to using it. + ** it must be converted to a native Win32 path via the Cygwin API + ** prior to using it. */ if( winIsDriveLetterAndColon(zDir) ){ zConverted = winConvertFromUtf8Filename(zDir); @@ -4078,6 +4082,7 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ } if( winIsDir(zConverted) ){ sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir); + winMakeEndInDirSep(nBuf-30, zBuf); sqlite3_free(zConverted); break; } @@ -4112,11 +4117,13 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ return SQLITE_IOERR_NOMEM; } sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8); + winMakeEndInDirSep(nBuf-30, zBuf); sqlite3_free(zUtf8); sqlite3_free(zConverted); break; }else{ sqlite3_snprintf(nBuf-30, zBuf, "%s", zConverted); + winMakeEndInDirSep(nBuf-30, zBuf); sqlite3_free(zConverted); break; } @@ -4144,6 +4151,7 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ zMulti = winUnicodeToUtf8(zWidePath); if( zMulti ){ sqlite3_snprintf(nBuf-30, zBuf, "%s", zMulti); + winMakeEndInDirSep(nBuf-30, zBuf); sqlite3_free(zMulti); sqlite3_free(zWidePath); }else{ @@ -4171,6 +4179,7 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); if( zUtf8 ){ sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8); + winMakeEndInDirSep(nBuf-30, zBuf); sqlite3_free(zUtf8); }else{ sqlite3_free(zBuf); @@ -4792,8 +4801,8 @@ static int winFullPathname( return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, "winFullPathname1", zRelative); } - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", - sqlite3_data_directory, winGetDirDep(), zOut); + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", + sqlite3_data_directory, winGetDirSep(), zOut); sqlite3_free(zOut); }else{ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ @@ -4815,8 +4824,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%s", - sqlite3_data_directory, winGetDirDep(), zRelative); + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", + sqlite3_data_directory, winGetDirSep(), zRelative); }else{ sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); } @@ -4848,8 +4857,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%s", - sqlite3_data_directory, winGetDirDep(), zRelative); + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", + sqlite3_data_directory, winGetDirSep(), zRelative); return SQLITE_OK; } zConverted = winConvertFromUtf8Filename(zRelative);