MCPcopy Create free account
hub / github.com/coreboot/coreboot / _valid

Function _valid

payloads/libpayload/libc/string.c:318–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316*/
317
318static int _valid(char ch, int base)
319{
320 char end = (base > 9) ? '9' : '0' + (base - 1);
321
322 /* all bases will be some subset of the 0-9 range */
323
324 if (ch >= '0' && ch <= end)
325 return 1;
326
327 /* Bases > 11 will also have to match in the a-z range */
328
329 if (base > 11) {
330 if (tolower(ch) >= 'a' &&
331 tolower(ch) <= 'a' + (base - 11))
332 return 1;
333 }
334
335 return 0;
336}
337
338/* Return the "value" of the character in the given base */
339

Callers 1

strtoullFunction · 0.85

Calls 1

tolowerFunction · 0.70

Tested by

no test coverage detected