4646#include <assert.h>
4747#include <ctype.h>
4848
49+ #define ISSPACE (X ) isspace((unsigned char)(X))
50+ #define ISDIGIT (X ) isdigit((unsigned char)(X))
51+
4952/* The suffix to append to the child command lines, if any */
5053#if defined(_WIN32 )
5154# define GETPID (int)GetCurrentProcessId
@@ -187,10 +190,10 @@ int strglob(const char *zGlob, const char *z){
187190 }
188191 if ( c2 == 0 || (seen ^ invert )== 0 ) return 0 ;
189192 }else if ( c == '#' ){
190- if ( (z [0 ]== '-' || z [0 ]== '+' ) && isdigit (z [1 ]) ) z ++ ;
191- if ( !isdigit (z [0 ]) ) return 0 ;
193+ if ( (z [0 ]== '-' || z [0 ]== '+' ) && ISDIGIT (z [1 ]) ) z ++ ;
194+ if ( !ISDIGIT (z [0 ]) ) return 0 ;
192195 z ++ ;
193- while ( isdigit (z [0 ]) ){ z ++ ; }
196+ while ( ISDIGIT (z [0 ]) ){ z ++ ; }
194197 }else {
195198 if ( c != (* (z ++ )) ) return 0 ;
196199 }
@@ -289,7 +292,7 @@ static void logMessage(const char *zFormat, ...){
289292*/
290293static int clipLength (const char * z ){
291294 int n = (int )strlen (z );
292- while ( n > 0 && isspace (z [n - 1 ]) ){ n -- ; }
295+ while ( n > 0 && ISSPACE (z [n - 1 ]) ){ n -- ; }
293296 return n ;
294297}
295298
@@ -444,7 +447,7 @@ static void stringAppendTerm(String *p, const char *z){
444447 stringAppend (p , "nil" , 3 );
445448 return ;
446449 }
447- for (i = 0 ; z [i ] && !isspace (z [i ]); i ++ ){}
450+ for (i = 0 ; z [i ] && !ISSPACE (z [i ]); i ++ ){}
448451 if ( i > 0 && z [i ]== 0 ){
449452 stringAppend (p , z , i );
450453 return ;
@@ -699,7 +702,7 @@ static char *readFile(const char *zFilename){
699702*/
700703static int tokenLength (const char * z , int * pnLine ){
701704 int n = 0 ;
702- if ( isspace (z [0 ]) || (z [0 ]== '/' && z [1 ]== '*' ) ){
705+ if ( ISSPACE (z [0 ]) || (z [0 ]== '/' && z [1 ]== '*' ) ){
703706 int inC = 0 ;
704707 int c ;
705708 if ( z [0 ]== '/' ){
@@ -708,7 +711,7 @@ static int tokenLength(const char *z, int *pnLine){
708711 }
709712 while ( (c = z [n ++ ])!= 0 ){
710713 if ( c == '\n' ) (* pnLine )++ ;
711- if ( isspace (c ) ) continue ;
714+ if ( ISSPACE (c ) ) continue ;
712715 if ( inC && c == '*' && z [n ]== '/' ){
713716 n ++ ;
714717 inC = 0 ;
@@ -734,7 +737,7 @@ static int tokenLength(const char *z, int *pnLine){
734737 }
735738 }else {
736739 int c ;
737- for (n = 1 ; (c = z [n ])!= 0 && !isspace (c ) && c != '"' && c != '\'' && c != ';' ; n ++ ){}
740+ for (n = 1 ; (c = z [n ])!= 0 && !ISSPACE (c ) && c != '"' && c != '\'' && c != ';' ; n ++ ){}
738741 }
739742 return n ;
740743}
@@ -748,7 +751,7 @@ static int extractToken(const char *zIn, int nIn, char *zOut, int nOut){
748751 zOut [0 ] = 0 ;
749752 return 0 ;
750753 }
751- for (i = 0 ; i < nIn && i < nOut - 1 && !isspace (zIn [i ]); i ++ ){ zOut [i ] = zIn [i ]; }
754+ for (i = 0 ; i < nIn && i < nOut - 1 && !ISSPACE (zIn [i ]); i ++ ){ zOut [i ] = zIn [i ]; }
752755 zOut [i ] = 0 ;
753756 return i ;
754757}
@@ -758,7 +761,7 @@ static int extractToken(const char *zIn, int nIn, char *zOut, int nOut){
758761*/
759762static int findEnd (const char * z , int * pnLine ){
760763 int n = 0 ;
761- while ( z [n ] && (strncmp (z + n ,"--end" ,5 ) || !isspace (z [n + 5 ])) ){
764+ while ( z [n ] && (strncmp (z + n ,"--end" ,5 ) || !ISSPACE (z [n + 5 ])) ){
762765 n += tokenLength (z + n , pnLine );
763766 }
764767 return n ;
@@ -773,12 +776,12 @@ static int findEndif(const char *z, int stopAtElse, int *pnLine){
773776 int n = 0 ;
774777 while ( z [n ] ){
775778 int len = tokenLength (z + n , pnLine );
776- if ( (strncmp (z + n ,"--endif" ,7 )== 0 && isspace (z [n + 7 ]))
777- || (stopAtElse && strncmp (z + n ,"--else" ,6 )== 0 && isspace (z [n + 6 ]))
779+ if ( (strncmp (z + n ,"--endif" ,7 )== 0 && ISSPACE (z [n + 7 ]))
780+ || (stopAtElse && strncmp (z + n ,"--else" ,6 )== 0 && ISSPACE (z [n + 6 ]))
778781 ){
779782 return n + len ;
780783 }
781- if ( strncmp (z + n ,"--if" ,4 )== 0 && isspace (z [n + 4 ]) ){
784+ if ( strncmp (z + n ,"--if" ,4 )== 0 && ISSPACE (z [n + 4 ]) ){
782785 int skip = findEndif (z + n + len , 0 , pnLine );
783786 n += skip + len ;
784787 }else {
@@ -888,7 +891,7 @@ static void runScript(
888891 while ( (c = zScript [ii ])!= 0 ){
889892 prevLine = lineno ;
890893 len = tokenLength (zScript + ii , & lineno );
891- if ( isspace (c ) || (c == '/' && zScript [ii + 1 ]== '*' ) ){
894+ if ( ISSPACE (c ) || (c == '/' && zScript [ii + 1 ]== '*' ) ){
892895 ii += len ;
893896 continue ;
894897 }
@@ -909,7 +912,7 @@ static void runScript(
909912 if ( g .iTrace >=2 ) logMessage ("%.*s" , len , zScript + ii );
910913 n = extractToken (zScript + ii + 2 , len - 2 , zCmd , sizeof (zCmd ));
911914 for (nArg = 0 ; n < len - 2 && nArg < MX_ARG ; nArg ++ ){
912- while ( n < len - 2 && isspace (zScript [ii + 2 + n ]) ){ n ++ ; }
915+ while ( n < len - 2 && ISSPACE (zScript [ii + 2 + n ]) ){ n ++ ; }
913916 if ( n >=len - 2 ) break ;
914917 n += extractToken (zScript + ii + 2 + n , len - 2 - n ,
915918 azArg [nArg ], sizeof (azArg [nArg ]));
@@ -976,7 +979,7 @@ static void runScript(
976979 if ( strcmp (zCmd , "match" )== 0 ){
977980 int jj ;
978981 char * zAns = zScript + ii ;
979- for (jj = 7 ; jj < len - 1 && isspace (zAns [jj ]); jj ++ ){}
982+ for (jj = 7 ; jj < len - 1 && ISSPACE (zAns [jj ]); jj ++ ){}
980983 zAns += jj ;
981984 if ( len - jj - 1 != sResult .n || strncmp (sResult .z , zAns , len - jj - 1 ) ){
982985 errorMessage ("line %d of %s:\nExpected [%.*s]\n Got [%s]" ,
@@ -998,7 +1001,7 @@ static void runScript(
9981001 char * zAns = zScript + ii ;
9991002 char * zCopy ;
10001003 int isGlob = (zCmd [0 ]== 'g' );
1001- for (jj = 9 - 3 * isGlob ; jj < len - 1 && isspace (zAns [jj ]); jj ++ ){}
1004+ for (jj = 9 - 3 * isGlob ; jj < len - 1 && ISSPACE (zAns [jj ]); jj ++ ){}
10021005 zAns += jj ;
10031006 zCopy = sqlite3_mprintf ("%.*s" , len - jj - 1 , zAns );
10041007 if ( (sqlite3_strglob (zCopy , sResult .z )== 0 )^isGlob ){
@@ -1050,7 +1053,7 @@ static void runScript(
10501053 */
10511054 if ( strcmp (zCmd , "print" )== 0 ){
10521055 int jj ;
1053- for (jj = 7 ; jj < len && isspace (zScript [ii + jj ]); jj ++ ){}
1056+ for (jj = 7 ; jj < len && ISSPACE (zScript [ii + jj ]); jj ++ ){}
10541057 logMessage ("%.*s" , len - jj , zScript + ii + jj );
10551058 }else
10561059
@@ -1062,7 +1065,7 @@ static void runScript(
10621065 if ( strcmp (zCmd , "if" )== 0 ){
10631066 int jj , rc ;
10641067 sqlite3_stmt * pStmt ;
1065- for (jj = 4 ; jj < len && isspace (zScript [ii + jj ]); jj ++ ){}
1068+ for (jj = 4 ; jj < len && ISSPACE (zScript [ii + jj ]); jj ++ ){}
10661069 pStmt = prepareSql ("SELECT %.*s" , len - jj , zScript + ii + jj );
10671070 rc = sqlite3_step (pStmt );
10681071 if ( rc != SQLITE_ROW || sqlite3_column_int (pStmt , 0 )== 0 ){
0 commit comments