Add --if, --else, --endif processing to mptest.c.
FossilOrigin-Name: 51265acae3088a51ac0ce6ab8731e6e15a48d4ae
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
||||
C Fix\sthe\s--source\scommand\sso\sthat\sits\sargument\sis\srelative\sto\sthe\sscript.\nVerify\sthat\sthe\sSQLite\sheader\sand\slibrary\smatch.\s\sPrint\sSQLite\sversion\nand\scompile-time\sconfiguration\sinformation\son\sstartup.
|
||||
D 2013-04-06T18:35:07.098
|
||||
C Add\s--if,\s--else,\s--endif\sprocessing\sto\smptest.c.
|
||||
D 2013-04-08T13:13:43.458
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in aafa71d66bab7e87fb2f348152340645f79f0244
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -111,7 +111,7 @@ F mkopcodec.awk f6fccee29e68493bfd90a2e0466ede5fa94dd2fc
|
||||
F mkopcodeh.awk 29b84656502eee5f444c3147f331ee686956ab0e
|
||||
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
|
||||
F mptest/config01.test 058a9bc2b0db710d36003ab06dc1618566f27b52
|
||||
F mptest/mptest.c 6e23dade7b4cde4801b7a6df29f52a492d82d450
|
||||
F mptest/mptest.c b4030a7ef4a2bfd2913062d637ae3f55fb9443c2
|
||||
F mptest/multiwrite01.test aef0af17f1ce1beacd158e403a45a21008d7a70c
|
||||
F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
|
||||
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
|
||||
@@ -1047,7 +1047,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
|
||||
P fb7a7773965697855c12193408cb75300decc23c
|
||||
R 22a5a5addda1bdaa7f5e87ce6cbfc935
|
||||
P 15cb0db7583c3a24cbea0c72576047a93fba0801
|
||||
R ebe6490efbbe63db101a13263cb552f3
|
||||
U drh
|
||||
Z 9527a4645b09957de5c779d28c3eb994
|
||||
Z bd1b6a8c139e5f3d36fca35a646773b9
|
||||
|
||||
@@ -1 +1 @@
|
||||
15cb0db7583c3a24cbea0c72576047a93fba0801
|
||||
51265acae3088a51ac0ce6ab8731e6e15a48d4ae
|
||||
@@ -662,7 +662,7 @@ static int extractToken(const char *zIn, int nIn, char *zOut, int nOut){
|
||||
}
|
||||
|
||||
/*
|
||||
** Find the number of characters up to the next "--end" token.
|
||||
** Find the number of characters up to the start of the next "--end" token.
|
||||
*/
|
||||
static int findEnd(const char *z, int *pnLine){
|
||||
int n = 0;
|
||||
@@ -672,6 +672,30 @@ static int findEnd(const char *z, int *pnLine){
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
** Find the number of characters up to the first character past the
|
||||
** of the next "--endif" or "--else" token. Nested --if commands are
|
||||
** also skipped.
|
||||
*/
|
||||
static int findEndif(const char *z, int stopAtElse, int *pnLine){
|
||||
int n = 0;
|
||||
while( z[n] ){
|
||||
int len = tokenLength(z+n, pnLine);
|
||||
if( (strncmp(z+n,"--endif",7)==0 && isspace(z[n+7]))
|
||||
|| (stopAtElse && strncmp(z+n,"--else",6)==0 && isspace(z[n+6]))
|
||||
){
|
||||
return n+len;
|
||||
}
|
||||
if( strncmp(z+n,"--if",4)==0 && isspace(z[n+4]) ){
|
||||
int skip = findEndif(z+n+len, 0, pnLine);
|
||||
n += skip + len;
|
||||
}else{
|
||||
n += len;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
** Wait for a client process to complete all its tasks
|
||||
*/
|
||||
@@ -712,7 +736,7 @@ static void waitForClient(int iClient, int iTimeout, char *zErrPrefix){
|
||||
}
|
||||
|
||||
/* Maximum number of arguments to a --command */
|
||||
#define MX_ARG 5
|
||||
#define MX_ARG 2
|
||||
|
||||
/*
|
||||
** Run a script.
|
||||
@@ -791,7 +815,7 @@ static void runScript(
|
||||
}else
|
||||
|
||||
/*
|
||||
** --result
|
||||
** --reset
|
||||
**
|
||||
** Reset accumulated results back to an empty string
|
||||
*/
|
||||
@@ -852,12 +876,49 @@ static void runScript(
|
||||
logMessage("%.*s", len-jj, zScript+ii+jj);
|
||||
}else
|
||||
|
||||
/*
|
||||
** --if EXPR
|
||||
**
|
||||
** Skip forward to the next matching --endif or --else if EXPR is false.
|
||||
*/
|
||||
if( strcmp(zCmd, "if")==0 ){
|
||||
int jj, rc;
|
||||
sqlite3_stmt *pStmt;
|
||||
for(jj=4; jj<len && isspace(zScript[ii+jj]); jj++){}
|
||||
pStmt = prepareSql("SELECT %.*s", len-jj, zScript+ii+jj);
|
||||
rc = sqlite3_step(pStmt);
|
||||
if( rc!=SQLITE_ROW || sqlite3_column_int(pStmt, 0)==0 ){
|
||||
ii += findEndif(zScript+ii+len, 1, &lineno);
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
}else
|
||||
|
||||
/*
|
||||
** --else
|
||||
**
|
||||
** This command can only be encountered if currently inside an --if that
|
||||
** is true. Skip forward to the next matching --endif.
|
||||
*/
|
||||
if( strcmp(zCmd, "else")==0 ){
|
||||
ii += findEndif(zScript+ii+len, 0, &lineno);
|
||||
}else
|
||||
|
||||
/*
|
||||
** --endif
|
||||
**
|
||||
** This command can only be encountered if currently inside an --if that
|
||||
** is true or an --else of a false if. This is a no-op.
|
||||
*/
|
||||
if( strcmp(zCmd, "endif")==0 ){
|
||||
/* no-op */
|
||||
}else
|
||||
|
||||
/*
|
||||
** --start CLIENT
|
||||
**
|
||||
** Start up the given client.
|
||||
*/
|
||||
if( strcmp(zCmd, "start")==0 ){
|
||||
if( strcmp(zCmd, "start")==0 && iClient==0 ){
|
||||
int iNewClient = atoi(azArg[0]);
|
||||
if( iNewClient>0 ){
|
||||
startClient(iNewClient);
|
||||
@@ -871,7 +932,7 @@ static void runScript(
|
||||
** "all" then wait for all clients to complete. Wait no longer than
|
||||
** TIMEOUT milliseconds (default 10,000)
|
||||
*/
|
||||
if( strcmp(zCmd, "wait")==0 ){
|
||||
if( strcmp(zCmd, "wait")==0 && iClient==0 ){
|
||||
int iTimeout = nArg>=2 ? atoi(azArg[1]) : 10000;
|
||||
sqlite3_snprintf(sizeof(zError),zError,"line %d of %s\n",
|
||||
prevLine, zFilename);
|
||||
@@ -886,7 +947,7 @@ static void runScript(
|
||||
** Assign work to a client. Start the client if it is not running
|
||||
** already.
|
||||
*/
|
||||
if( strcmp(zCmd, "task")==0 ){
|
||||
if( strcmp(zCmd, "task")==0 && iClient==0 ){
|
||||
int iTarget = atoi(azArg[0]);
|
||||
int iEnd;
|
||||
char *zTask;
|
||||
|
||||
Reference in New Issue
Block a user