MCPcopy Create free account
hub / github.com/DFHack/dfhack / getnum

Function getnum

depends/lua/src/lstrlib.c:1182–1192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1180static int digit (int c) { return '0' <= c && c <= '9'; }
1181
1182static int getnum (const char **fmt, int df) {
1183 if (!digit(**fmt)) /* no number? */
1184 return df; /* return default value */
1185 else {
1186 int a = 0;
1187 do {
1188 a = a*10 + (*((*fmt)++) - '0');
1189 } while (digit(**fmt) && a <= ((int)MAXSIZE - 9)/10);
1190 return a;
1191 }
1192}
1193
1194
1195/*

Callers 2

getnumlimitFunction · 0.85
getoptionFunction · 0.85

Calls 1

digitFunction · 0.85

Tested by

no test coverage detected