| 539 | } |
| 540 | |
| 541 | int __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 |
no test coverage detected