/[avr-libc]/avr-libc/libc/stdio/vfscanf.c
ViewVC logotype

Diff of /avr-libc/libc/stdio/vfscanf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by joerg_wunsch, Wed Nov 9 20:45:09 2005 UTC revision 1.13 by joerg_wunsch, Wed Nov 9 21:54:33 2005 UTC
# Line 104  vfscanf(FILE *stream, const char *fmt, v Line 104  vfscanf(FILE *stream, const char *fmt, v
104          } a;          } a;
105          char    c;      /* holds a char from the format string */          char    c;      /* holds a char from the format string */
106          uint8_t base;          uint8_t base;
107          int     nconvs, i, j, olen;          int     nconvs, rv, i, j, olen;
108  #if SCANF_LEVEL > SCANF_MIN  #if SCANF_LEVEL > SCANF_MIN
109          int8_t  width;          int8_t  width;
110  #endif  #endif
# Line 118  vfscanf(FILE *stream, const char *fmt, v Line 118  vfscanf(FILE *stream, const char *fmt, v
118          flags = 0;          flags = 0;
119          nconvs = 0;          nconvs = 0;
120          i = 0;          i = 0;
121            rv = EOF;
122          olen = stream->len = 0;          olen = stream->len = 0;
123    
124          if ((stream->flags & __SRD) == 0)          if ((stream->flags & __SRD) == 0)
# Line 536  vfscanf(FILE *stream, const char *fmt, v Line 537  vfscanf(FILE *stream, const char *fmt, v
537  #if SCANF_LEVEL >= SCANF_FLT  #if SCANF_LEVEL >= SCANF_FLT
538                    nextconv:                    nextconv:
539  #endif  #endif
540                          flags = 0;                          if (stream->len > olen) {
541                          if (stream->len > olen)  #if SCANF_LEVEL >= SCANF_STD
542                                  nconvs++;                                  if (!(flags & FLSTAR))
543                          else if (c != 'n' || i == EOF)  #endif
544                                            nconvs++;
545                                    rv = 0;
546                            } else if (c != 'n' || i == EOF)
547                                  /*                                  /*
548                                   * If one conversion failed completely,                                   * If one conversion failed completely,
549                                   * punt.                                   * punt.
550                                   */                                   */
551                                  goto leave;                                  goto leave;
552                            flags = 0;
553                  } else if (c == '%') {                  } else if (c == '%') {
554                          flags = FLHASPERCENT;                          flags = FLHASPERCENT;
555                          base = 10;                          base = 10;
# Line 575  leave: Line 580  leave:
580           * or end-of-file), adjust the total number of conversions           * or end-of-file), adjust the total number of conversions
581           * done if at least one char could be read from the stream.           * done if at least one char could be read from the stream.
582           */           */
583          if ((flags & FLHASPERCENT) && stream->len > olen)          if ((flags & FLHASPERCENT) && stream->len > olen) {
584                  nconvs++;  #if SCANF_LEVEL >= SCANF_STD
585                    if (!(flags & FLSTAR))
586    #endif
587                            nconvs++;
588                    rv = 0;
589            }
590          /*          /*
591           * If an error occurs before the first successful conversion,           * If an error occurs before the first successful conversion,
592           * we ought to return EOF.  Before getting here, all           * we ought to return EOF.  Before getting here, all
593           * conversions maintain the last character read from the           * conversions maintain the last character read from the
594           * stream (or EOF) within variable `i'.           * stream (or EOF) within variable `i'.
595           */           */
596          if (nconvs == 0 && i == EOF)          if (i == EOF && nconvs == 0)
597                  nconvs = EOF;                  return rv;
598    
599          return nconvs;          return nconvs;
600  }  }

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26