1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-06 15:49:35 +03:00

Do not report an error if the input to the sqlite shell ends in a comment.

Ticket #211. (CVS 838)

FossilOrigin-Name: 32a8e6e9771d636c0ad3042632d35865bc08585b
This commit is contained in:
drh
2003-01-18 17:05:00 +00:00
parent 799550beb0
commit be4f31c226
3 changed files with 24 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
C Check\sthe\svalidity\sof\sthe\sdatabase\sconnection\sbefore\sthe\strace\scallback,\nnot\safterwards.\s(CVS\s837) C Do\snot\sreport\san\serror\sif\sthe\sinput\sto\sthe\ssqlite\sshell\sends\sin\sa\scomment.\nTicket\s#211.\s(CVS\s838)
D 2003-01-18T17:04:09 D 2003-01-18T17:05:01
F Makefile.in 6606854b1512f185b8e8c779b8d7fc2750463d64 F Makefile.in 6606854b1512f185b8e8c779b8d7fc2750463d64
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -39,7 +39,7 @@ F src/parse.y 58655a50817f93ddd0bc3d8949e267729396949c
F src/printf.c 5c50fc1da75c8f5bf432b1ad17d91d6653acd167 F src/printf.c 5c50fc1da75c8f5bf432b1ad17d91d6653acd167
F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
F src/select.c 5ce75c1381d8ec3b89ea4d7eb5171bc57785e610 F src/select.c 5ce75c1381d8ec3b89ea4d7eb5171bc57785e610
F src/shell.c c9946847b81b8b7f32ad195498dafbc623c6874f F src/shell.c cbb29252f0bd7b144d1e3126e64e17e5a314f2fd
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
F src/sqlite.h.in 90657185cff387069d17c5b876a87a6a7a3b6f10 F src/sqlite.h.in 90657185cff387069d17c5b876a87a6a7a3b6f10
F src/sqliteInt.h 1df32c9bcf08e30b5b8b978fd587fac018273c33 F src/sqliteInt.h 1df32c9bcf08e30b5b8b978fd587fac018273c33
@@ -154,7 +154,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803
F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
P f67bff8ff3db9694f87daf1a549d24ea9612da6b P 960a2e4af3b940d74a82f98e8bf19aeec88a05ce
R effe9d0228ec9a51eeb8838dab1ee578 R 401c88fefa12fdbc2635d9394c8dc749
U drh U drh
Z 762142889e27f0dfcfbf3d94a2871c9d Z d11acb4a94d33c83e2103e12a2cf5085

View File

@@ -1 +1 @@
960a2e4af3b940d74a82f98e8bf19aeec88a05ce 32a8e6e9771d636c0ad3042632d35865bc08585b

View File

@@ -12,7 +12,7 @@
** This file contains code to implement the "sqlite" command line ** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases. ** utility for accessing SQLite databases.
** **
** $Id: shell.c,v 1.64 2003/01/08 13:02:53 drh Exp $ ** $Id: shell.c,v 1.65 2003/01/18 17:05:01 drh Exp $
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -912,6 +912,20 @@ static int do_meta_command(char *zLine, sqlite *db, struct callback_data *p){
return rc; return rc;
} }
/*
** Skip over an SQL comments and whitespace. Return a pointer to the text that
** follows the comments and whitespace.
*/
static char *skip_whitespace(char *z){
while( isspace(*z) ){ z++; }
while( z[0]=='-' && z[1]=='-' ){
z += 2;
while( *z && *z!='\n' ){ z++; }
while( isspace(*z) ){ z++; }
}
return z;
}
/* /*
** Read input from *in and process it. If *in==0 then input ** Read input from *in and process it. If *in==0 then input
** is interactive - the user is typing it it. Otherwise, input ** is interactive - the user is typing it it. Otherwise, input
@@ -976,7 +990,8 @@ static void process_input(struct callback_data *p, FILE *in){
} }
} }
if( zSql ){ if( zSql ){
printf("Incomplete SQL: %s\n", zSql); char *zTail = skip_whitespace(zSql);
if( zTail && zTail[0] ) printf("Incomplete SQL: %s\n", zSql);
free(zSql); free(zSql);
} }
} }