From d95a3d3527d6d3db37759cdbda7850fdd52c1090 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 30 Aug 2013 21:52:38 +0000 Subject: [PATCH 1/6] Add support for Cygwin when handling temporary file names. Improve error codes and diagnostic messages for temporary file name handling on Windows. Rename winConvertUtf8Filename to winConvertFromUtf8Filename. Improve placement and comments for forward function declarations. FossilOrigin-Name: a411df725153119acb3bcf44fb71deecaa307887 --- manifest | 23 ++++---- manifest.uuid | 2 +- src/main.c | 2 + src/os_unix.c | 4 +- src/os_win.c | 151 ++++++++++++++++++++++++++++++++++++++++++------ src/sqlite.h.in | 2 + 6 files changed, 154 insertions(+), 30 deletions(-) diff --git a/manifest b/manifest index 9b210d3d88..40a9efb0be 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompiler\swarnings\sin\sanalyze.c. -D 2013-08-30T20:19:52.698 +C Add\ssupport\sfor\sCygwin\swhen\shandling\stemporary\sfile\snames.\s\sImprove\serror\scodes\sand\sdiagnostic\smessages\sfor\stemporary\sfile\sname\shandling\son\sWindows.\s\sRename\swinConvertUtf8Filename\sto\swinConvertFromUtf8Filename.\s\sImprove\splacement\sand\scomments\sfor\sforward\sfunction\sdeclarations. +D 2013-08-30T21:52:38.235 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -185,7 +185,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303 -F src/main.c dc02c7c118d58049e0cccc6c9c47c0a4d3e2bcda +F src/main.c c4c781b06faa2ce4040c32a75fd931a07ba7054e F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa @@ -202,8 +202,8 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c b4ad71336fd96f97776f75587cd9e8218288f5be F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 -F src/os_unix.c 7d5f3c51db561804e3ff3d47970a58bc6ea4d662 -F src/os_win.c 26d752736dff0c7e4e384ab65b353cce1e7e19c5 +F src/os_unix.c 243fb37f47dc072fc59839ea241ff0a17c8d76e6 +F src/os_win.c 8e87c2718975bc3cd8d86bf3ff2cc3bbafbc7eaf F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f @@ -218,7 +218,7 @@ F src/resolve.c 9d53899cc6e1f4ec0b4632d07e97d57827bf63b9 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 8b148eb851f384412aea57091659d14b369918ca F src/shell.c dbe064d404bb497acd8a44c066cd6b8460a71236 -F src/sqlite.h.in bd1451ba1ab681022a53bccc3c39580ba094a3ff +F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc F src/sqliteInt.h 600086a5082e2291b0aeeefcfbb546f2bbda67b2 @@ -1109,7 +1109,10 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P dbc31750440226702fbf88f1bf6140ef403c9be1 -R 5df52e9a380e1241cf1df8d1d5fbe7ea -U dan -Z 33fcbfc1bf7d299e3e7e4e929460c0cd +P 5bbd2ccb3d2d6286fd667dac2ab658d6b89640a6 +R 72dd46cadd0f990a967d544f6edf59de +T *branch * cygwinTempPath +T *sym-cygwinTempPath * +T -sym-trunk * +U mistachkin +Z 23133362076223f26c27390373169480 diff --git a/manifest.uuid b/manifest.uuid index e0a1d44337..44a442d40d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5bbd2ccb3d2d6286fd667dac2ab658d6b89640a6 \ No newline at end of file +a411df725153119acb3bcf44fb71deecaa307887 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 7e817e5953..4697009666 100644 --- a/src/main.c +++ b/src/main.c @@ -1107,6 +1107,7 @@ const char *sqlite3ErrName(int rc){ case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break; case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break; case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break; + case SQLITE_IOERR_CONVPATH: zName = "SQLITE_IOERR_CONVPATH"; break; case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break; case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break; case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break; @@ -1115,6 +1116,7 @@ const char *sqlite3ErrName(int rc){ case SQLITE_CANTOPEN_NOTEMPDIR: zName = "SQLITE_CANTOPEN_NOTEMPDIR";break; case SQLITE_CANTOPEN_ISDIR: zName = "SQLITE_CANTOPEN_ISDIR"; break; case SQLITE_CANTOPEN_FULLPATH: zName = "SQLITE_CANTOPEN_FULLPATH"; break; + case SQLITE_CANTOPEN_CONVPATH: zName = "SQLITE_CANTOPEN_CONVPATH"; break; case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break; case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break; case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break; diff --git a/src/os_unix.c b/src/os_unix.c index 797ace031d..cd8cec0046 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5338,6 +5338,7 @@ static int fillInUnixFile( */ static const char *unixTempFileDir(void){ static const char *azDirs[] = { + 0, 0, 0, "/var/tmp", @@ -5350,7 +5351,8 @@ static const char *unixTempFileDir(void){ const char *zDir = 0; azDirs[0] = sqlite3_temp_directory; - if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR"); + if( !azDirs[1] ) azDirs[1] = getenv("SQLITE_TMPDIR"); + if( !azDirs[2] ) azDirs[2] = getenv("TMPDIR"); for(i=0; i0 -/* Forward references to VFS methods */ +/* Forward references to VFS helper methods used for memory mapped files */ +static int winMapfile(winFile*, sqlite3_int64); static int winUnmapfile(winFile*); #endif @@ -2870,11 +2871,10 @@ static void winModeBit(winFile *pFile, unsigned char mask, int *pArg){ } } -/* Forward declaration */ +/* Forward references to VFS helper methods used for temporary files */ static int winGetTempname(sqlite3_vfs *, char **); -#if SQLITE_MAX_MMAP_SIZE>0 -static int winMapfile(winFile*, sqlite3_int64); -#endif +static int winIsDir(const void *); +static BOOL winIsDriveLetterAndColon(const char *); /* ** Control and query of the open file handle. @@ -3909,13 +3909,32 @@ static const sqlite3_io_methods winIoMethod = { ** sqlite3_vfs object. */ +/* +** Convert a filename from whatever the underlying operating system +** supports for filenames into UTF-8. Space to hold the result is +** obtained from malloc and must be freed by the calling function. +*/ +static char *winConvertToUtf8Filename(const void *zFilename){ + char *zConverted = 0; + if( osIsNT() ){ + zConverted = winUnicodeToUtf8(zFilename); + } +#ifdef SQLITE_WIN32_HAS_ANSI + else{ + zConverted = sqlite3_win32_mbcs_to_utf8(zFilename); + } +#endif + /* caller will handle out of memory */ + return zConverted; +} + /* ** Convert a UTF-8 filename into whatever form the underlying ** operating system wants filenames in. Space to hold the result ** is obtained from malloc and must be freed by the calling ** function. */ -static void *winConvertUtf8Filename(const char *zFilename){ +static void *winConvertFromUtf8Filename(const char *zFilename){ void *zConverted = 0; if( osIsNT() ){ zConverted = winUtf8ToUnicode(zFilename); @@ -3980,7 +3999,90 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ winEndsInDirSep(sqlite3_temp_directory) ? "" : winGetDirDep()); } -#if !SQLITE_OS_WINRT +#if defined(__CYGWIN__) + else{ + static const char *azDirs[] = { + 0, /* getenv("SQLITE_TMPDIR") */ + 0, /* getenv("TMPDIR") */ + 0, /* getenv("TMP") */ + 0, /* getenv("TEMP") */ + 0, /* getenv("USERPROFILE") */ + "/var/tmp", + "/usr/tmp", + "/tmp", + 0 /* List terminator */ + }; + unsigned int i; + const char *zDir = 0; + + if( !azDirs[0] ) azDirs[0] = getenv("SQLITE_TMPDIR"); + if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR"); + if( !azDirs[2] ) azDirs[2] = getenv("TMP"); + if( !azDirs[3] ) azDirs[3] = getenv("TEMP"); + if( !azDirs[4] ) azDirs[4] = getenv("USERPROFILE"); + for(i=0; imxPathname+1)<0 ){ - winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path", + winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, "winFullPathname", zRelative); sqlite3_free(zOut); - return SQLITE_CANTOPEN_FULLPATH; + return SQLITE_CANTOPEN_CONVPATH; } sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", sqlite3_data_directory, winGetDirDep(), zOut); sqlite3_free(zOut); }else{ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ - winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path", + winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, "winFullPathname", zRelative); - return SQLITE_CANTOPEN_FULLPATH; + return SQLITE_CANTOPEN_CONVPATH; } } return SQLITE_OK; @@ -4700,7 +4815,7 @@ static int winFullPathname( sqlite3_data_directory, winGetDirDep(), zRelative); return SQLITE_OK; } - zConverted = winConvertUtf8Filename(zRelative); + zConverted = winConvertFromUtf8Filename(zRelative); if( zConverted==0 ){ return SQLITE_IOERR_NOMEM; } @@ -4781,7 +4896,7 @@ static int winFullPathname( */ static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){ HANDLE h; - void *zConverted = winConvertUtf8Filename(zFilename); + void *zConverted = winConvertFromUtf8Filename(zFilename); UNUSED_PARAMETER(pVfs); if( zConverted==0 ){ return 0; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index fc76029bcb..1e5a3f22a4 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -474,12 +474,14 @@ int sqlite3_exec( #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8)) #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8)) +#define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8)) #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) +#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8)) #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) From 9f11ef12320a9f8417d4cd0846b11c32051faaf4 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 31 Aug 2013 02:48:56 +0000 Subject: [PATCH 2/6] Improve the consistency of the diagnostic messages on Windows. FossilOrigin-Name: c6f174a0cb27fe79740fffc7ce51081ec52a5dbd --- manifest | 15 +++---- manifest.uuid | 2 +- src/os_win.c | 112 +++++++++++++++++++++++--------------------------- 3 files changed, 58 insertions(+), 71 deletions(-) diff --git a/manifest b/manifest index 40a9efb0be..4c92aed8c7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\sCygwin\swhen\shandling\stemporary\sfile\snames.\s\sImprove\serror\scodes\sand\sdiagnostic\smessages\sfor\stemporary\sfile\sname\shandling\son\sWindows.\s\sRename\swinConvertUtf8Filename\sto\swinConvertFromUtf8Filename.\s\sImprove\splacement\sand\scomments\sfor\sforward\sfunction\sdeclarations. -D 2013-08-30T21:52:38.235 +C Improve\sthe\sconsistency\sof\sthe\sdiagnostic\smessages\son\sWindows. +D 2013-08-31T02:48:56.122 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 243fb37f47dc072fc59839ea241ff0a17c8d76e6 -F src/os_win.c 8e87c2718975bc3cd8d86bf3ff2cc3bbafbc7eaf +F src/os_win.c 27ab5a2236e0649bcaa246b5ce80b7289ab31688 F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f @@ -1109,10 +1109,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 5bbd2ccb3d2d6286fd667dac2ab658d6b89640a6 -R 72dd46cadd0f990a967d544f6edf59de -T *branch * cygwinTempPath -T *sym-cygwinTempPath * -T -sym-trunk * +P a411df725153119acb3bcf44fb71deecaa307887 +R bb11e3b1e087c83913695ae6bba44408 U mistachkin -Z 23133362076223f26c27390373169480 +Z b8d9459ebc748b157e98d4dbf0b6c355 diff --git a/manifest.uuid b/manifest.uuid index 44a442d40d..1b8e732303 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a411df725153119acb3bcf44fb71deecaa307887 \ No newline at end of file +c6f174a0cb27fe79740fffc7ce51081ec52a5dbd \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index ab33b52a47..81265a070e 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1761,10 +1761,9 @@ static int winceCreateLock(const char *zFilename, winFile *pFile){ pFile->hMutex = osCreateMutexW(NULL, FALSE, zName); if (!pFile->hMutex){ pFile->lastErrno = osGetLastError(); - winLogError(SQLITE_IOERR, pFile->lastErrno, - "winceCreateLock1", zFilename); sqlite3_free(zName); - return SQLITE_IOERR; + return winLogError(SQLITE_IOERR, pFile->lastErrno, + "winceCreateLock1", zFilename); } /* Acquire the mutex before continuing */ @@ -2100,7 +2099,7 @@ static int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){ && ((lastErrno = osGetLastError())!=NO_ERROR)) ){ pFile->lastErrno = lastErrno; winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno, - "winSeekFile", pFile->zPath); + "winSeekFile", pFile->zPath); OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h)); return 1; } @@ -2121,7 +2120,7 @@ static int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){ if(!bRet){ pFile->lastErrno = osGetLastError(); winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno, - "winSeekFile", pFile->zPath); + "winSeekFile", pFile->zPath); OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h)); return 1; } @@ -2254,7 +2253,7 @@ static int winRead( pFile->lastErrno = lastErrno; OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h)); return winLogError(SQLITE_IOERR_READ, pFile->lastErrno, - "winRead", pFile->zPath); + "winRead", pFile->zPath); } winLogIoerr(nRetry); if( nRead<(DWORD)amt ){ @@ -2360,11 +2359,12 @@ static int winWrite( if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL ) || ( pFile->lastErrno==ERROR_DISK_FULL )){ OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h)); - return SQLITE_FULL; + return winLogError(SQLITE_FULL, pFile->lastErrno, + "winWrite1", pFile->zPath); } OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h)); return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno, - "winWrite", pFile->zPath); + "winWrite2", pFile->zPath); }else{ winLogIoerr(nRetry); } @@ -2488,7 +2488,7 @@ static int winSync(sqlite3_file *id, int flags){ pFile->lastErrno = osGetLastError(); OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h)); return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno, - "winSync", pFile->zPath); + "winSync", pFile->zPath); } #endif } @@ -2529,7 +2529,7 @@ static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){ && ((lastErrno = osGetLastError())!=NO_ERROR) ){ pFile->lastErrno = lastErrno; rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno, - "winFileSize", pFile->zPath); + "winFileSize", pFile->zPath); } } #endif @@ -2624,7 +2624,7 @@ static int winUnlockReadLock(winFile *pFile){ if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){ pFile->lastErrno = lastErrno; winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno, - "winUnlockReadLock", pFile->zPath); + "winUnlockReadLock", pFile->zPath); } OSTRACE(("READ-UNLOCK file=%p, rc=%s\n", pFile->h, sqlite3ErrName(res))); return res; @@ -2837,7 +2837,7 @@ static int winUnlock(sqlite3_file *id, int locktype){ /* This should never happen. We should always be able to ** reacquire the read lock */ rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(), - "winUnlock", pFile->zPath); + "winUnlock", pFile->zPath); } } if( type>=RESERVED_LOCK ){ @@ -2952,7 +2952,7 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){ if( rc==SQLITE_OK ){ *(char**)pArg = zTFile; } - OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc)); + OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc))); return rc; } #if SQLITE_MAX_MMAP_SIZE>0 @@ -2970,7 +2970,7 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){ rc = winMapfile(pFile, -1); } } - OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc)); + OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc))); return rc; } #endif @@ -3286,7 +3286,7 @@ static int winOpenSharedMemory(winFile *pDbFd){ rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0); if( rc!=SQLITE_OK ){ rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(), - "winOpenShm", pDbFd->zPath); + "winOpenShm", pDbFd->zPath); } } if( rc==SQLITE_OK ){ @@ -3546,7 +3546,7 @@ static int winShmMap( rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz); if( rc!=SQLITE_OK ){ rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(), - "winShmMap1", pDbFd->zPath); + "winShmMap1", pDbFd->zPath); goto shmpage_out; } @@ -3561,7 +3561,7 @@ static int winShmMap( rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte); if( rc!=SQLITE_OK ){ rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(), - "winShmMap2", pDbFd->zPath); + "winShmMap2", pDbFd->zPath); goto shmpage_out; } } @@ -3615,7 +3615,7 @@ static int winShmMap( if( !pMap ){ pShmNode->lastErrno = osGetLastError(); rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno, - "winShmMap3", pDbFd->zPath); + "winShmMap3", pDbFd->zPath); if( hMap ) osCloseHandle(hMap); goto shmpage_out; } @@ -3663,7 +3663,7 @@ static int winUnmapfile(winFile *pFile){ "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), pFile, pFile->pMapRegion)); return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno, - "winUnmap1", pFile->zPath); + "winUnmapfile1", pFile->zPath); } pFile->pMapRegion = 0; pFile->mmapSize = 0; @@ -3675,7 +3675,7 @@ static int winUnmapfile(winFile *pFile){ OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), pFile, pFile->hMap)); return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno, - "winUnmap2", pFile->zPath); + "winUnmapfile2", pFile->zPath); } pFile->hMap = NULL; } @@ -3750,10 +3750,10 @@ static int winMapfile(winFile *pFd, sqlite3_int64 nByte){ if( pFd->hMap==NULL ){ pFd->lastErrno = osGetLastError(); rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno, - "winMapfile", pFd->zPath); + "winMapfile1", pFd->zPath); /* Log the error, but continue normal operation using xRead/xWrite */ - OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n", - osGetCurrentProcessId(), pFd)); + OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=%s\n", + osGetCurrentProcessId(), pFd, sqlite3ErrName(rc))); return SQLITE_OK; } assert( (nMap % winSysInfo.dwPageSize)==0 ); @@ -3767,10 +3767,11 @@ static int winMapfile(winFile *pFd, sqlite3_int64 nByte){ osCloseHandle(pFd->hMap); pFd->hMap = NULL; pFd->lastErrno = osGetLastError(); - winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno, - "winMapfile", pFd->zPath); - OSTRACE(("MAP-FILE-MAP pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n", - osGetCurrentProcessId(), pFd)); + rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno, + "winMapfile2", pFd->zPath); + /* Log the error, but continue normal operation using xRead/xWrite */ + OSTRACE(("MAP-FILE-MAP pid=%lu, pFile=%p, rc=%s\n", + osGetCurrentProcessId(), pFd, sqlite3ErrName(rc))); return SQLITE_OK; } pFd->pMapRegion = pNew; @@ -4050,10 +4051,9 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir, zConverted, nBuf+1)<0 ){ sqlite3_free(zConverted); - winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno, - "cygwin_conv_path", zDir); OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\n")); - return SQLITE_IOERR_CONVPATH; + return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno, + "winGetTempname1", zDir); } if( winIsDir(zConverted) ){ /* At this point, we know the candidate directory exists and should @@ -4094,10 +4094,9 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ if( osGetTempPathW(nBuf, zWidePath)==0 ){ sqlite3_free(zWidePath); sqlite3_free(zBuf); - winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(), - "winGetTempname", 0); OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n")); - return SQLITE_IOERR_GETTEMPPATH; + return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(), + "winGetTempname1", 0); } zMulti = winUnicodeToUtf8(zWidePath); if( zMulti ){ @@ -4122,10 +4121,9 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ } if( osGetTempPathA(nBuf, zMbcsPath)==0 ){ sqlite3_free(zBuf); - winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(), - "winGetTempname", 0); OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n")); - return SQLITE_IOERR_GETTEMPPATH; + return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(), + "winGetTempname2", 0); } zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); if( zUtf8 ){ @@ -4148,7 +4146,7 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ if( (nLen + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){ sqlite3_free(zBuf); OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n")); - return SQLITE_ERROR; + return winLogError(SQLITE_ERROR, 0, "winGetTempname3", 0); } sqlite3_snprintf(nBuf-18-nLen, zBuf+nLen, SQLITE_TEMP_FILE_PREFIX); @@ -4585,8 +4583,7 @@ static int winDelete( } #endif if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){ - rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, - "winDelete", zFilename); + rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename); }else{ winLogIoerr(cnt); } @@ -4640,9 +4637,9 @@ static int winAccess( }else{ winLogIoerr(cnt); if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){ - winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess", zFilename); sqlite3_free(zConverted); - return SQLITE_IOERR_ACCESS; + return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess", + zFilename); }else{ attr = INVALID_FILE_ATTRIBUTES; } @@ -4744,24 +4741,21 @@ static int winFullPathname( */ char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 ); if( !zOut ){ - winLogError(SQLITE_IOERR_NOMEM, 0, "winFullPathname", zRelative); return SQLITE_IOERR_NOMEM; } if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut, pVfs->mxPathname+1)<0 ){ - winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, "winFullPathname", - zRelative); sqlite3_free(zOut); - return SQLITE_CANTOPEN_CONVPATH; + 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_free(zOut); }else{ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ - winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, "winFullPathname", - zRelative); - return SQLITE_CANTOPEN_CONVPATH; + return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, + "winFullPathname2", zRelative); } } return SQLITE_OK; @@ -4794,7 +4788,7 @@ static int winFullPathname( /* If this path name begins with "/X:", where "X" is any alphabetic ** character, discard the initial "/" from the pathname. */ - if( zRelative[0]=='/' && sqlite3Isalpha(zRelative[1]) && zRelative[2]==':' ){ + if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){ zRelative++; } @@ -4823,10 +4817,9 @@ static int winFullPathname( LPWSTR zTemp; nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0); if( nByte==0 ){ - winLogError(SQLITE_ERROR, osGetLastError(), - "GetFullPathNameW1", zConverted); sqlite3_free(zConverted); - return SQLITE_CANTOPEN_FULLPATH; + return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(), + "winFullPathname1", zRelative); } nByte += 3; zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) ); @@ -4836,11 +4829,10 @@ static int winFullPathname( } nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0); if( nByte==0 ){ - winLogError(SQLITE_ERROR, osGetLastError(), - "GetFullPathNameW2", zConverted); sqlite3_free(zConverted); sqlite3_free(zTemp); - return SQLITE_CANTOPEN_FULLPATH; + return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(), + "winFullPathname2", zRelative); } sqlite3_free(zConverted); zOut = winUnicodeToUtf8(zTemp); @@ -4851,10 +4843,9 @@ static int winFullPathname( char *zTemp; nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0); if( nByte==0 ){ - winLogError(SQLITE_ERROR, osGetLastError(), - "GetFullPathNameA1", zConverted); sqlite3_free(zConverted); - return SQLITE_CANTOPEN_FULLPATH; + return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(), + "winFullPathname3", zRelative); } nByte += 3; zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) ); @@ -4864,11 +4855,10 @@ static int winFullPathname( } nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0); if( nByte==0 ){ - winLogError(SQLITE_ERROR, osGetLastError(), - "GetFullPathNameA2", zConverted); sqlite3_free(zConverted); sqlite3_free(zTemp); - return SQLITE_CANTOPEN_FULLPATH; + return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(), + "winFullPathname4", zRelative); } sqlite3_free(zConverted); zOut = sqlite3_win32_mbcs_to_utf8(zTemp); From 3fb4b6df07f7ce12bed39aef31590d06d251e2db Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 31 Aug 2013 05:13:22 +0000 Subject: [PATCH 3/6] Fix harmless MSVC compiler warning with MEMDEBUG defined. FossilOrigin-Name: b48cfd2dfca70091a52deeeee16619237e1c270b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/mem2.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4c92aed8c7..0c61c93cf6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sthe\sconsistency\sof\sthe\sdiagnostic\smessages\son\sWindows. -D 2013-08-31T02:48:56.122 +C Fix\sharmless\sMSVC\scompiler\swarning\swith\sMEMDEBUG\sdefined. +D 2013-08-31T05:13:22.387 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -189,7 +189,7 @@ F src/main.c c4c781b06faa2ce4040c32a75fd931a07ba7054e F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa -F src/mem2.c e243acb034f91e75e4c06aed5d3d960025c62d1f +F src/mem2.c dce31758da87ec2cfa52ba4c5df1aed6e07d8e8f F src/mem3.c 61c9d47b792908c532ca3a62b999cf21795c6534 F src/mem5.c 0025308a93838022bd5696cf9627ff4e40b19918 F src/memjournal.c 0683aac6cab6ec2b5374c0db37c0deb2436a3785 @@ -1109,7 +1109,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P a411df725153119acb3bcf44fb71deecaa307887 -R bb11e3b1e087c83913695ae6bba44408 +P c6f174a0cb27fe79740fffc7ce51081ec52a5dbd +R bb417a9280c6c7257f662f98515af4c7 U mistachkin -Z b8d9459ebc748b157e98d4dbf0b6c355 +Z ce71d33f787d820719edc5d9e21c8ccd diff --git a/manifest.uuid b/manifest.uuid index 1b8e732303..66324b2b9e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c6f174a0cb27fe79740fffc7ce51081ec52a5dbd \ No newline at end of file +b48cfd2dfca70091a52deeeee16619237e1c270b \ No newline at end of file diff --git a/src/mem2.c b/src/mem2.c index d461dffab1..99ea42517e 100644 --- a/src/mem2.c +++ b/src/mem2.c @@ -348,7 +348,7 @@ static void *sqlite3MemRealloc(void *pPrior, int nByte){ pOldHdr = sqlite3MemsysGetHeader(pPrior); pNew = sqlite3MemMalloc(nByte); if( pNew ){ - memcpy(pNew, pPrior, nByteiSize ? nByte : pOldHdr->iSize); + memcpy(pNew, pPrior, (int)(nByteiSize ? nByte : pOldHdr->iSize)); if( nByte>pOldHdr->iSize ){ randomFill(&((char*)pNew)[pOldHdr->iSize], nByte - (int)pOldHdr->iSize); } From 2a43c28f0678bbf98a802c2e93b41156ad8fbd22 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 31 Aug 2013 05:46:42 +0000 Subject: [PATCH 4/6] Avoid commenting out #include statements when building the amalgamation source code file. FossilOrigin-Name: 2fca6d784b000fd3a4d6890e38a0b087767f3a7f --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/mksqlite3c.tcl | 13 +++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 0c61c93cf6..2863afe545 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\sMSVC\scompiler\swarning\swith\sMEMDEBUG\sdefined. -D 2013-08-31T05:13:22.387 +C Avoid\scommenting\sout\s#include\sstatements\swhen\sbuilding\sthe\samalgamation\ssource\scode\sfile. +D 2013-08-31T05:46:42.494 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1079,7 +1079,7 @@ F tool/mkkeywordhash.c bb52064aa614e1426445e4b2b9b00eeecd23cc79 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 -F tool/mksqlite3c.tcl a61fe62a2895ca6458c463fccf1211ca1c000fcf +F tool/mksqlite3c.tcl d8d51141424a0227aecfd7bd07a92304a946b8b2 F tool/mksqlite3h.tcl ba24038056f51fde07c0079c41885ab85e2cff12 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 F tool/mkvsix.tcl 0be7f7a591f1e83f9199cb82911b66668ca484c9 @@ -1109,7 +1109,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P c6f174a0cb27fe79740fffc7ce51081ec52a5dbd -R bb417a9280c6c7257f662f98515af4c7 +P b48cfd2dfca70091a52deeeee16619237e1c270b +R b57559fe8be860201c533ce843be8c05 U mistachkin -Z ce71d33f787d820719edc5d9e21c8ccd +Z 5c7a5afeef353865f26e419014385170 diff --git a/manifest.uuid b/manifest.uuid index 66324b2b9e..895cd83cdf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b48cfd2dfca70091a52deeeee16619237e1c270b \ No newline at end of file +2fca6d784b000fd3a4d6890e38a0b087767f3a7f \ No newline at end of file diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index c93bcea44d..8826f25b77 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -137,10 +137,10 @@ proc section_comment {text} { # Read the source file named $filename and write it into the # sqlite3.c output file. If any #include statements are seen, -# process them approprately. +# process them appropriately. # proc copy_file {filename} { - global seen_hdr available_hdr out addstatic linemacros + global available_hdr out addstatic linemacros set ln 0 set tail [file tail $filename] section_comment "Begin file $tail" @@ -166,11 +166,12 @@ proc copy_file {filename} { section_comment "Continuing where we left off in $tail" if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""} } - } elseif {![info exists seen_hdr($hdr)]} { - set seen_hdr($hdr) 1 - puts $out $line } else { - puts $out "/* $line */" + set suffix [string toupper [string map [list / _ . _] $hdr]] + puts $out "#ifndef SQLITE_HEADER_$suffix" + puts $out "#define SQLITE_HEADER_$suffix" + puts $out $line + puts $out "#endif" } } elseif {[regexp {^#ifdef __cplusplus} $line]} { puts $out "#if 0" From 28159a5ee99e55a0f10fb8497a5122112d893222 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 31 Aug 2013 17:01:56 +0000 Subject: [PATCH 5/6] Enhancements to the Win32 API definition macros. FossilOrigin-Name: b1811baab6e35ecb1ba920a7ed3302997758d309 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2863afe545..c62353483b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\scommenting\sout\s#include\sstatements\swhen\sbuilding\sthe\samalgamation\ssource\scode\sfile. -D 2013-08-31T05:46:42.494 +C Enhancements\sto\sthe\sWin32\sAPI\sdefinition\smacros. +D 2013-08-31T17:01:56.739 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 243fb37f47dc072fc59839ea241ff0a17c8d76e6 -F src/os_win.c 27ab5a2236e0649bcaa246b5ce80b7289ab31688 +F src/os_win.c 896581ee5a2ad261c3410fc84cfb0639ef2a1d56 F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f @@ -1109,7 +1109,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P b48cfd2dfca70091a52deeeee16619237e1c270b -R b57559fe8be860201c533ce843be8c05 +P 2fca6d784b000fd3a4d6890e38a0b087767f3a7f +R 81d5e6e46adbe46f943b02ea53b00aff U mistachkin -Z 5c7a5afeef353865f26e419014385170 +Z 8550f042a6eaddfa936a0e87c6856786 diff --git a/manifest.uuid b/manifest.uuid index 895cd83cdf..64c97df68b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2fca6d784b000fd3a4d6890e38a0b087767f3a7f \ No newline at end of file +b1811baab6e35ecb1ba920a7ed3302997758d309 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 81265a070e..34b5834eb8 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -38,7 +38,7 @@ ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions ** based on the sub-platform)? */ -#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(SQLITE_WIN32_NO_ANSI) # define SQLITE_WIN32_HAS_ANSI #endif @@ -46,10 +46,19 @@ ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions ** based on the sub-platform)? */ -#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT +#if (SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT) && \ + !defined(SQLITE_WIN32_NO_WIDE) # define SQLITE_WIN32_HAS_WIDE #endif +/* +** Make sure at least one set of Win32 APIs is available. +*/ +#if !defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_WIN32_HAS_WIDE) +# error "At least one of SQLITE_WIN32_HAS_ANSI and SQLITE_WIN32_HAS_WIDE\ + must be defined." +#endif + /* ** Maximum pathname length (in chars) for Win32. This should normally be ** MAX_PATH. @@ -1116,7 +1125,7 @@ void sqlite3_win32_sleep(DWORD milliseconds){ ** WinNT/2K/XP so that we will know whether or not we can safely call ** the LockFileEx() API. */ -#if SQLITE_OS_WINCE || SQLITE_OS_WINRT +#if SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI) # define osIsNT() (1) #elif !defined(SQLITE_WIN32_HAS_WIDE) # define osIsNT() (0) From 1a88b14e5d17ba55a5cdcccf0839e30b4a6463a0 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 31 Aug 2013 18:06:52 +0000 Subject: [PATCH 6/6] Revise the amalgamation tool to allow 'duplicate' include files to be retained manually while still preserving the existing line numbers. FossilOrigin-Name: aa48284637b954d63bcf77e19b25e75c7ad1a6d3 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 3 ++- tool/mksqlite3c.tcl | 17 +++++++++++------ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index c62353483b..8d15520f4c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhancements\sto\sthe\sWin32\sAPI\sdefinition\smacros. -D 2013-08-31T17:01:56.739 +C Revise\sthe\samalgamation\stool\sto\sallow\s'duplicate'\sinclude\sfiles\sto\sbe\sretained\smanually\swhile\sstill\spreserving\sthe\sexisting\sline\snumbers. +D 2013-08-31T18:06:52.923 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 243fb37f47dc072fc59839ea241ff0a17c8d76e6 -F src/os_win.c 896581ee5a2ad261c3410fc84cfb0639ef2a1d56 +F src/os_win.c bb592dfb850e4ee3e4caecce461dca74dc40936d F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f @@ -1079,7 +1079,7 @@ F tool/mkkeywordhash.c bb52064aa614e1426445e4b2b9b00eeecd23cc79 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 -F tool/mksqlite3c.tcl d8d51141424a0227aecfd7bd07a92304a946b8b2 +F tool/mksqlite3c.tcl d344cc3144a0271cd853c5e3df36e9f31d78d619 F tool/mksqlite3h.tcl ba24038056f51fde07c0079c41885ab85e2cff12 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 F tool/mkvsix.tcl 0be7f7a591f1e83f9199cb82911b66668ca484c9 @@ -1109,7 +1109,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 2fca6d784b000fd3a4d6890e38a0b087767f3a7f -R 81d5e6e46adbe46f943b02ea53b00aff +P b1811baab6e35ecb1ba920a7ed3302997758d309 +R c09e9aaa82ece462d9ada3bc7aee07de U mistachkin -Z 8550f042a6eaddfa936a0e87c6856786 +Z 9761d739f96263a417653d62e6565ea2 diff --git a/manifest.uuid b/manifest.uuid index 64c97df68b..f86d289b7d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b1811baab6e35ecb1ba920a7ed3302997758d309 \ No newline at end of file +aa48284637b954d63bcf77e19b25e75c7ad1a6d3 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 34b5834eb8..72d6e8ba5c 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -17,7 +17,7 @@ #ifdef __CYGWIN__ # include -# include +# include /* amalgamator: keep */ #endif /* @@ -4020,6 +4020,7 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ "/var/tmp", "/usr/tmp", "/tmp", + ".", 0 /* List terminator */ }; unsigned int i; diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index 8826f25b77..343f606cfe 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -140,7 +140,7 @@ proc section_comment {text} { # process them appropriately. # proc copy_file {filename} { - global available_hdr out addstatic linemacros + global seen_hdr available_hdr out addstatic linemacros set ln 0 set tail [file tail $filename] section_comment "Begin file $tail" @@ -166,12 +166,17 @@ proc copy_file {filename} { section_comment "Continuing where we left off in $tail" if {$linemacros} {puts $out "#line [expr {$ln+1}] \"$filename\""} } - } else { - set suffix [string toupper [string map [list / _ . _] $hdr]] - puts $out "#ifndef SQLITE_HEADER_$suffix" - puts $out "#define SQLITE_HEADER_$suffix" + } elseif {![info exists seen_hdr($hdr)]} { + set seen_hdr($hdr) 1 puts $out $line - puts $out "#endif" + } elseif {[regexp {/\*\s+amalgamator:\s+keep\s+\*/} $line]} { + # This include file must be kept because there was a "keep" + # directive inside of a line comment. + puts $out $line + } else { + # Comment out the entire line, replacing any nested comment + # begin/end markers with the harmless substring "**". + puts $out "/* [string map [list /* ** */ **] $line] */" } } elseif {[regexp {^#ifdef __cplusplus} $line]} { puts $out "#if 0"