MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / integerValue

Function integerValue

test/sqlite/speedtest1.c:102–144  ·  view source on GitHub ↗

** Interpret zArg as an integer value, possibly with suffixes. */

Source from the content-addressed store, hash-verified

100** Interpret zArg as an integer value, possibly with suffixes.
101*/
102static int integerValue(const char *zArg){
103 sqlite3_int64 v = 0;
104 static const struct { char *zSuffix; int iMult; } aMult[] = {
105 { "KiB", 1024 },
106 { "MiB", 1024*1024 },
107 { "GiB", 1024*1024*1024 },
108 { "KB", 1000 },
109 { "MB", 1000000 },
110 { "GB", 1000000000 },
111 { "K", 1000 },
112 { "M", 1000000 },
113 { "G", 1000000000 },
114 };
115 int i;
116 int isNeg = 0;
117 if( zArg[0]=='-' ){
118 isNeg = 1;
119 zArg++;
120 }else if( zArg[0]=='+' ){
121 zArg++;
122 }
123 if( zArg[0]=='0' && zArg[1]=='x' ){
124 int x;
125 zArg += 2;
126 while( (x = hexDigitValue(zArg[0]))>=0 ){
127 v = (v<<4) + x;
128 zArg++;
129 }
130 }else{
131 while( isdigit(zArg[0]) ){
132 v = v*10 + zArg[0] - '0';
133 zArg++;
134 }
135 }
136 for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){
137 if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
138 v *= aMult[i].iMult;
139 break;
140 }
141 }
142 if( v>0x7fffffff ) fatal_error("parameter too large - max 2147483648");
143 return (int)(isNeg? -v : v);
144}
145
146/* Return the current wall-clock time, in milliseconds */
147sqlite3_int64 speedtest1_timestamp(void){

Callers 1

mainFunction · 0.85

Calls 3

hexDigitValueFunction · 0.85
fatal_errorFunction · 0.85
isdigitFunction · 0.50

Tested by

no test coverage detected