1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Simplify the temporary filename generator and the time-of-day functions in

the unix VFS.

FossilOrigin-Name: 6c5621ce1b1a65913b088ed8be65f9b689260d2c
This commit is contained in:
drh
2015-11-25 23:13:14 +00:00
parent 489f1e86e3
commit 970942e4fc
3 changed files with 16 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
C Fix\sharmless\scompiler\swarnings\sin\stest_fs.c.\s\sFix\stypos\sand\sclean\sup\sthe\stext\nof\sthe\sdocumentation\sfor\ssqlite3_strglob()\sand\ssqlite3_strlike(). C Simplify\sthe\stemporary\sfilename\sgenerator\sand\sthe\stime-of-day\sfunctions\sin\nthe\sunix\sVFS.
D 2015-11-25T18:40:38.741 D 2015-11-25T23:13:14.833
F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1 F Makefile.in d828db6afa6c1fa060d01e33e4674408df1942a1
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc e928e68168df69b353300ac87c10105206653a03 F Makefile.msc e928e68168df69b353300ac87c10105206653a03
@@ -323,7 +323,7 @@ F src/os.c 8fd25588eeba74068d41102d26810e216999b6c8
F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf F src/os.h 3e57a24e2794a94d3cf2342c6d9a884888cd96bf
F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e F src/os_common.h abdb9a191a367793268fe553d25bab894e986a0e
F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
F src/os_unix.c 066d6f8e4ea9c9b82e93eef2daee3cf25759fa36 F src/os_unix.c 3f22d7f2577b963261e9ef3b177b10a3083ed518
F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811 F src/os_win.c 386fba30419e8458b13209781c2af5590eab2811
F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e F src/pager.c 18341e2b759b447cbc82fb9215d08d9c5864e92e
@@ -1405,7 +1405,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 6ef6578c03b7cfbeaaf3627b9eea2febf501ace5 P 697b20534c2d780cdd8cc165d2930f6e56480770
R 6a7e3073277459e34ef3bc33d986fb8e R 8a05f9924f5556e21d4d47be27f99435
U drh U drh
Z 86f0abe6c80c8309344887b29ae04a0c Z fea2e37220480a85fb0635b776213ee8

View File

@@ -1 +1 @@
697b20534c2d780cdd8cc165d2930f6e56480770 6c5621ce1b1a65913b088ed8be65f9b689260d2c

View File

@@ -5424,11 +5424,6 @@ static const char *unixTempFileDir(void){
** pVfs->mxPathname bytes. ** pVfs->mxPathname bytes.
*/ */
static int unixGetTempname(int nBuf, char *zBuf){ static int unixGetTempname(int nBuf, char *zBuf){
static const unsigned char zChars[] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";
unsigned int i, j;
const char *zDir; const char *zDir;
/* It's odd to simulate an io-error here, but really this is just /* It's odd to simulate an io-error here, but really this is just
@@ -5439,23 +5434,14 @@ static int unixGetTempname(int nBuf, char *zBuf){
zDir = unixTempFileDir(); zDir = unixTempFileDir();
if( zDir==0 ) zDir = "."; if( zDir==0 ) zDir = ".";
/* Check that the output buffer is large enough for the temporary file
** name. If it is not, return SQLITE_ERROR.
*/
if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
return SQLITE_ERROR;
}
do{ do{
sqlite3_snprintf(nBuf-18, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX, zDir); u64 r;
j = (int)strlen(zBuf); sqlite3_randomness(sizeof(r), &r);
sqlite3_randomness(15, &zBuf[j]); assert( nBuf>2 );
for(i=0; i<15; i++, j++){ zBuf[nBuf-2] = 0;
zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; sqlite3_snprintf(nBuf, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX"%llx%c",
} zDir, r, 0);
zBuf[j] = 0; if( zBuf[nBuf-2]!=0 ) return SQLITE_ERROR;
zBuf[j+1] = 0;
}while( osAccess(zBuf,0)==0 ); }while( osAccess(zBuf,0)==0 );
return SQLITE_OK; return SQLITE_OK;
} }
@@ -6200,11 +6186,8 @@ static int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){
*piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_nsec/1000000; *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_nsec/1000000;
#else #else
struct timeval sNow; struct timeval sNow;
if( gettimeofday(&sNow, 0)==0 ){ (void)gettimeofday(&sNow, 0); /* Cannot fail given valid arguments */
*piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000; *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000;
}else{
rc = SQLITE_ERROR;
}
#endif #endif
#ifdef SQLITE_TEST #ifdef SQLITE_TEST