Progress toward getting things to work better on windows.

FossilOrigin-Name: 253dd7072ef7f4e8742e5b6430658f8e5102e0bb
This commit is contained in:
drh 2011-12-01 22:07:22 +00:00
parent a76e858917
commit c8ccda6076
5 changed files with 121 additions and 25 deletions

View File

@ -1,5 +1,5 @@
C Add\stest\slogic\sand\ssome\stest\scases.
D 2011-12-01T20:48:15.803
C Progress\stoward\sgetting\sthings\sto\swork\sbetter\son\swindows.
D 2011-12-01T22:07:22.034
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -220,7 +220,7 @@ F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e
F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec
F src/test_osinst.c 62b0b8ef21ce754cc94e17bb42377ed8795dba32
F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00
F src/test_quota.c ed68398661b398f0ce213349eb1cac6b5c39f62e
F src/test_quota.c 38c23c0fcbc92e0f8fe6fc0a76e66680cdb1b5cb
F src/test_quota.h 118dba604ae5b6903acdd40d2b94a1f319047612
F src/test_rtree.c 6d06306e29946dc36f528a3a2cdc3add794656f1
F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
@ -634,8 +634,9 @@ F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
F test/quick.test 1681febc928d686362d50057c642f77a02c62e57
F test/quota-glob.test bb88e8da2f24f7f8413492967beb35d3222f52a4
F test/quota.test 46e6571b45c3c58ac131cc38f7d600aa9f75974d
F test/quota2.test 1372a399adcecc423396f51faec5de44ae236019
F test/quota2.test 87b9c7a63e458706e528c661efa3955abc540fc5
F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459
F test/randexpr1.test 1084050991e9ba22c1c10edd8d84673b501cc25a
@ -978,7 +979,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P bd3ce723f1b5be52be46ede8614ca316f56e7e6f
R 137abcb878bf12767e2fb107dd20a728
P a4730586cc1f686ead956ccd1cc218b5931942c9
R 2e2d8adc5259d2440bcb724fb4357d2b
U drh
Z 363de760bad75051e8a4f47a97fcd11d
Z 0c07da994a8e7e81f42215da8ed506cb

View File

@ -1 +1 @@
a4730586cc1f686ead956ccd1cc218b5931942c9
253dd7072ef7f4e8742e5b6430658f8e5102e0bb

View File

