** Interpret zArg as either an integer or a boolean value. Return 1 or 0 ** for TRUE and FALSE. Return the integer value if appropriate. */
| 20715 | ** for TRUE and FALSE. Return the integer value if appropriate. |
| 20716 | */ |
| 20717 | static int booleanValue(const char *zArg){ |
| 20718 | int i; |
| 20719 | if( zArg[0]=='0' && zArg[1]=='x' ){ |
| 20720 | for(i=2; hexDigitValue(zArg[i])>=0; i++){} |
| 20721 | }else{ |
| 20722 | for(i=0; zArg[i]>='0' && zArg[i]<='9'; i++){} |
| 20723 | } |
| 20724 | if( i>0 && zArg[i]==0 ) return (int)(integerValue(zArg) & 0xffffffff); |
| 20725 | if( sqlite3_stricmp(zArg, "on")==0 || sqlite3_stricmp(zArg,"yes")==0 ){ |
| 20726 | return 1; |
| 20727 | } |
| 20728 | if( sqlite3_stricmp(zArg, "off")==0 || sqlite3_stricmp(zArg,"no")==0 ){ |
| 20729 | return 0; |
| 20730 | } |
| 20731 | utf8_printf(stderr, "ERROR: Not a boolean value: \"%s\". Assuming \"no\".\n", |
| 20732 | zArg); |
| 20733 | return 0; |
| 20734 | } |
| 20735 | |
| 20736 | /* |
| 20737 | ** Set or clear a shell flag according to a boolean value. |
no test coverage detected