mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-06 15:49:35 +03:00
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
This commit is contained in:
40
src/shell.c
40
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 <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user