@ -241,7 +241,7 @@ static void quotaGroupDeref(quotaGroup *pGroup){
**
*/
static int quotaStrglob(const char *zGlob, const char *z){
int c, c2;
int c, c2, cx;
int invert;
int seen;
@ -258,8 +258,9 @@ static int quotaStrglob(const char *zGlob, const char *z){
}
return (*z)!=0;
}
cx = (c=='/') ? '\\' : c;
while( (c2 = (*(z++)))!=0 ){
while( c2!=c ){
while( c2!=c && c2!=cx ){
c2 = *(z++);
if( c2==0 ) return 0;
}
@ -423,7 +424,7 @@ static char *quota_utf8_to_mbcs(const char *zUtf8){
*/
static void quota_mbcs_free(char *zOld){
#if SQLITE_OS_WIN
free(zOld);
sqlite3_free(zOld);
#else
/* No-op on unix */
#endif
@ -1004,7 +1005,7 @@ size_t sqlite3_quota_fwrite(
iOfst = ftell(p->f);
iEnd = iOfst + size*nmemb;
pFile = p->pFile;
if( pFile->iSize<iEnd ){
if( pFile && pFile->iSize<iEnd ){
quotaGroup *pGroup = pFile->pGroup;
quotaEnter();
szNew = pGroup->iSize - pFile->iSize + iEnd;
@ -1035,14 +1036,16 @@ int sqlite3_quota_fclose(quota_FILE *p){
quotaFile *pFile;
rc = fclose(p->f);
pFile = p->pFile;
quotaEnter();
pFile->nRef--;
if( pFile->nRef==0 ){
quotaGroup *pGroup = pFile->pGroup;
if( pFile->deleteOnClose ) quotaRemoveFile(pFile);
quotaGroupDeref(pGroup);
if( pFile ){
quotaEnter();
pFile->nRef--;
if( pFile->nRef==0 ){
quotaGroup *pGroup = pFile->pGroup;
if( pFile->deleteOnClose ) quotaRemoveFile(pFile);
quotaGroupDeref(pGroup);
}
quotaLeave();
}
quotaLeave();
sqlite3_free(p);
return rc;
}
@ -1305,9 +1308,13 @@ static int test_quota_dump(
Tcl_ListObjAppendElement(interp, pGroupTerm,
Tcl_NewWideIntObj(pGroup->iSize));
for(pFile=pGroup->pFiles; pFile; pFile=pFile->pNext){
int i;
char zTemp[1000];
pFileTerm = Tcl_NewObj();
sqlite3_snprintf(sizeof(zTemp), zTemp, "%s", pFile->zFilename);
for(i=0; zTemp[i]; i++){ if( zTemp[i]=='\\' ) zTemp[i] = '/'; }
Tcl_ListObjAppendElement(interp, pFileTerm,
Tcl_NewStringObj(pFile->zFilename, -1));
Tcl_NewStringObj(zTemp, -1));
Tcl_ListObjAppendElement(interp, pFileTerm,
Tcl_NewWideIntObj(pFile->iSize));
Tcl_ListObjAppendElement(interp, pFileTerm,
@ -1537,6 +1544,32 @@ static int test_quota_remove(
return TCL_OK;
}
/*
** tclcmd: sqlite3_quota_glob PATTERN TEXT
**
** Test the glob pattern matching. Return 1 if TEXT matches PATTERN
** and return 0 if it does not.
*/
static int test_quota_glob(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
const char *zPattern; /* The glob pattern */
const char *zText; /* Text to compare agains the pattern */
int rc;
if( objc!=3 ){
Tcl_WrongNumArgs(interp, 1, objv, "PATTERN TEXT");
return TCL_ERROR;
}
zPattern = Tcl_GetString(objv[1]);
zText = Tcl_GetString(objv[2]);
rc = quotaStrglob(zPattern, zText);
Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
return TCL_OK;
}
/*
** This routine registers the custom TCL commands defined in this
** module. This should be the only procedure visible from outside
@ -1560,6 +1593,7 @@ int Sqlitequota_Init(Tcl_Interp *interp){
{ "sqlite3_quota_rewind", test_quota_rewind },
{ "sqlite3_quota_ftell", test_quota_ftell },
{ "sqlite3_quota_remove", test_quota_remove },
{ "sqlite3_quota_glob", test_quota_glob },
};
int i;

50
test/quota-glob.test Normal file
View File

@ -0,0 +1,50 @@
# 2011 December 1
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# Tests for the glob-style string compare operator embedded in the
# quota shim.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
catch { unset testnum }
catch { unset pattern }
catch { unset text }
catch { unset ans }
foreach {testnum pattern text ans} {
1 abcdefg abcdefg 1
2 abcdefG abcdefg 0
3 abcdef abcdefg 0
4 abcdefgh abcdefg 0
5 abcdef? abcdefg 1
6 abcdef? abcdef 0
7 abcdef? abcdefgh 0
8 abcdefg abcdef? 0
9 abcdef? abcdef? 1
10 abc/def abc/def 1
11 abc/def abc\\def 1
12 */abc/* x/abc/y 1
13 */abc/* /abc/ 1
16 */abc/* x///a/ab/abc 0
17 */abc/* x//a/ab/abc/ 1
16 */abc/* x///a/ab/abc 0
17 */abc/* x//a/ab/abc/ 1
} {
do_test quota-glob-$testnum.1 {
sqlite3_quota_glob $::pattern $::text
} $::ans
do_test quota-glob-$testnum.2 {
sqlite3_quota_glob $::pattern [string map {/ \\} $::text]
} $::ans
}
finish_test

View File

@ -22,6 +22,17 @@ file delete -force quota2b
file mkdir quota2a
file mkdir quota2b
# The standard_path procedure converts a pathname into a standard format
# that is the same across platforms.
#
unset -nocomplain ::quota_pwd ::quota_mapping
set ::quota_pwd [string map {\\ /} [pwd]]
set ::quota_mapping [list $::quota_pwd PWD]
proc standard_path {x} {
set x [string map {\\ /} $x]
return [string map $::quota_mapping $x]
}
# The quota_check procedure is a callback from the quota handler.
# It has three arguments which are (1) the full pathname of the file
# that has gone over quota, (2) the quota limit, (3) the requested
@ -35,10 +46,10 @@ file mkdir quota2b
#
set ::quota {}
set ::quota_request_ok 0
proc quota_check {filename limitvar size} {
upvar $limitvar limit
set filename [string map [list [pwd] PWD \\ /] $filename]
lappend ::quota $filename [set limit] $size
lappend ::quota [standard_path $filename] [set limit] $size
if {$::quota_request_ok} {set limit $size}
}
@ -96,15 +107,15 @@ do_test quota2-1.10 {
sqlite3_quota_ftell $::h1
} {0}
do_test quota2-1.11 {
string map [list [pwd] PWD \\ /] [sqlite3_quota_dump]
standard_path [sqlite3_quota_dump]
} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 4000 {PWD/quota2a/xyz.txt 4000 1 0}}}
do_test quota1-1.12 {
sqlite3_quota_fclose $::h1
string map [list [pwd] PWD \\ /] [sqlite3_quota_dump]
standard_path [sqlite3_quota_dump]
} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 4000 {PWD/quota2a/xyz.txt 4000 0 0}}}
do_test quota1-1.13 {
sqlite3_quota_remove quota2a/xyz.txt
string map [list [pwd] PWD \\ /] [sqlite3_quota_dump]
standard_path [sqlite3_quota_dump]
} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}