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

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

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

revision 1.12 by joerg_wunsch, Tue Jan 18 16:22:04 2005 UTC revision 1.13 by joerg_wunsch, Tue Sep 6 18:49:15 2005 UTC
# Line 1  Line 1 
1  /* Copyright (c) 2002, Alexander Popov (sasho@vip.bg)  /* Copyright (c) 2002, Alexander Popov (sasho@vip.bg)
2     Copyright (c) 2002,2004 Joerg Wunsch     Copyright (c) 2002,2004,2005 Joerg Wunsch
3     Copyright (c) 2005, Helmut Wallner     Copyright (c) 2005, Helmut Wallner
4     All rights reserved.     All rights reserved.
5    
# Line 33  Line 33 
33  /* $Id$ */  /* $Id$ */
34    
35  #include <avr/pgmspace.h>  #include <avr/pgmspace.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>
# Line 121  vfprintf(FILE *stream, const char *fmt, Line 121  vfprintf(FILE *stream, const char *fmt,
121  #endif  #endif
122  #if PRINTF_LEVEL >= PRINTF_FLT  #if PRINTF_LEVEL >= PRINTF_FLT
123          int8_t  decpt;          int8_t  decpt;
124          char    *fb;    /* floating point buffer, malloc'ed */          char    fb[FLTBUFLEN];  /* floating point buffer */
125  #endif  #endif
126    
127  #if PRINTF_LEVEL < PRINTF_STD  #if PRINTF_LEVEL < PRINTF_STD
# Line 132  vfprintf(FILE *stream, const char *fmt, Line 132  vfprintf(FILE *stream, const char *fmt,
132    
133          flags = 0;          flags = 0;
134          stream->len = 0;          stream->len = 0;
 #if PRINTF_LEVEL >= PRINTF_FLT  
         fb = 0;  
 #endif  
135    
136          if ((stream->flags & __SWR) == 0)          if ((stream->flags & __SWR) == 0)
137                  return EOF;                  return EOF;
# Line 167  vfprintf(FILE *stream, const char *fmt, Line 164  vfprintf(FILE *stream, const char *fmt,
164                          } else if ((c >= 'e' && c <= 'g') ||                          } else if ((c >= 'e' && c <= 'g') ||
165                                     (c >= 'E' && c <= 'G')) {                                     (c >= 'E' && c <= 'G')) {
166                                  a.d = va_arg(ap, double);                                  a.d = va_arg(ap, double);
                                 if (fb == 0) {  
                                         if ((fb = malloc(FLTBUFLEN)) == 0)  
                                                 /*  
                                                  * No buffer for floating point  
                                                  * conversion, punt.  
                                                  */  
                                                 goto clearflags;  
                                 }  
167                                  if (!(flags & FLPREC))                                  if (!(flags & FLPREC))
168                                          prec = 6;                                          prec = 6;
169                                  /* FLPREC is used for integer formats only */                                  /* FLPREC is used for integer formats only */
# Line 559  vfprintf(FILE *stream, const char *fmt, Line 548  vfprintf(FILE *stream, const char *fmt,
548                                  putc(c, stream);                                  putc(c, stream);
549          }          }
550    
 #if PRINTF_LEVEL >= PRINTF_FLT  
         free(fb);  
 #endif  
551          return stream->len;          return stream->len;
552  }  }
553    

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