Fix the sqlite_complete() routine so that it recognizes /*...*/ comments.

Ticket #277. (CVS 937)

FossilOrigin-Name: ef8eb580fc6c40264219c2ae77a9c4f8a5803c8b
This commit is contained in:
drh 2003-04-26 02:31:54 +00:00
parent 85e2096fb6
commit 524a5bf5f6
4 changed files with 65 additions and 13 deletions

View File

@ -1,5 +1,5 @@
C Report\sthe\scorrect\sauthorization\scontext\sin\sthe\sauthorization\scallback\nwhen\scoding\san\sINSTEAD\sOF\strigger\son\san\supdate\sor\sdelete.\s(CVS\s936)
D 2003-04-25T17:52:11
C Fix\sthe\ssqlite_complete()\sroutine\sso\sthat\sit\srecognizes\s/*...*/\scomments.\nTicket\s#277.\s(CVS\s937)
D 2003-04-26T02:31:54
F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@ -33,7 +33,7 @@ F src/func.c 882c3ed5a02be18cd904715c7ec62947a34a3605
F src/hash.c 4fc39feb7b7711f6495ee9f2159559bedb043e1f
F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
F src/insert.c 19882be1edc4b1629b8f3097e2615164f2c9cecb
F src/main.c 5e4d4d081d82840a743c57269ca3c32640cefc06
F src/main.c 6763d9a5556b7ac04aad3819699331df9172f029
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
F src/os.c e56853eaea5dab258ab1ccb77b4743b453516e3a
F src/os.h 9e5bbddff123187295e3d00d49af06192cd1cd49
@ -90,7 +90,7 @@ F test/ioerr.test 5dbaf09f96b56ee01cf3edd762b96eb4ad2c9ca4
F test/join.test c97267c19294bf1fa4e81087edad179828bced88
F test/limit.test 9ffb965a0f5bf7152187ef3d8d1249b96e5620bf
F test/lock.test 388a3a10962d2d571c0c1821cc35bf069ee73473
F test/main.test 8108ac48302027bbe4296c30b913adbe6d5d984b
F test/main.test a028743affca67670e24c97527d1f4ad4bc2aad3
F test/malloc.test 7ba32a9ebd3aeed52ae4aaa6d42ca37e444536fd
F test/memdb.test 4494051bcf72df58d9c631a5bc1260cba2b021cc
F test/memleak.test a18e6810cae96d2f6f5136920267adbefc8e1e90
@ -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 8d3e879349fc9523c72cb46111e0058b57ce9341
R fbd9cacc0c39e890456b02e579584ea3
P 67746833fc8de3afff80db413bd63a362bb28218
R b3e3bfe8164620c4480a4b87336b23e6
U drh
Z d170dde2366e1aeda159869f0f0e19bb
Z 0c48e13a3396dc7d9213cbebb3486c16

View File

@ -1 +1 @@
67746833fc8de3afff80db413bd63a362bb28218
ef8eb580fc6c40264219c2ae77a9c4f8a5803c8b

View File

@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.127 2003/04/23 12:25:24 drh Exp $
** $Id: main.c,v 1.128 2003/04/26 02:31:54 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@ -599,6 +599,19 @@ int sqlite_complete(const char *zSql){
if( *zSql==0 ) return 0;
break;
}
case '/': {
if( zSql[1]!='*' ){
isComplete = 0;
seenText = 1;
seenCreate = 0;
break;
}
zSql += 2;
while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }
if( zSql[0]==0 ) return 0;
zSql += 2;
break;
}
case '-': {
if( zSql[1]!='-' ){
isComplete = 0;
@ -662,7 +675,7 @@ int sqlite_complete(const char *zSql){
}
zSql++;
}
return seenText && isComplete && requireEnd==0;
return /* seenText && */ isComplete && requireEnd==0;
}
/*

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is exercising the code in main.c.
#
# $Id: main.test,v 1.12 2003/04/16 02:17:36 drh Exp $
# $Id: main.test,v 1.13 2003/04/26 02:31:54 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -24,12 +24,12 @@ do_test main-1.1 {
do_test main-1.2 {
db complete {
}
} {0}
} {1}
do_test main-1.3 {
db complete {
-- a comment ;
}
} {0}
} {1}
do_test main-1.4 {
db complete {
-- a comment ;
@ -158,6 +158,45 @@ do_test main-1.29 {
EXPLAIN select * from xyz;
}
} {0}
do_test main-1.30 {
db complete {
CREATE TABLE /* In comment ; */
}
} {0}
do_test main-1.31 {
db complete {
CREATE TABLE /* In comment ; */ hi;
}
} {1}
do_test main-1.32 {
db complete {
stuff;
/*
CREATE TABLE
multiple lines
of text
*/
}
} {1}
do_test main-1.33 {
db complete {
/*
CREATE TABLE
multiple lines
of text;
}
} {0}
do_test main-1.34 {
db complete {
/*
CREATE TABLE
multiple lines "*/
of text;
}
} {1}
do_test main-1.35 {
db complete {hi /**/ there;}
} {1}
# Try to open a database with a corrupt database file.