Merge the Cygwin directory separator fix. Also fix a C++-ism in the

multiplexor code so that it will compile on MSVC.

FossilOrigin-Name: 830629d31d171155d90ff87ae8e70094d17bb2d3
This commit is contained in:
drh 2013-11-08 17:03:50 +00:00
commit 95a5bcbb00
4 changed files with 42 additions and 31 deletions

View File

@ -1,5 +1,5 @@
C Performance\simprovement:\sAvoid\sunnecessary\sseeks\son\sREPLACE\sINTO\sfor\sa\nWITHOUT\sROWID\stable.
D 2013-11-08T16:54:56.609
C Merge\sthe\sCygwin\sdirectory\sseparator\sfix.\s\sAlso\sfix\sa\sC++-ism\sin\sthe\nmultiplexor\scode\sso\sthat\sit\swill\scompile\son\sMSVC.
D 2013-11-08T17:03:50.071
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
@ -253,7 +253,7 @@ F src/test_intarray.h 2ece66438cfd177b78d1bfda7a4180cd3a10844d
F src/test_journal.c f5c0a05b7b3d5930db769b5ee6c3766dc2221a64
F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e
F src/test_malloc.c eba4e1c5847cc98e7edc98f62265cd2abafba7a6
F src/test_multiplex.c 6f63947cca286eeed0adc5f8d63fb17347648d4b
F src/test_multiplex.c 9f304bf04170c91c0318238d512df2da039eb1c8
F src/test_multiplex.h 110a8c4d356e0aa464ca8730375608a9a0b61ae1
F src/test_mutex.c 293042d623ebba969160f471a82aa1551626454f
F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25
@ -1135,7 +1135,8 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 6f187a0fb1b09ebc4732c4afbf3c813f82e069f1
R eedb71726af8e12f0f13d18d7fd22009
P fd11afa5f5c853dcac2290444b581a3fe1d4332d 9d870d5f0d8f02e5c91396a1f98b5ddb56b40b70
R deb20dcd1b212d002ce341c4a8b6d225
T +closed 9d870d5f0d8f02e5c91396a1f98b5ddb56b40b70
U drh
Z 047e6bb9b5b607bfaacf5c7e4c685d04
Z 91483894a7585609e534fd671adf83ff

View File

@ -1 +1 @@
fd11afa5f5c853dcac2290444b581a3fe1d4332d
830629d31d171155d90ff87ae8e70094d17bb2d3

View File

@ -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+1<nBuf ){
zBuf[nLen] = winGetDirSep();
zBuf[nLen+1] = '\0';
return 1;
}
}
}
return 0;
}
@ -4023,7 +4028,7 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){
** name for the temporary file. If this fails, we cannot continue.
*/
nBuf = pVfs->mxPathname;
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);

View File

@ -768,8 +768,9 @@ static int multiplexRead(
}else{
while( iAmt > 0 ){
int i = (int)(iOfst / pGroup->szChunk);
sqlite3_file *pSubOpen;
if( nMutex==0 ){ multiplexEnter(); nMutex++; }
sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, i, &rc, NULL, 1);
pSubOpen = multiplexSubOpen(pGroup, i, &rc, NULL, 1);
multiplexLeave(); nMutex--;
if( pSubOpen ){
int extra = ((int)(iOfst % pGroup->szChunk) + iAmt) - pGroup->szChunk;