/ 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 Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  1533   1533     z[j] = 0;
  1534   1534   }
  1535   1535   
  1536   1536   /*
  1537   1537   ** Interpret zArg as a boolean value.  Return either 0 or 1.
  1538   1538   */
  1539   1539   static int booleanValue(char *zArg){
  1540         -  int val = atoi(zArg);
  1541         -  int j;
  1542         -  for(j=0; zArg[j]; j++){
  1543         -    zArg[j] = ToLower(zArg[j]);
         1540  +  int i;
         1541  +  for(i=0; zArg[i]>='0' && zArg[i]<='9'; i++){}
         1542  +  if( i>0 && zArg[i]==0 ) return atoi(zArg);
         1543  +  if( sqlite3_stricmp(zArg, "on")==0 || sqlite3_stricmp(zArg,"yes")==0 ){
         1544  +    return 1;
  1544   1545     }
  1545         -  if( strcmp(zArg,"on")==0 ){
  1546         -    val = 1;
  1547         -  }else if( strcmp(zArg,"yes")==0 ){
  1548         -    val = 1;
         1546  +  if( sqlite3_stricmp(zArg, "off")==0 || sqlite3_stricmp(zArg,"no")==0 ){
         1547  +    return 0;
  1549   1548     }
  1550         -  return val;
         1549  +  fprintf(stderr, "ERROR: Not a boolean value: \"%s\". Assuming \"no\".\n",
         1550  +          zArg);
         1551  +  return 0;
  1551   1552   }
  1552   1553   
  1553   1554   /*
  1554   1555   ** Close an output file, assuming it is not stderr or stdout
  1555   1556   */
  1556   1557   static void output_file_close(FILE *f){
  1557   1558     if( f && f!=stdout && f!=stderr ) fclose(f);

Changes to test/shell1.test.

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