MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / booleanValue

Function booleanValue

modules/dasSQLITE/sqlite/shell.c:20717–20734  ·  view source on GitHub ↗

** Interpret zArg as either an integer or a boolean value. Return 1 or 0 ** for TRUE and FALSE. Return the integer value if appropriate. */

Source from the content-addressed store, hash-verified

20715** for TRUE and FALSE. Return the integer value if appropriate.
20716*/
20717static 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.

Callers 2

setOrClearFlagFunction · 0.85
do_meta_commandFunction · 0.85

Calls 3

hexDigitValueFunction · 0.85
integerValueFunction · 0.85
utf8_printfFunction · 0.85

Tested by

no test coverage detected