MCPcopy Create free account
hub / github.com/GJDuck/e9patch / scanf_get_dec

Function scanf_get_dec

examples/stdlib.c:4316–4338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4314}
4315
4316static __attribute__((__noinline__)) bool scanf_get_dec(
4317 struct scanf_stream_s *in, size_t *width, uint64_t *p, bool *r)
4318{
4319 char c = scanf_get_char_n(in, width);
4320 if (!isdigit(c))
4321 {
4322 scanf_unget_char_n(c, in, width);
4323 return false;
4324 }
4325 uint64_t i = 0;
4326 do
4327 {
4328 i *= 10;
4329 uint64_t d = (c - '0');
4330 if (UINT64_MAX - i < d)
4331 *r = true;
4332 i = (UINT64_MAX - i < d? UINT64_MAX: i + d);
4333 }
4334 while (isdigit(c = scanf_get_char_n(in, width)));
4335 scanf_unget_char_n(c, in, width);
4336 *p = i;
4337 return true;
4338}
4339
4340static __attribute__((__noinline__)) bool scanf_get_oct(
4341 struct scanf_stream_s *in, size_t *width, uint64_t *p, bool *r)

Callers 1

scanf_get_numFunction · 0.85

Calls 3

scanf_get_char_nFunction · 0.85
scanf_unget_char_nFunction · 0.85
isdigitFunction · 0.70

Tested by

no test coverage detected