/ Check-in [b4d94947]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Cause the command-line shell to issue an error message if you give something that does not look like a boolean value to a dot-command that wants a boolean argument.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b4d94947fc11bd63180cbc27554b3bbb60abe7ff
User & Date: drh 2013-01-28 18:18:26
Context
2013-01-28
19:00
Issue an error message and quit (rather than overflowing a reference counter) if the number of references to a table exceeds the maximum due to nested UNION views. Fix for ticket [d58ccbb3f1]. check-in: c2462a95 user: drh tags: trunk
18:18
Cause the command-line shell to issue an error message if you give something that does not look like a boolean value to a dot-command that wants a boolean argument. check-in: b4d94947 user: drh tags: trunk
2013-01-26
19:31
Add a single test case to fts4unicode.test to verify that title-case maps to lower case. check-in: 955a9459 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.

1533
1534
1535
1536
1537
1538
1539
1540
1541

1542
1543

1544
1545
1546
1547
1548
1549


1550
1551
1552
1553
1554
1555
1556
1557
  z[j] = 0;
}

/*
** Interpret zArg as a boolean value.  Return either 0 or 1.
*/
static int booleanValue(char *zArg){
  int val = atoi(zArg);
  int j;

  for(j=0; zArg[j]; j++){
    zArg[j] = ToLower(zArg[j]);

  }
  if( strcmp(zArg,"on")==0 ){
    val = 1;
  }else if( strcmp(zArg,"yes")==0 ){
    val = 1;
  }


  return val;
}

/*
** Close an output file, assuming it is not stderr or stdout
*/
static void output_file_close(FILE *f){
  if( f && f!=stdout && f!=stderr ) fclose(f);







<
|
>
|
|
>

<
|
|
<

>
>
|







1533
1534
1535
1536
1537
1538
1539

1540
1541
1542
1543
1544
1545

1546
1547

1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
  z[j] = 0;
}

/*
** Interpret zArg as a boolean value.  Return either 0 or 1.
*/
static int booleanValue(char *zArg){

  int i;
  for(i=0; zArg[i]>='0' && zArg[i]<='9'; i++){}
  if( i>0 && zArg[i]==0 ) return atoi(zArg);
  if( sqlite3_stricmp(zArg, "on")==0 || sqlite3_stricmp(zArg,"yes")==0 ){
    return 1;
  }

  if( sqlite3_stricmp(zArg, "off")==0 || sqlite3_stricmp(zArg,"no")==0 ){
    return 0;

  }
  fprintf(stderr, "ERROR: Not a boolean value: \"%s\". Assuming \"no\".\n",
          zArg);
  return 0;
}

/*
** Close an output file, assuming it is not stderr or stdout
*/
static void output_file_close(FILE *f){
  if( f && f!=stdout && f!=stderr ) fclose(f);

Changes to test/shell1.test.

216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
  catchcmd "test.db" ".explain 1"
} {0 {}}
do_test shell1-2.3.2 {
  catchcmd "test.db" ".explain on"
} {0 {}}
do_test shell1-2.3.3 {
  catchcmd "test.db" ".explain \"1 2 3\""
} {0 {}}
do_test shell1-2.3.4 {
  catchcmd "test.db" ".explain \"OFF\""
} {0 {}}
do_test shell1-2.3.5 {
  catchcmd "test.db" ".\'explain\' \'OFF\'"
} {0 {}}
do_test shell1-2.3.6 {







|







216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
  catchcmd "test.db" ".explain 1"
} {0 {}}
do_test shell1-2.3.2 {
  catchcmd "test.db" ".explain on"
} {0 {}}
do_test shell1-2.3.3 {
  catchcmd "test.db" ".explain \"1 2 3\""
} {1 {ERROR: Not a boolean value: "1 2 3". Assuming "no".}}
do_test shell1-2.3.4 {
  catchcmd "test.db" ".explain \"OFF\""
} {0 {}}
do_test shell1-2.3.5 {
  catchcmd "test.db" ".\'explain\' \'OFF\'"
} {0 {}}
do_test shell1-2.3.6 {