]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the shell tool to do a better job of ignoring whitespace. Ticket #234. (CVS...
authordrh <drh@noemail.net>
Sat, 26 Apr 2003 03:03:06 +0000 (03:03 +0000)
committerdrh <drh@noemail.net>
Sat, 26 Apr 2003 03:03:06 +0000 (03:03 +0000)
FossilOrigin-Name: 639957e9f793eddce027050d2655863d82fe8ac9

manifest
manifest.uuid
src/shell.c

index c4ad43b949119ed8989e00ccc9521350d89c1fd9..5d9a6a758c2a9ca8f0335dba8685fd90042885f5 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Only\sprint\sthe\s"Loading\sresources\sfrom..."\sline\swhen\sthe\soutput\sis\sa\sTTY.\nTicket\s#168.\s(CVS\s939)
-D 2003-04-26T02:50:11
+C Fix\sthe\sshell\stool\sto\sdo\sa\sbetter\sjob\sof\signoring\swhitespace.\s\sTicket\s#234.\s(CVS\s940)
+D 2003-04-26T03:03:07
 F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -44,7 +44,7 @@ F src/pragma.c 118fe400d71b7fdcc03580d5eab6bb5aa00772a5
 F src/printf.c fc5fdef6e92ad205005263661fe9716f55a49f3e
 F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
 F src/select.c dfc13cb62ba658c4463179713c40ee25a062b2ba
-F src/shell.c 137f4a1e3abe9da97c32d07f78fb0d60e4764fe2
+F src/shell.c 6557e37e6c34564b72d6b98da23a88eb6ed88d59
 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
 F src/sqlite.h.in eec06462cba262c0ee03f38462a18a4bc66dda4e
 F src/sqliteInt.h 0c7474068c37a5aad715810c8190266edcbd4f4c
@@ -165,7 +165,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P acf9e9802fa6396df5653ca4e72ab4ec2333509d
-R 73d63156ebfdfb609f263f8398d35bd9
+P 92ded93376635f37e2f5a7a8f4077c85d5bce735
+R a6549a02bf88e45588d8dc89d4315963
 U drh
-Z dce4473556dffe669a617d39555a8689
+Z 2a7401700105d8209d91c7c271e81f42
index c88d352406ef9b485f74c0d7e2ffbb00493e920f..0cf1590ffa8f31e94feaf58eb5035458bad48b67 100644 (file)
@@ -1 +1 @@
-92ded93376635f37e2f5a7a8f4077c85d5bce735
\ No newline at end of file
+639957e9f793eddce027050d2655863d82fe8ac9
\ No newline at end of file
index 9c6dc9a6fc6fa5e4848f744a4717b6f3383ba2ce..fd4485c207658f59a73697686ccac040082b0f66 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains code to implement the "sqlite" command line
 ** utility for accessing SQLite databases.
 **
-** $Id: shell.c,v 1.72 2003/04/26 02:50:11 drh Exp $
+** $Id: shell.c,v 1.73 2003/04/26 03:03:07 drh Exp $
 */
 #include <stdlib.h>
 #include <string.h>
@@ -889,20 +889,6 @@ static int do_meta_command(char *zLine, sqlite *db, struct callback_data *p){
   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;
-}
-
 /*
 ** Return TRUE if the last non-whitespace character in z[] is a semicolon.
 ** z[] is N characters long.
@@ -912,6 +898,30 @@ static int _ends_with_semicolon(const char *z, int N){
   return N>0 && z[N-1]==';';
 }
 
+/*
+** Test to see if a line consists entirely of whitespace.
+*/
+static int _all_whitespace(const char *z){
+  for(; *z; z++){
+    if( isspace(*z) ) continue;
+    if( *z=='/' && z[1]=='*' ){
+      z += 2;
+      while( *z && (*z!='*' || z[1]!='/') ){ z++; }
+      if( *z==0 ) return 0;
+      z++;
+      continue;
+    }
+    if( *z=='-' && z[1]=='-' ){
+      z += 2;
+      while( *z && *z!='\n' ){ z++; }
+      if( *z==0 ) return 1;
+      continue;
+    }
+    return 0;
+  }
+  return 1;
+}
+
 /*
 ** Read input from *in and process it.  If *in==0 then input
 ** is interactive - the user is typing it it.  Otherwise, input
@@ -931,6 +941,7 @@ static void process_input(struct callback_data *p, FILE *in){
       seenInterrupt = 0;
     }
     if( p->echoOn ) printf("%s\n", zLine);
+    if( _all_whitespace(zLine) ) continue;
     if( zLine && zLine[0]=='.' && nSql==0 ){
       int rc = do_meta_command(zLine, db, p);
       free(zLine);
@@ -976,8 +987,7 @@ static void process_input(struct callback_data *p, FILE *in){
     }
   }
   if( zSql ){
-    char *zTail = skip_whitespace(zSql);
-    if( zTail && zTail[0] ) printf("Incomplete SQL: %s\n", zSql);
+    if( !_all_whitespace(zSql) ) printf("Incomplete SQL: %s\n", zSql);
     free(zSql);
   }
 }