diff options
author | drh <drh@noemail.net> | 2015-10-29 13:48:15 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-10-29 13:48:15 +0000 |
commit | c56fac7483c195e4d309efc5e4459579fde2e77e (patch) | |
tree | db5e70540eacb42c8d7eea90a72f5637fb4bf4a8 | |
parent | de4148e304512686cac28013cb1cdccb1978918a (diff) | |
download | sqlite-c56fac7483c195e4d309efc5e4459579fde2e77e.tar.gz sqlite-c56fac7483c195e4d309efc5e4459579fde2e77e.zip |
Fix uses of ctype functions (ex: isspace()) on signed characters in test
programs and in some obscure extensions. No changes to the core.
FossilOrigin-Name: 34eb6911afee09e779318b79baf953f616200128
-rw-r--r-- | autoconf/tea/win/nmakehlp.c | 6 | ||||
-rw-r--r-- | ext/fts1/fts1.c | 6 | ||||
-rw-r--r-- | ext/fts1/simple_tokenizer.c | 2 | ||||
-rw-r--r-- | ext/misc/amatch.c | 4 | ||||
-rw-r--r-- | ext/misc/closure.c | 4 | ||||
-rw-r--r-- | ext/misc/spellfix.c | 2 | ||||
-rw-r--r-- | manifest | 46 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | mptest/mptest.c | 41 | ||||
-rw-r--r-- | test/fuzzcheck.c | 9 | ||||
-rw-r--r-- | test/speedtest1.c | 6 | ||||
-rw-r--r-- | test/wordcount.c | 5 | ||||
-rw-r--r-- | tool/fuzzershell.c | 3 | ||||
-rw-r--r-- | tool/lemon.c | 82 | ||||
-rw-r--r-- | tool/showdb.c | 12 | ||||
-rw-r--r-- | tool/showstat4.c | 4 | ||||
-rw-r--r-- | tool/showwal.c | 7 | ||||
-rw-r--r-- | tool/speedtest16.c | 4 | ||||
-rw-r--r-- | tool/speedtest8inst1.c | 4 |
19 files changed, 139 insertions, 110 deletions
diff --git a/autoconf/tea/win/nmakehlp.c b/autoconf/tea/win/nmakehlp.c index 2868857ef..e00f1b499 100644 --- a/autoconf/tea/win/nmakehlp.c +++ b/autoconf/tea/win/nmakehlp.c @@ -603,8 +603,8 @@ SubstituteFile( sp = fopen(substitutions, "rt"); if (sp != NULL) { while (fgets(szBuffer, cbBuffer, sp) != NULL) { - char *ks, *ke, *vs, *ve; - ks = szBuffer; + unsigned char *ks, *ke, *vs, *ve; + ks = (unsigned char*)szBuffer; while (ks && *ks && isspace(*ks)) ++ks; ke = ks; while (ke && *ke && !isspace(*ke)) ++ke; @@ -613,7 +613,7 @@ SubstituteFile( ve = vs; while (ve && *ve && !(*ve == '\r' || *ve == '\n')) ++ve; *ke = 0, *ve = 0; - list_insert(&substPtr, ks, vs); + list_insert(&substPtr, (char*)ks, (char*)vs); } fclose(sp); } diff --git a/ext/fts1/fts1.c b/ext/fts1/fts1.c index 482cf759b..77fa9e23f 100644 --- a/ext/fts1/fts1.c +++ b/ext/fts1/fts1.c @@ -205,13 +205,13 @@ static int getVarint32(const char *p, int *pi){ */ /* TODO(shess) Is __isascii() a portable version of (c&0x80)==0? */ static int safe_isspace(char c){ - return (c&0x80)==0 ? isspace(c) : 0; + return (c&0x80)==0 ? isspace((unsigned char)c) : 0; } static int safe_tolower(char c){ - return (c&0x80)==0 ? tolower(c) : c; + return (c&0x80)==0 ? tolower((unsigned char)c) : c; } static int safe_isalnum(char c){ - return (c&0x80)==0 ? isalnum(c) : 0; + return (c&0x80)==0 ? isalnum((unsigned char)c) : 0; } typedef enum DocListType { diff --git a/ext/fts1/simple_tokenizer.c b/ext/fts1/simple_tokenizer.c index d00a77089..0ddc7055a 100644 --- a/ext/fts1/simple_tokenizer.c +++ b/ext/fts1/simple_tokenizer.c @@ -138,7 +138,7 @@ static int simpleNext( ** case-insensitivity. */ char ch = c->pCurrent[ii]; - c->zToken[ii] = (unsigned char)ch<0x80 ? tolower(ch) : ch; + c->zToken[ii] = (unsigned char)ch<0x80 ? tolower((unsigned char)ch):ch; } c->zToken[n] = '\0'; *ppToken = c->zToken; diff --git a/ext/misc/amatch.c b/ext/misc/amatch.c index d08ef57aa..852491988 100644 --- a/ext/misc/amatch.c +++ b/ext/misc/amatch.c @@ -816,10 +816,10 @@ static const char *amatchValueOfKey(const char *zKey, const char *zStr){ int i; if( nStr<nKey+1 ) return 0; if( memcmp(zStr, zKey, nKey)!=0 ) return 0; - for(i=nKey; isspace(zStr[i]); i++){} + for(i=nKey; isspace((unsigned char)zStr[i]); i++){} if( zStr[i]!='=' ) return 0; i++; - while( isspace(zStr[i]) ){ i++; } + while( isspace((unsigned char)zStr[i]) ){ i++; } return zStr+i; } diff --git a/ext/misc/closure.c b/ext/misc/closure.c index 30c812d22..510c46ec9 100644 --- a/ext/misc/closure.c +++ b/ext/misc/closure.c @@ -486,10 +486,10 @@ static const char *closureValueOfKey(const char *zKey, const char *zStr){ int i; if( nStr<nKey+1 ) return 0; if( memcmp(zStr, zKey, nKey)!=0 ) return 0; - for(i=nKey; isspace(zStr[i]); i++){} + for(i=nKey; isspace((unsigned char)zStr[i]); i++){} if( zStr[i]!='=' ) return 0; i++; - while( isspace(zStr[i]) ){ i++; } + while( isspace((unsigned char)zStr[i]) ){ i++; } return zStr+i; } diff --git a/ext/misc/spellfix.c b/ext/misc/spellfix.c index 336203433..0515b7bc6 100644 --- a/ext/misc/spellfix.c +++ b/ext/misc/spellfix.c @@ -1851,7 +1851,7 @@ static char *spellfix1Dequote(const char *zIn){ char *zOut; int i, j; char c; - while( isspace(zIn[0]) ) zIn++; + while( isspace((unsigned char)zIn[0]) ) zIn++; zOut = sqlite3_mprintf("%s", zIn); if( zOut==0 ) return 0; i = (int)strlen(zOut); @@ -1,5 +1,5 @@ -C Enhance\scomments\sin\sthe\sMSVC\sbatch\sbuild\stool. -D 2015-10-29T01:11:39.776 +C Fix\suses\sof\sctype\sfunctions\s(ex:\sisspace())\son\ssigned\scharacters\sin\stest\nprograms\sand\sin\ssome\sobscure\sextensions.\s\sNo\schanges\sto\sthe\score. +D 2015-10-29T13:48:15.235 F Makefile.in 2ea961bc09e441874eb3d1bf7398e04feb24f3ee F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 702d3e98f3afc6587a78481257f3c4c900efc3a4 @@ -30,7 +30,7 @@ F autoconf/tea/pkgIndex.tcl.in 3ef61715cf1c7bdcff56947ffadb26bc991ca39d F autoconf/tea/tclconfig/install-sh bdd5e293591621ae60d9824d86a4b1c5f22c3d00 F autoconf/tea/tclconfig/tcl.m4 66ddf0a5d5e4b1d29bff472c0985fd7fa89d0fb5 F autoconf/tea/win/makefile.vc f89d0184d0eee5f7e356ea407964dcd139939928 -F autoconf/tea/win/nmakehlp.c 2070e086f39866b353a482d3a14dedaf26196506 +F autoconf/tea/win/nmakehlp.c 247538ad8e8c508f33c03ec1fbd67d3a07ef6291 F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 42b71ad3fe21c9e88fa59e8458ca1a6bc72eb0c0 @@ -48,7 +48,7 @@ F ext/async/sqlite3async.h f489b080af7e72aec0e1ee6f1d98ab6cf2e4dcef F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e F ext/fts1/ft_hash.c 3927bd880e65329bdc6f506555b228b28924921b F ext/fts1/ft_hash.h 06df7bba40dadd19597aa400a875dbc2fed705ea -F ext/fts1/fts1.c f7739dc37500a613cc0dab8fc04d1b5577d02998 +F ext/fts1/fts1.c a39f7d21c2994d27c959ef9c3505c81542c81432 F ext/fts1/fts1.h 6060b8f62c1d925ea8356cb1a6598073eb9159a6 F ext/fts1/fts1_hash.c 3196cee866edbebb1c0521e21672e6d599965114 F ext/fts1/fts1_hash.h e7f0d761353996a8175eda351104acfde23afcb0 @@ -57,7 +57,7 @@ F ext/fts1/fts1_tokenizer.h fdea722c38a9f82ed921642981234f666e47919c F ext/fts1/fts1_tokenizer1.c fd00d1fe4dc30dfc5c64cba695ce34f4af20d2fa F ext/fts1/fulltext.c 37698e1909584f6d8ea67d1485e3ad39dbf42d19 F ext/fts1/fulltext.h 08525a47852d1d62a0be81d3fc3fe2d23b094efd -F ext/fts1/simple_tokenizer.c 1844d72f7194c3fd3d7e4173053911bf0661b70d +F ext/fts1/simple_tokenizer.c bbfa4e3b2a26ef17d4edc6d98cd4a3f5396d998a F ext/fts1/tokenizer.h 0c53421b832366d20d720d21ea3e1f6e66a36ef9 F ext/fts2/README.tokenizers 21e3684ea5a095b55d70f6878b4ce6af5932dfb7 F ext/fts2/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d @@ -190,8 +190,8 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 F ext/icu/icu.c b2732aef0b076e4276d9b39b5a33cec7a05e1413 F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 -F ext/misc/amatch.c 27b9b601fb1453084e18a3432ea0240d7af8decb -F ext/misc/closure.c 636024302cde41b2bf0c542f81c40c624cfb7012 +F ext/misc/amatch.c a1a8f66c29d40bd71b075546ddeddb477b17a2bb +F ext/misc/closure.c 0d2a038df8fbae7f19de42e7c7d71f2e4dc88704 F ext/misc/compress.c 122faa92d25033d6c3f07c39231de074ab3d2e83 F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f @@ -204,7 +204,7 @@ F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a F ext/misc/series.c b8fb7befd85b3a9b4a10e701b30b2b79ca92b6d4 F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52 -F ext/misc/spellfix.c 86998fb73aefb7b5dc346ba8a58912f312da4996 +F ext/misc/spellfix.c b9065af7ab1f2597b505a8aa9892620866d502fc F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95 F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e @@ -269,7 +269,7 @@ F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271 F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504 F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421 F mptest/crash02.subtest f4ef05adcd15d60e5d2bd654204f2c008b519df8 -F mptest/mptest.c fca59f0a922e03f95ed17c44b1515ed37a841c81 +F mptest/mptest.c e7b499cb0cf8c3de65eaf24dec9b36daa4e013e4 F mptest/multiwrite01.test dab5c5f8f9534971efce679152c5146da265222d F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b @@ -752,7 +752,7 @@ F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1 F test/fuzz3.test 53fabcd5f0f430f8b221282f6c12c4d0903c21eb F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26 -F test/fuzzcheck.c c84086021a514360268190a1bc6ae8ed78d7c94f +F test/fuzzcheck.c ee926f1d4090d053ed542899720d4e4d30811bcc F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664 F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba @@ -1030,7 +1030,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/speedtest1.c 857439869d1cb4db35e1c720ee9c2756eb9ea2a0 +F test/speedtest1.c f8bf04214e7b5f745feea99f7bde68b1c4870666 F test/spellfix.test 0597065ff57042df1f138e6a2611ae19c2698135 F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3 F test/sqldiff1.test 8f6bc7c6a5b3585d350d779c6078869ba402f8f5 @@ -1333,7 +1333,7 @@ F test/without_rowid3.test aad4f9d383e199349b6c7e508a778f7dff5dff79 F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a F test/without_rowid5.test 61256715b686359df48ca1742db50cc7e3e7b862 F test/without_rowid6.test 1f99644e6508447fb050f73697350c7ceca3392e -F test/wordcount.c 9915e06cb33d8ca8109b8700791afe80d305afda +F test/wordcount.c 2a0a6c0d0e8e8bbbac1f06d72a6791828c37c0cf F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test cf6748bad89553cc1632be51a6f54e487e4039ac F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 @@ -1345,11 +1345,11 @@ F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 -F tool/fuzzershell.c b36096cdbcb4af985a2d6c20093d61e55b49bfe1 +F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c 039f813b520b9395740c52f9cbf36c90b5d8df03 +F tool/lemon.c 799e73e19a33b8dd7767a7fa34618ed2a9c2397d F tool/lempar.c 3617143ddb9b176c3605defe6a9c798793280120 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c eef612f8adf4d0993dafed0416064cf50d5d33c6 @@ -1371,18 +1371,18 @@ F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/replace.tcl 7727c60a04299b65a92f5e1590896fea0f25b9e0 F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c b1e16174385d5bd0815823a7fda1ecc82ed6088b +F tool/showdb.c d4476e000a64eca9f5e2c2f68741e747b9778e8d F tool/showjournal.c 5bad7ae8784a43d2b270d953060423b8bd480818 F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68 -F tool/showstat4.c 9515faa8ec176599d4a8288293ba8ec61f7b728a -F tool/showwal.c 85cb36d4fe3e93e2fbd63e786e0d1ce42d0c4fad +F tool/showstat4.c bda40d6e395df7edb6e9ea630784d3d762c35b4b +F tool/showwal.c ec79959834f7b21f1e0a2aa52bb7c056d2203977 F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe F tool/spaceanal.tcl 93c1fdc9733c525b17a2024c7df193daa002e037 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 -F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 +F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 -F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e +F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/sqldiff.c b318efc2eaf7a7fac4d281a0ce736193cb2506df F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43 @@ -1395,7 +1395,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b10ab59fb8a696d11a269f3904e799c687246aea -R cc38e20a3bed22c727ef2060f0363586 -U mistachkin -Z f9c898158c1864e737c38818df859932 +P 2964ce25864e8aec86272af741caf49c23c86590 +R 108548c0deac3f928b4d6bf600bf3b5a +U drh +Z 9e7ef25aa5af86f6161b757cd0b4f721 diff --git a/manifest.uuid b/manifest.uuid index 2101e8fe3..bb3991b90 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2964ce25864e8aec86272af741caf49c23c86590
\ No newline at end of file +34eb6911afee09e779318b79baf953f616200128
\ No newline at end of file diff --git a/mptest/mptest.c b/mptest/mptest.c index f81ffb5ca..5a9c8bf6b 100644 --- a/mptest/mptest.c +++ b/mptest/mptest.c @@ -46,6 +46,9 @@ #include <assert.h> #include <ctype.h> +#define ISSPACE(X) isspace((unsigned char)(X)) +#define ISDIGIT(X) isdigit((unsigned char)(X)) + /* The suffix to append to the child command lines, if any */ #if defined(_WIN32) # define GETPID (int)GetCurrentProcessId @@ -187,10 +190,10 @@ int strglob(const char *zGlob, const char *z){ } if( c2==0 || (seen ^ invert)==0 ) return 0; }else if( c=='#' ){ - if( (z[0]=='-' || z[0]=='+') && isdigit(z[1]) ) z++; - if( !isdigit(z[0]) ) return 0; + if( (z[0]=='-' || z[0]=='+') && ISDIGIT(z[1]) ) z++; + if( !ISDIGIT(z[0]) ) return 0; z++; - while( isdigit(z[0]) ){ z++; } + while( ISDIGIT(z[0]) ){ z++; } }else{ if( c!=(*(z++)) ) return 0; } @@ -289,7 +292,7 @@ static void logMessage(const char *zFormat, ...){ */ static int clipLength(const char *z){ int n = (int)strlen(z); - while( n>0 && isspace(z[n-1]) ){ n--; } + while( n>0 && ISSPACE(z[n-1]) ){ n--; } return n; } @@ -444,7 +447,7 @@ static void stringAppendTerm(String *p, const char *z){ stringAppend(p, "nil", 3); return; } - for(i=0; z[i] && !isspace(z[i]); i++){} + for(i=0; z[i] && !ISSPACE(z[i]); i++){} if( i>0 && z[i]==0 ){ stringAppend(p, z, i); return; @@ -699,7 +702,7 @@ static char *readFile(const char *zFilename){ */ static int tokenLength(const char *z, int *pnLine){ int n = 0; - if( isspace(z[0]) || (z[0]=='/' && z[1]=='*') ){ + if( ISSPACE(z[0]) || (z[0]=='/' && z[1]=='*') ){ int inC = 0; int c; if( z[0]=='/' ){ @@ -708,7 +711,7 @@ static int tokenLength(const char *z, int *pnLine){ } while( (c = z[n++])!=0 ){ if( c=='\n' ) (*pnLine)++; - if( isspace(c) ) continue; + if( ISSPACE(c) ) continue; if( inC && c=='*' && z[n]=='/' ){ n++; inC = 0; @@ -734,7 +737,7 @@ static int tokenLength(const char *z, int *pnLine){ } }else{ int c; - for(n=1; (c = z[n])!=0 && !isspace(c) && c!='"' && c!='\'' && c!=';'; n++){} + for(n=1; (c = z[n])!=0 && !ISSPACE(c) && c!='"' && c!='\'' && c!=';'; n++){} } return n; } @@ -748,7 +751,7 @@ static int extractToken(const char *zIn, int nIn, char *zOut, int nOut){ zOut[0] = 0; return 0; } - for(i=0; i<nIn && i<nOut-1 && !isspace(zIn[i]); i++){ zOut[i] = zIn[i]; } + for(i=0; i<nIn && i<nOut-1 && !ISSPACE(zIn[i]); i++){ zOut[i] = zIn[i]; } zOut[i] = 0; return i; } @@ -758,7 +761,7 @@ static int extractToken(const char *zIn, int nIn, char *zOut, int nOut){ */ static int findEnd(const char *z, int *pnLine){ int n = 0; - while( z[n] && (strncmp(z+n,"--end",5) || !isspace(z[n+5])) ){ + while( z[n] && (strncmp(z+n,"--end",5) || !ISSPACE(z[n+5])) ){ n += tokenLength(z+n, pnLine); } return n; @@ -773,12 +776,12 @@ static int findEndif(const char *z, int stopAtElse, int *pnLine){ int n = 0; while( z[n] ){ int len = tokenLength(z+n, pnLine); - if( (strncmp(z+n,"--endif",7)==0 && isspace(z[n+7])) - || (stopAtElse && strncmp(z+n,"--else",6)==0 && isspace(z[n+6])) + if( (strncmp(z+n,"--endif",7)==0 && ISSPACE(z[n+7])) + || (stopAtElse && strncmp(z+n,"--else",6)==0 && ISSPACE(z[n+6])) ){ return n+len; } - if( strncmp(z+n,"--if",4)==0 && isspace(z[n+4]) ){ + if( strncmp(z+n,"--if",4)==0 && ISSPACE(z[n+4]) ){ int skip = findEndif(z+n+len, 0, pnLine); n += skip + len; }else{ @@ -888,7 +891,7 @@ static void runScript( while( (c = zScript[ii])!=0 ){ prevLine = lineno; len = tokenLength(zScript+ii, &lineno); - if( isspace(c) || (c=='/' && zScript[ii+1]=='*') ){ + if( ISSPACE(c) || (c=='/' && zScript[ii+1]=='*') ){ ii += len; continue; } @@ -909,7 +912,7 @@ static void runScript( if( g.iTrace>=2 ) logMessage("%.*s", len, zScript+ii); n = extractToken(zScript+ii+2, len-2, zCmd, sizeof(zCmd)); for(nArg=0; n<len-2 && nArg<MX_ARG; nArg++){ - while( n<len-2 && isspace(zScript[ii+2+n]) ){ n++; } + while( n<len-2 && ISSPACE(zScript[ii+2+n]) ){ n++; } if( n>=len-2 ) break; n += extractToken(zScript+ii+2+n, len-2-n, azArg[nArg], sizeof(azArg[nArg])); @@ -976,7 +979,7 @@ static void runScript( if( strcmp(zCmd, "match")==0 ){ int jj; char *zAns = zScript+ii; - for(jj=7; jj<len-1 && isspace(zAns[jj]); jj++){} + for(jj=7; jj<len-1 && ISSPACE(zAns[jj]); jj++){} zAns += jj; if( len-jj-1!=sResult.n || strncmp(sResult.z, zAns, len-jj-1) ){ errorMessage("line %d of %s:\nExpected [%.*s]\n Got [%s]", @@ -998,7 +1001,7 @@ static void runScript( char *zAns = zScript+ii; char *zCopy; int isGlob = (zCmd[0]=='g'); - for(jj=9-3*isGlob; jj<len-1 && isspace(zAns[jj]); jj++){} + for(jj=9-3*isGlob; jj<len-1 && ISSPACE(zAns[jj]); jj++){} zAns += jj; zCopy = sqlite3_mprintf("%.*s", len-jj-1, zAns); if( (sqlite3_strglob(zCopy, sResult.z)==0)^isGlob ){ @@ -1050,7 +1053,7 @@ static void runScript( */ if( strcmp(zCmd, "print")==0 ){ int jj; - for(jj=7; jj<len && isspace(zScript[ii+jj]); jj++){} + for(jj=7; jj<len && ISSPACE(zScript[ii+jj]); jj++){} logMessage("%.*s", len-jj, zScript+ii+jj); }else @@ -1062,7 +1065,7 @@ static void runScript( if( strcmp(zCmd, "if")==0 ){ int jj, rc; sqlite3_stmt *pStmt; - for(jj=4; jj<len && isspace(zScript[ii+jj]); jj++){} + for(jj=4; jj<len && ISSPACE(zScript[ii+jj]); jj++){} pStmt = prepareSql("SELECT %.*s", len-jj, zScript+ii+jj); rc = sqlite3_step(pStmt); if( rc!=SQLITE_ROW || sqlite3_column_int(pStmt, 0)==0 ){ diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index 15ddd09ee..19995684e 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -70,6 +70,9 @@ #include <stdarg.h> #include <ctype.h> #include "sqlite3.h" +#define ISSPACE(X) isspace((unsigned char)(X)) +#define ISDIGIT(X) isdigit((unsigned char)(X)) + #ifdef __unix__ # include <signal.h> @@ -633,9 +636,9 @@ static void runSql(sqlite3 *db, const char *zSql, unsigned runFlags){ if( runFlags & SQL_TRACE ){ const char *z = zSql; int n; - while( z<zMore && isspace(z[0]) ) z++; + while( z<zMore && ISSPACE(z[0]) ) z++; n = (int)(zMore - z); - while( n>0 && isspace(z[n-1]) ) n--; + while( n>0 && ISSPACE(z[n-1]) ) n--; if( n==0 ) break; if( pStmt==0 ){ printf("TRACE: %.*s (error: %s)\n", n, z, sqlite3_errmsg(db)); @@ -757,7 +760,7 @@ static int integerValue(const char *zArg){ zArg++; } }else{ - while( isdigit(zArg[0]) ){ + while( ISDIGIT(zArg[0]) ){ v = v*10 + zArg[0] - '0'; zArg++; } diff --git a/test/speedtest1.c b/test/speedtest1.c index b34dae65a..b41c73205 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -47,6 +47,8 @@ static const char zHelp[] = #include <stdarg.h> #include <string.h> #include <ctype.h> +#define ISSPACE(X) isspace((unsigned char)(X)) +#define ISDIGIT(X) isdigit((unsigned char)(X)) #if SQLITE_VERSION_NUMBER<3005000 # define sqlite3_int64 sqlite_int64 @@ -315,7 +317,7 @@ void speedtest1_final(void){ /* Print an SQL statement to standard output */ static void printSql(const char *zSql){ int n = (int)strlen(zSql); - while( n>0 && (zSql[n-1]==';' || isspace(zSql[n-1])) ){ n--; } + while( n>0 && (zSql[n-1]==';' || ISSPACE(zSql[n-1])) ){ n--; } if( g.bExplain ) printf("EXPLAIN "); printf("%.*s;\n", n, zSql); if( g.bExplain @@ -414,7 +416,7 @@ void speedtest1_run(void){ /* The sqlite3_trace() callback function */ static void traceCallback(void *NotUsed, const char *zSql){ int n = (int)strlen(zSql); - while( n>0 && (zSql[n-1]==';' || isspace(zSql[n-1])) ) n--; + while( n>0 && (zSql[n-1]==';' || ISSPACE(zSql[n-1])) ) n--; fprintf(stderr,"%.*s;\n", n, zSql); } diff --git a/test/wordcount.c b/test/wordcount.c index cf63e983c..72aa6b2f0 100644 --- a/test/wordcount.c +++ b/test/wordcount.c @@ -80,6 +80,7 @@ #include <stdlib.h> #include <stdarg.h> #include "sqlite3.h" +#define ISALPHA(X) isalpha((unsigned char)(X)) /* Return the current wall-clock time */ static sqlite3_int64 realTime(void){ @@ -392,8 +393,8 @@ int main(int argc, char **argv){ /* Process the input file */ while( fgets(zInput, sizeof(zInput), in) ){ for(i=0; zInput[i]; i++){ - if( !isalpha(zInput[i]) ) continue; - for(j=i+1; isalpha(zInput[j]); j++){} + if( !ISALPHA(zInput[i]) ) continue; + for(j=i+1; ISALPHA(zInput[j]); j++){} /* Found a new word at zInput[i] that is j-i bytes long. ** Process it into the wordcount table. */ diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c index 6754a071e..2c778bce6 100644 --- a/tool/fuzzershell.c +++ b/tool/fuzzershell.c @@ -67,6 +67,7 @@ #include <stdarg.h> #include <ctype.h> #include "sqlite3.h" +#define ISDIGIT(X) isdigit((unsigned char)(X)) /* ** All global variables are gathered into the "g" singleton. @@ -383,7 +384,7 @@ static int integerValue(const char *zArg){ zArg++; } }else{ - while( isdigit(zArg[0]) ){ + while( ISDIGIT(zArg[0]) ){ v = v*10 + zArg[0] - '0'; zArg++; } diff --git a/tool/lemon.c b/tool/lemon.c index 2e8054b5c..d704deb62 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -13,6 +13,14 @@ #include <stdlib.h> #include <assert.h> +#define ISSPACE(X) isspace((unsigned char)(X)) +#define ISDIGIT(X) isdigit((unsigned char)(X)) +#define ISALNUM(X) isalnum((unsigned char)(X)) +#define ISALPHA(X) isalpha((unsigned char)(X)) +#define ISUPPER(X) isupper((unsigned char)(X)) +#define ISLOWER(X) islower((unsigned char)(X)) + + #ifndef __WIN32__ # if defined(_WIN32) || defined(WIN32) # define __WIN32__ @@ -93,9 +101,9 @@ static int lemon_vsprintf(char *str, const char *zFormat, va_list ap){ int iWidth = 0; lemon_addtext(str, &nUsed, &zFormat[j], i-j, 0); c = zFormat[++i]; - if( isdigit(c) || (c=='-' && isdigit(zFormat[i+1])) ){ + if( ISDIGIT(c) || (c=='-' && ISDIGIT(zFormat[i+1])) ){ if( c=='-' ) i++; - while( isdigit(zFormat[i]) ) iWidth = iWidth*10 + zFormat[i++] - '0'; + while( ISDIGIT(zFormat[i]) ) iWidth = iWidth*10 + zFormat[i++] - '0'; if( c=='-' ) iWidth = -iWidth; c = zFormat[i]; } @@ -1578,7 +1586,7 @@ int main(int argc, char **argv) while( lem.symbols[i-1]->type==MULTITERMINAL ){ i--; } assert( strcmp(lem.symbols[i-1]->name,"{default}")==0 ); lem.nsymbol = i - 1; - for(i=1; isupper(lem.symbols[i]->name[0]); i++); + for(i=1; ISUPPER(lem.symbols[i]->name[0]); i++); lem.nterminal = i; /* Generate a reprint of the grammar, if requested on the command line */ @@ -2121,7 +2129,7 @@ static void parseonetoken(struct pstate *psp) case WAITING_FOR_DECL_OR_RULE: if( x[0]=='%' ){ psp->state = WAITING_FOR_DECL_KEYWORD; - }else if( islower(x[0]) ){ + }else if( ISLOWER(x[0]) ){ psp->lhs = Symbol_new(x); psp->nrhs = 0; psp->lhsalias = 0; @@ -2151,7 +2159,7 @@ to follow the previous rule."); } break; case PRECEDENCE_MARK_1: - if( !isupper(x[0]) ){ + if( !ISUPPER(x[0]) ){ ErrorMsg(psp->filename,psp->tokenlineno, "The precedence symbol must be a terminal."); psp->errorcnt++; @@ -2191,7 +2199,7 @@ to follow the previous rule."); } break; case LHS_ALIAS_1: - if( isalpha(x[0]) ){ + if( ISALPHA(x[0]) ){ psp->lhsalias = x; psp->state = LHS_ALIAS_2; }else{ @@ -2260,7 +2268,7 @@ to follow the previous rule."); psp->prevrule = rp; } psp->state = WAITING_FOR_DECL_OR_RULE; - }else if( isalpha(x[0]) ){ + }else if( ISALPHA(x[0]) ){ if( psp->nrhs>=MAXRHS ){ ErrorMsg(psp->filename,psp->tokenlineno, "Too many symbols on RHS of rule beginning at \"%s\".", @@ -2289,7 +2297,7 @@ to follow the previous rule."); msp->subsym = (struct symbol **) realloc(msp->subsym, sizeof(struct symbol*)*msp->nsubsym); msp->subsym[msp->nsubsym-1] = Symbol_new(&x[1]); - if( islower(x[1]) || islower(msp->subsym[0]->name[0]) ){ + if( ISLOWER(x[1]) || ISLOWER(msp->subsym[0]->name[0]) ){ ErrorMsg(psp->filename,psp->tokenlineno, "Cannot form a compound containing a non-terminal"); psp->errorcnt++; @@ -2304,7 +2312,7 @@ to follow the previous rule."); } break; case RHS_ALIAS_1: - if( isalpha(x[0]) ){ + if( ISALPHA(x[0]) ){ psp->alias[psp->nrhs-1] = x; psp->state = RHS_ALIAS_2; }else{ @@ -2326,7 +2334,7 @@ to follow the previous rule."); } break; case WAITING_FOR_DECL_KEYWORD: - if( isalpha(x[0]) ){ + if( ISALPHA(x[0]) ){ psp->declkeyword = x; psp->declargslot = 0; psp->decllinenoslot = 0; @@ -2406,7 +2414,7 @@ to follow the previous rule."); } break; case WAITING_FOR_DESTRUCTOR_SYMBOL: - if( !isalpha(x[0]) ){ + if( !ISALPHA(x[0]) ){ ErrorMsg(psp->filename,psp->tokenlineno, "Symbol name missing after %%destructor keyword"); psp->errorcnt++; @@ -2420,7 +2428,7 @@ to follow the previous rule."); } break; case WAITING_FOR_DATATYPE_SYMBOL: - if( !isalpha(x[0]) ){ + if( !ISALPHA(x[0]) ){ ErrorMsg(psp->filename,psp->tokenlineno, "Symbol name missing after %%type keyword"); psp->errorcnt++; @@ -2445,7 +2453,7 @@ to follow the previous rule."); case WAITING_FOR_PRECEDENCE_SYMBOL: if( x[0]=='.' ){ psp->state = WAITING_FOR_DECL_OR_RULE; - }else if( isupper(x[0]) ){ + }else if( ISUPPER(x[0]) ){ struct symbol *sp; sp = Symbol_new(x); if( sp->prec>=0 ){ @@ -2463,7 +2471,7 @@ to follow the previous rule."); } break; case WAITING_FOR_DECL_ARG: - if( x[0]=='{' || x[0]=='\"' || isalnum(x[0]) ){ + if( x[0]=='{' || x[0]=='\"' || ISALNUM(x[0]) ){ const char *zOld, *zNew; char *zBuf, *z; int nOld, n, nLine = 0, nNew, nBack; @@ -2524,7 +2532,7 @@ to follow the previous rule."); case WAITING_FOR_FALLBACK_ID: if( x[0]=='.' ){ psp->state = WAITING_FOR_DECL_OR_RULE; - }else if( !isupper(x[0]) ){ + }else if( !ISUPPER(x[0]) ){ ErrorMsg(psp->filename, psp->tokenlineno, "%%fallback argument \"%s\" should be a token", x); psp->errorcnt++; @@ -2545,7 +2553,7 @@ to follow the previous rule."); case WAITING_FOR_WILDCARD_ID: if( x[0]=='.' ){ psp->state = WAITING_FOR_DECL_OR_RULE; - }else if( !isupper(x[0]) ){ + }else if( !ISUPPER(x[0]) ){ ErrorMsg(psp->filename, psp->tokenlineno, "%%wildcard argument \"%s\" should be a token", x); psp->errorcnt++; @@ -2561,7 +2569,7 @@ to follow the previous rule."); } break; case WAITING_FOR_CLASS_ID: - if( !islower(x[0]) ){ + if( !ISLOWER(x[0]) ){ ErrorMsg(psp->filename, psp->tokenlineno, "%%token_class must be followed by an identifier: ", x); psp->errorcnt++; @@ -2580,12 +2588,12 @@ to follow the previous rule."); case WAITING_FOR_CLASS_TOKEN: if( x[0]=='.' ){ psp->state = WAITING_FOR_DECL_OR_RULE; - }else if( isupper(x[0]) || ((x[0]=='|' || x[0]=='/') && isupper(x[1])) ){ + }else if( ISUPPER(x[0]) || ((x[0]=='|' || x[0]=='/') && ISUPPER(x[1])) ){ struct symbol *msp = psp->tkclass; msp->nsubsym++; msp->subsym = (struct symbol **) realloc(msp->subsym, sizeof(struct symbol*)*msp->nsubsym); - if( !isupper(x[0]) ) x++; + if( !ISUPPER(x[0]) ) x++; msp->subsym[msp->nsubsym-1] = Symbol_new(x); }else{ ErrorMsg(psp->filename, psp->tokenlineno, @@ -2618,7 +2626,7 @@ static void preprocess_input(char *z){ for(i=0; z[i]; i++){ if( z[i]=='\n' ) lineno++; if( z[i]!='%' || (i>0 && z[i-1]!='\n') ) continue; - if( strncmp(&z[i],"%endif",6)==0 && isspace(z[i+6]) ){ + if( strncmp(&z[i],"%endif",6)==0 && ISSPACE(z[i+6]) ){ if( exclude ){ exclude--; if( exclude==0 ){ @@ -2626,13 +2634,13 @@ static void preprocess_input(char *z){ } } for(j=i; z[j] && z[j]!='\n'; j++) z[j] = ' '; - }else if( (strncmp(&z[i],"%ifdef",6)==0 && isspace(z[i+6])) - || (strncmp(&z[i],"%ifndef",7)==0 && isspace(z[i+7])) ){ + }else if( (strncmp(&z[i],"%ifdef",6)==0 && ISSPACE(z[i+6])) + || (strncmp(&z[i],"%ifndef",7)==0 && ISSPACE(z[i+7])) ){ if( exclude ){ exclude++; }else{ - for(j=i+7; isspace(z[j]); j++){} - for(n=0; z[j+n] && !isspace(z[j+n]); n++){} + for(j=i+7; ISSPACE(z[j]); j++){} + for(n=0; z[j+n] && !ISSPACE(z[j+n]); n++){} exclude = 1; for(k=0; k<nDefine; k++){ if( strncmp(azDefine[k],&z[j],n)==0 && lemonStrlen(azDefine[k])==n ){ @@ -2712,7 +2720,7 @@ void Parse(struct lemon *gp) lineno = 1; for(cp=filebuf; (c= *cp)!=0; ){ if( c=='\n' ) lineno++; /* Keep track of the line number */ - if( isspace(c) ){ cp++; continue; } /* Skip all white space */ + if( ISSPACE(c) ){ cp++; continue; } /* Skip all white space */ if( c=='/' && cp[1]=='/' ){ /* Skip C++ style comments */ cp+=2; while( (c= *cp)!=0 && c!='\n' ) cp++; @@ -2782,15 +2790,15 @@ void Parse(struct lemon *gp) }else{ nextcp = cp+1; } - }else if( isalnum(c) ){ /* Identifiers */ - while( (c= *cp)!=0 && (isalnum(c) || c=='_') ) cp++; + }else if( ISALNUM(c) ){ /* Identifiers */ + while( (c= *cp)!=0 && (ISALNUM(c) || c=='_') ) cp++; nextcp = cp; }else if( c==':' && cp[1]==':' && cp[2]=='=' ){ /* The operator "::=" */ cp += 3; nextcp = cp; - }else if( (c=='/' || c=='|') && isalpha(cp[1]) ){ + }else if( (c=='/' || c=='|') && ISALPHA(cp[1]) ){ cp += 2; - while( (c = *cp)!=0 && (isalnum(c) || c=='_') ) cp++; + while( (c = *cp)!=0 && (ISALNUM(c) || c=='_') ) cp++; nextcp = cp; }else{ /* All other (one character) operators */ cp++; @@ -3241,7 +3249,7 @@ PRIVATE void tplt_xfer(char *name, FILE *in, FILE *out, int *lineno) if( name ){ for(i=0; line[i]; i++){ if( line[i]=='P' && strncmp(&line[i],"Parse",5)==0 - && (i==0 || !isalpha(line[i-1])) + && (i==0 || !ISALPHA(line[i-1])) ){ if( i>iStart ) fprintf(out,"%.*s",i-iStart,&line[iStart]); fprintf(out,"%s",name); @@ -3478,9 +3486,9 @@ PRIVATE void translate_code(struct lemon *lemp, struct rule *rp){ /* This const cast is wrong but harmless, if we're careful. */ for(cp=(char *)rp->code; *cp; cp++){ - if( isalpha(*cp) && (cp==rp->code || (!isalnum(cp[-1]) && cp[-1]!='_')) ){ + if( ISALPHA(*cp) && (cp==rp->code || (!ISALNUM(cp[-1]) && cp[-1]!='_')) ){ char saved; - for(xp= &cp[1]; isalnum(*xp) || *xp=='_'; xp++); + for(xp= &cp[1]; ISALNUM(*xp) || *xp=='_'; xp++); saved = *xp; *xp = 0; if( rp->lhsalias && strcmp(cp,rp->lhsalias)==0 ){ @@ -3645,9 +3653,9 @@ void print_stack_union( cp = sp->datatype; if( cp==0 ) cp = lemp->vartype; j = 0; - while( isspace(*cp) ) cp++; + while( ISSPACE(*cp) ) cp++; while( *cp ) stddt[j++] = *cp++; - while( j>0 && isspace(stddt[j-1]) ) j--; + while( j>0 && ISSPACE(stddt[j-1]) ) j--; stddt[j] = 0; if( lemp->tokentype && strcmp(stddt, lemp->tokentype)==0 ){ sp->dtnum = 0; @@ -3857,8 +3865,8 @@ void ReportTable( name = lemp->name ? lemp->name : "Parse"; if( lemp->arg && lemp->arg[0] ){ i = lemonStrlen(lemp->arg); - while( i>=1 && isspace(lemp->arg[i-1]) ) i--; - while( i>=1 && (isalnum(lemp->arg[i-1]) || lemp->arg[i-1]=='_') ) i--; + while( i>=1 && ISSPACE(lemp->arg[i-1]) ) i--; + while( i>=1 && (ISALNUM(lemp->arg[i-1]) || lemp->arg[i-1]=='_') ) i--; fprintf(out,"#define %sARG_SDECL %s;\n",name,lemp->arg); lineno++; fprintf(out,"#define %sARG_PDECL ,%s\n",name,lemp->arg); lineno++; fprintf(out,"#define %sARG_FETCH %s = yypParser->%s\n", @@ -4666,7 +4674,7 @@ struct symbol *Symbol_new(const char *x) sp = (struct symbol *)calloc(1, sizeof(struct symbol) ); MemoryCheck(sp); sp->name = Strsafe(x); - sp->type = isupper(*x) ? TERMINAL : NONTERMINAL; + sp->type = ISUPPER(*x) ? TERMINAL : NONTERMINAL; sp->rule = 0; sp->fallback = 0; sp->prec = -1; diff --git a/tool/showdb.c b/tool/showdb.c index 892cacd55..38b92f1f7 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -3,6 +3,8 @@ */ #include <stdio.h> #include <ctype.h> +#define ISDIGIT(X) isdigit((unsigned char)(X)) +#define ISPRINT(X) isprint((unsigned char)(X)) #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -217,7 +219,7 @@ static unsigned char *print_byte_range( if( i+j>nByte ){ fprintf(stdout, " "); }else{ - fprintf(stdout,"%c", isprint(aData[i+j]) ? aData[i+j] : '.'); + fprintf(stdout,"%c", ISPRINT(aData[i+j]) ? aData[i+j] : '.'); } } fprintf(stdout,"\n"); @@ -600,7 +602,7 @@ static void decodeCell( }else{ zConst[0] = '\''; for(ii=1, jj=0; jj<szCol[i] && ii<24; jj++, ii++){ - zConst[ii] = isprint(pData[jj]) ? pData[jj] : '.'; + zConst[ii] = ISPRINT(pData[jj]) ? pData[jj] : '.'; } zConst[ii] = 0; } @@ -653,11 +655,11 @@ static void decode_btree_page( case 'c': showCellContent = 1; break; case 'm': showMap = 1; break; case 'd': { - if( !isdigit(zArgs[1]) ){ + if( !ISDIGIT(zArgs[1]) ){ cellToDecode = -1; }else{ cellToDecode = 0; - while( isdigit(zArgs[1]) ){ + while( ISDIGIT(zArgs[1]) ){ zArgs++; cellToDecode = cellToDecode*10 + zArgs[0] - '0'; } @@ -1123,7 +1125,7 @@ int main(int argc, char **argv){ usage(zPrg); continue; } - if( !isdigit(azArg[i][0]) ){ + if( !ISDIGIT(azArg[i][0]) ){ fprintf(stderr, "%s: unknown option: [%s]\n", zPrg, azArg[i]); continue; } diff --git a/tool/showstat4.c b/tool/showstat4.c index 215962919..c7f9b10fb 100644 --- a/tool/showstat4.c +++ b/tool/showstat4.c @@ -9,6 +9,8 @@ #include <ctype.h> #include "sqlite3.h" +#define ISPRINT(X) isprint((unsigned char)(X)) + typedef sqlite3_int64 i64; /* 64-bit signed integer type */ @@ -131,7 +133,7 @@ int main(int argc, char **argv){ printf("%s\"", zSep); for(j=0; j<sz; j++){ char c = (char)aSample[y+j]; - if( isprint(c) ){ + if( ISPRINT(c) ){ if( c=='"' || c=='\\' ) putchar('\\'); putchar(c); }else if( c=='\n' ){ diff --git a/tool/showwal.c b/tool/showwal.c index 35810c66a..33cc21896 100644 --- a/tool/showwal.c +++ b/tool/showwal.c @@ -7,6 +7,9 @@ #include <sys/stat.h> #include <fcntl.h> +#define ISDIGIT(X) isdigit((unsigned char)(X)) +#define ISPRINT(X) isprint((unsigned char)(X)) + #if !defined(_MSC_VER) #include <unistd.h> #else @@ -159,7 +162,7 @@ static void print_byte_range( if( i+j>nByte ){ fprintf(stdout, " "); }else{ - fprintf(stdout,"%c", isprint(aData[i+j]) ? aData[i+j] : '.'); + fprintf(stdout,"%c", ISPRINT(aData[i+j]) ? aData[i+j] : '.'); } } fprintf(stdout,"\n"); @@ -550,7 +553,7 @@ int main(int argc, char **argv){ print_wal_header(0); continue; } - if( !isdigit(argv[i][0]) ){ + if( !ISDIGIT(argv[i][0]) ){ fprintf(stderr, "%s: unknown option: [%s]\n", argv[0], argv[i]); continue; } diff --git a/tool/speedtest16.c b/tool/speedtest16.c index e81f1a6db..993cc1926 100644 --- a/tool/speedtest16.c +++ b/tool/speedtest16.c @@ -29,6 +29,8 @@ #include <unistd.h> #include "sqlite3.h" +#define ISSPACE(X) isspace((unsigned char)(X)) + /* ** hwtime.h contains inline assembler code for implementing ** high-performance timing routines. @@ -140,7 +142,7 @@ int main(int argc, char **argv){ zSql[j+1] = c; if( isComplete ){ zSql[j] = 0; - while( i<j && isspace(zSql[i]) ){ i++; } + while( i<j && ISSPACE(zSql[i]) ){ i++; } if( i<j ){ nStmt++; nByte += j-i; diff --git a/tool/speedtest8inst1.c b/tool/speedtest8inst1.c index f0cb544c8..ceaeca0f1 100644 --- a/tool/speedtest8inst1.c +++ b/tool/speedtest8inst1.c @@ -29,6 +29,8 @@ #include <stdarg.h> #include "sqlite3.h" +#define ISSPACE(X) isspace((unsigned char)(X)) + #include "test_osinst.c" /* @@ -197,7 +199,7 @@ int main(int argc, char **argv){ zSql[j+1] = c; if( isComplete ){ zSql[j] = 0; - while( i<j && isspace(zSql[i]) ){ i++; } + while( i<j && ISSPACE(zSql[i]) ){ i++; } if( i<j ){ prepareAndRun(pInstVfs, db, &zSql[i]); } |