MCPcopy Create free account
hub / github.com/NetHack/NetHack / fscanf

Function fscanf

outdated/sys/wince/celib.c:541–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541int __cdecl fscanf(FILE *f, const char *format, ...)
542{
543 /* Format spec: %[*] [width] [l] type ] */
544 int ch;
545 int sch;
546 int matched = 0;
547 int width = 65535;
548 int modifier = -1;
549 int skip_flag = 0;
550 int n_read = 0;
551 char buf[BUFSZ];
552 TCHAR wbuf[BUFSZ];
553 char *p;
554 va_list args;
555
556#define RETURN_SCANF(i) \
557 { \
558 va_end(args); \
559 return i; \
560 }
561#define NEXT_CHAR(f) (n_read++, fgetc(f))
562
563 va_start(args, format);
564
565 ch = *format++;
566 sch = NEXT_CHAR(f);
567 while (ch && sch != EOF) {
568 if (isspace(ch)) {
569 while (ch && isspace(ch))
570 ch = *format++;
571 while (sch != EOF && isspace(sch))
572 sch = NEXT_CHAR(f);
573 format--;
574 goto next_spec;
575 }
576
577 /* read % */
578 if (ch != '%') {
579 if (sch != ch)
580 RETURN_SCANF(matched);
581 sch = NEXT_CHAR(f);
582 goto next_spec;
583 } else {
584 /* process '%%' */
585 ch = *format++;
586 if (ch == '%') {
587 if (sch != '%')
588 RETURN_SCANF(matched);
589 sch = NEXT_CHAR(f);
590 goto next_spec;
591 }
592
593 if (ch == '*') {
594 /* read skip flag - '*' */
595 skip_flag = 1;
596 ch = *format++;
597 }
598

Callers 5

copy_colormapFunction · 0.85
read_txttileFunction · 0.85
readentryFunction · 0.85
readlibdirFunction · 0.85
do_oraclesFunction · 0.85

Calls 4

isspaceFunction · 0.85
isdigitFunction · 0.85
isxdigitFunction · 0.85
fseekFunction · 0.85

Tested by

no test coverage detected