From 839656620487125e287c6eaa244bb04abbee3bcd Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 17 Apr 2003 02:54:13 +0000 Subject: [PATCH] Change the shell to use the sqliteIsNumber() routine for determining if values are numeric. Modified os.c so that it should now work with DJGPP - though I have no way of testing this. (CVS 913) FossilOrigin-Name: 35caefe31750fd103b5f0231ad36f375771063eb --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os.c | 23 +++++++++++++++++++---- src/shell.c | 40 +++++++++++----------------------------- 4 files changed, 38 insertions(+), 41 deletions(-) diff --git a/manifest b/manifest index 97ea22a06a..d02b4703f0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Rollback\sif\sa\scommit\shook\sfails.\s(CVS\s912) -D 2003-04-16T21:03:14 +C Change\sthe\sshell\sto\suse\sthe\ssqliteIsNumber()\sroutine\sfor\sdetermining\sif\nvalues\sare\snumeric.\s\sModified\sos.c\sso\sthat\sit\sshould\snow\swork\swith\sDJGPP\s-\nthough\sI\shave\sno\sway\sof\stesting\sthis.\s(CVS\s913) +D 2003-04-17T02:54:14 F Makefile.in df3a4db41a7450468b5fe934d9dd8f723b631249 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -35,7 +35,7 @@ F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8 F src/insert.c 45d27e3e8447bff4025db2f0dc3bb4e318e602f4 F src/main.c e48b3b019cf34503655e9737bcb859443ab6718c F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565 -F src/os.c c33ebb320921b8df6d09ea19fe846348df86a0c9 +F src/os.c 7274951ed6894f383cb889342267ded07caf339b F src/os.h aa52f0c9da321ff6134d19f2ca959e18e33615d0 F src/pager.c df4c81350cbd80c1ab48341ae0768ba78d99ad49 F src/pager.h e3702f7d384921f6cd5ce0b3ed589185433e9f6c @@ -44,7 +44,7 @@ F src/pragma.c aef327bd597e15f0d31f45b042bd2797cca65039 F src/printf.c fc5fdef6e92ad205005263661fe9716f55a49f3e F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe F src/select.c 14e2e2a512f4edfc75fb310ebcb502ff3ee87402 -F src/shell.c 97f397c0c108176ccbc52ea5b8ec688f995eba7a +F src/shell.c 6980eadda7506f741ab42fd9d32613e2fdabafa9 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e F src/sqlite.h.in f49c2cdec7d24cb03e496a1ca519e16306495ee1 F src/sqliteInt.h b3d4e485ab646970e8b0d268771486683aceab12 @@ -162,7 +162,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P f04bd43254b3ba3fccc842214115d4c298e28138 -R ba05498314c5f31c57ab60797b0329b3 +P 5cea7554ae9d36434cd7261b5b40f3d467b836f1 +R 02865a72582f56772c59d063e3ecf5aa U drh -Z a431049f257620a5d96f06bc4fc52099 +Z e1cf076e54a9004f700a5082c4a00108 diff --git a/manifest.uuid b/manifest.uuid index 98015f6d1f..005615a014 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5cea7554ae9d36434cd7261b5b40f3d467b836f1 \ No newline at end of file +35caefe31750fd103b5f0231ad36f375771063eb \ No newline at end of file diff --git a/src/os.c b/src/os.c index a0ec2d6b73..086424bba6 100644 --- a/src/os.c +++ b/src/os.c @@ -31,8 +31,12 @@ # ifndef O_NOFOLLOW # define O_NOFOLLOW 0 # endif +# ifndef O_BINARY +# define O_BINARY 0 +# endif #endif + #if OS_WIN # include #endif @@ -47,6 +51,16 @@ # include #endif +/* +** The DJGPP compiler environment looks mostly like Unix, but it +** lacks the fcntl() system call. So redefine fcntl() to be something +** that always succeeds. This means that locking does not occur under +** DJGPP. But its DOS - what did you expect? +*/ +#ifdef __DJGPP__ +# define fcntl(A,B,C) 0 +#endif + /* ** Macros for performance tracing. Normally turned off */ @@ -311,9 +325,9 @@ int sqliteOsOpenReadWrite( int *pReadonly ){ #if OS_UNIX - id->fd = open(zFilename, O_RDWR|O_CREAT|O_LARGEFILE, 0644); + id->fd = open(zFilename, O_RDWR|O_CREAT|O_LARGEFILE|O_BINARY, 0644); if( id->fd<0 ){ - id->fd = open(zFilename, O_RDONLY|O_LARGEFILE); + id->fd = open(zFilename, O_RDONLY|O_LARGEFILE|O_BINARY); if( id->fd<0 ){ return SQLITE_CANTOPEN; } @@ -435,7 +449,8 @@ int sqliteOsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){ if( access(zFilename, 0)==0 ){ return SQLITE_CANTOPEN; } - id->fd = open(zFilename, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_LARGEFILE, 0600); + id->fd = open(zFilename, + O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_LARGEFILE|O_BINARY, 0600); if( id->fd<0 ){ return SQLITE_CANTOPEN; } @@ -520,7 +535,7 @@ int sqliteOsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){ */ int sqliteOsOpenReadOnly(const char *zFilename, OsFile *id){ #if OS_UNIX - id->fd = open(zFilename, O_RDONLY|O_LARGEFILE); + id->fd = open(zFilename, O_RDONLY|O_LARGEFILE|O_BINARY); if( id->fd<0 ){ return SQLITE_CANTOPEN; } diff --git a/src/shell.c b/src/shell.c index 55aeb5601f..00601df47b 100644 --- a/src/shell.c +++ b/src/shell.c @@ -12,7 +12,7 @@ ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** -** $Id: shell.c,v 1.68 2003/04/03 19:35:02 drh Exp $ +** $Id: shell.c,v 1.69 2003/04/17 02:54:14 drh Exp $ */ #include #include @@ -72,6 +72,11 @@ static char *Argv0; static char mainPrompt[20]; /* First line prompt. default: "sqlite> "*/ static char continuePrompt[20]; /* Continuation prompt. default: " ...> " */ +/* +** Determines if a string is a number of not. +*/ +extern int sqliteIsNumber(const char*); + /* ** This routine reads a line of text from standard input, stores ** the text in memory obtained from malloc() and returns a pointer @@ -169,9 +174,11 @@ struct callback_data { char separator[20]; /* Separator character for MODE_List */ int colWidth[100]; /* Requested width of each column when in column mode*/ int actualWidth[100]; /* Actual width of each column */ - char nullvalue[20]; /* The text to print when a NULL comes back from the database */ + char nullvalue[20]; /* The text to print when a NULL comes back from + ** the database */ struct previous_mode_data explainPrev; - /* Holds the mode information just before .explain ON */ + /* Holds the mode information just before + ** .explain ON */ char outfile[FILENAME_MAX]; /* Filename for *out */ }; @@ -201,31 +208,6 @@ char *modeDescr[MODE_NUM_OF] = { */ #define ArraySize(X) (sizeof(X)/sizeof(X[0])) -/* -** Return TRUE if the string supplied is a number of some kinds. -*/ -static int is_numeric(const char *z){ - int seen_digit = 0; - if( *z=='-' || *z=='+' ){ - z++; - } - while( isdigit(*z) ){ - seen_digit = 1; - z++; - } - if( seen_digit && *z=='.' ){ - z++; - while( isdigit(*z) ){ z++; } - } - if( seen_digit && (*z=='e' || *z=='E') - && (isdigit(z[1]) || ((z[1]=='-' || z[1]=='+') && isdigit(z[2]))) - ){ - z+=2; - while( isdigit(*z) ){ z++; } - } - return seen_digit && *z==0; -} - /* ** Output the given string as a quoted string using SQL quoting conventions. */ @@ -403,7 +385,7 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){ char *zSep = i>0 ? ",": ""; if( azArg[i]==0 ){ fprintf(p->out,"%sNULL",zSep); - }else if( is_numeric(azArg[i]) ){ + }else if( sqliteIsNumber(azArg[i]) ){ fprintf(p->out,"%s%s",zSep, azArg[i]); }else{ if( zSep[0] ) fprintf(p->out,"%s",zSep);