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

Function scanf_impl

examples/stdlib.c:4500–4641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4498}
4499
4500static int scanf_impl(struct scanf_stream_s *in, const char *format, va_list ap)
4501{
4502 int num = 0;
4503 char c;
4504 for (; *format != '\0'; format++)
4505 {
4506 if (isspace(*format))
4507 {
4508 while (isspace(c = scanf_get_char(in)))
4509 ;
4510 scanf_unget_char(c, in);
4511 while (isspace(format[1]))
4512 format++;
4513 continue;
4514 }
4515 switch (*format)
4516 {
4517 case '%':
4518 format++;
4519 if (*format != '%')
4520 break;
4521 // Fallthrough:
4522 default:
4523 c = scanf_get_char(in);
4524 if (c != *format)
4525 {
4526 scanf_unget_char(c, in);
4527 return num;
4528 }
4529 continue;
4530 }
4531
4532 unsigned flags = 0x0;
4533 if (*format == '*')
4534 {
4535 format++;
4536 flags |= SCANF_FLAG_SUPPRESS;
4537 }
4538
4539 size_t width = 0;
4540 for (; isdigit(*format); format++)
4541 {
4542 width *= 10;
4543 width += (unsigned)(*format - '0');
4544 width = (width > INT32_MAX? INT32_MAX: width);
4545 }
4546 width = (width == 0? INT32_MAX: width);
4547
4548 switch (*format)
4549 {
4550 case 'l':
4551 flags |= SCANF_FLAG_64;
4552 format++;
4553 if (*format == 'l')
4554 format++;
4555 break;
4556 case 'h':
4557 format++;

Callers 2

vsscanfFunction · 0.85
vfscanf_unlockedFunction · 0.85

Calls 7

isspaceFunction · 0.85
scanf_get_charFunction · 0.85
scanf_unget_charFunction · 0.85
scanf_get_char_nFunction · 0.85
scanf_unget_char_nFunction · 0.85
scanf_get_numFunction · 0.85
isdigitFunction · 0.70

Tested by

no test coverage detected