/[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.10 by joerg_wunsch, Mon Feb 14 21:47:41 2005 UTC revision 1.11 by joerg_wunsch, Tue Sep 6 18:49:15 2005 UTC
# Line 1  Line 1 
1  /* Copyright (c) 2002,2004 Joerg Wunsch  /* Copyright (c) 2002,2004,2005 Joerg Wunsch
2     All rights reserved.     All rights reserved.
3    
4     Redistribution and use in source and binary forms, with or without     Redistribution and use in source and binary forms, with or without
# Line 33  Line 33 
33    
34  #include <avr/pgmspace.h>  #include <avr/pgmspace.h>
35  #include <ctype.h>  #include <ctype.h>
36  #include <inttypes.h>  #include <stdint.h>
37  #include <limits.h>  #include <limits.h>
38  #include <stdarg.h>  #include <stdarg.h>
39  #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  
40  #include <string.h>  #include <string.h>
41    
42  #include "stdio_private.h"  #include "stdio_private.h"
# Line 89  Line 88 
88   * bit vector for %[ formats, so it must be at least 256/8 = 32 bytes   * bit vector for %[ formats, so it must be at least 256/8 = 32 bytes
89   * long.   * long.
90   */   */
91  #define FLTBUF  40  #define FLTBUF 40
92  #endif  #endif
93    
94  int  int
# Line 110  vfscanf(FILE *stream, const char *fmt, v Line 109  vfscanf(FILE *stream, const char *fmt, v
109  #endif  #endif
110          uint8_t flags;          uint8_t flags;
111  #if SCANF_LEVEL >= SCANF_FLT  #if SCANF_LEVEL >= SCANF_FLT
112          char    *buf, *bp;          char    *bp;
113          char    fltchars[] = "0123456789Ee.";          char    fltchars[] = "0123456789Ee.";
114            char    buf[FLTBUF];
115  #endif  #endif
116    
117          flags = 0;          flags = 0;
118          nconvs = 0;          nconvs = 0;
119          i = 0;          i = 0;
120          olen = stream->len = 0;          olen = stream->len = 0;
 #if SCANF_LEVEL >= SCANF_FLT  
         buf = 0;  
 #endif  
121    
122          if ((stream->flags & __SRD) == 0)          if ((stream->flags & __SRD) == 0)
123                  return EOF;                  return EOF;
# Line 213  vfscanf(FILE *stream, const char *fmt, v Line 210  vfscanf(FILE *stream, const char *fmt, v
210  #endif /* SCANF_LEVEL > SCANF_MIN */  #endif /* SCANF_LEVEL > SCANF_MIN */
211    
212                          c = tolower(c);                          c = tolower(c);
 #if SCANF_LEVEL >= SCANF_FLT  
                         if ((c == '[' || c == 'e' || c == 'f' || c == 'g') &&  
                             buf == 0) {  
                                 if ((buf = malloc(FLTBUF)) == 0)  
                                         return EOF;  
                         }  
 #endif /* SCANF_LEVEL >= SCANF_FLT */  
213    
214                          switch (c) {                          switch (c) {
215  #if SCANF_LEVEL > SCANF_MIN  #if SCANF_LEVEL > SCANF_MIN
# Line 595  leave: Line 585  leave:
585          if (nconvs == 0 && i == EOF)          if (nconvs == 0 && i == EOF)
586                  nconvs = EOF;                  nconvs = EOF;
587    
 #if SCANF_LEVEL >= SCANF_FLT  
         free(buf);  
 #endif  
588          return nconvs;          return nconvs;
589  }  }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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