$OpenBSD: patch-sqlitebrowser_sqlbrowser_util_c,v 1.2 2012/03/17 22:50:56 naddy Exp $ --- sqlitebrowser/sqlbrowser_util.c.orig Sat Mar 17 16:45:31 2012 +++ sqlitebrowser/sqlbrowser_util.c Sat Mar 17 16:49:14 2012 @@ -53,6 +53,34 @@ static void output_quoted_string(FILE *out, const char } } + +int myIsNumber(const char *z, int *realnum, u8 enc){ + int incr = (enc==SQLITE_UTF8?1:2); + if( enc==SQLITE_UTF16BE ) z++; + if( *z=='-' || *z=='+' ) z += incr; + if( !isdigit(*(u8*)z) ){ + return 0; + } + z += incr; + if( realnum ) *realnum = 0; + while( isdigit(*(u8*)z) ){ z += incr; } + if( *z=='.' ){ + z += incr; + if( !isdigit(*(u8*)z) ) return 0; + while( isdigit(*(u8*)z) ){ z += incr; } + if( realnum ) *realnum = 1; + } + if( *z=='e' || *z=='E' ){ + z += incr; + if( *z=='+' || *z=='-' ) z += incr; + if( !isdigit(*(u8*)z) ) return 0; + while( isdigit(*(u8*)z) ){ z += incr; } + if( realnum ) *realnum = 1; + } + return *z==0; +} + + /* ** Output the given string with characters that are special to ** HTML escaped. @@ -193,7 +221,7 @@ static int callback(void *pArg, int nArg, char **azArg char *zSep = i>0 ? ",": ""; if( azArg[i]==0 ){ fprintf(p->out,"%sNULL",zSep); - }else if( sqlite3IsNumber(azArg[i], NULL, SQLITE_UTF8) ){ + }else if( myIsNumber(azArg[i], NULL, SQLITE_UTF8) ){ fprintf(p->out,"%s%s",zSep, azArg[i]); }else{ if( zSep[0] ) fprintf(p->out,"%s",zSep); @@ -351,14 +379,14 @@ static int _all_whitespace(const char *z){ static int _is_command_terminator(const char *zLine){ while( isspace(*zLine) ){ zLine++; }; if( zLine[0]=='/' && _all_whitespace(&zLine[1]) ) return 1; /* Oracle */ - if( sqlite3StrNICmp(zLine,"go",2)==0 && _all_whitespace(&zLine[2]) ){ + if( strncasecmp(zLine,"go",2)==0 && _all_whitespace(&zLine[2]) ){ return 1; /* SQL Server */ } return 0; } -char *getline(FILE *in){ +char *get_line(FILE *in){ char *zLine; int nLine; int n; @@ -402,7 +430,7 @@ void process_input(sqlite3 * db, FILE *in, int * lineE char * zErrMsg = 0; int nSql = 0; int rc; - while((zLine = getline(in))!=0 ){ + while((zLine = get_line(in))!=0 ){ if( (zSql==0 || zSql[0]==0) && _all_whitespace(zLine) ) continue; (*lineErr)++; if( zSql==0 ){