| 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 |
|
|
| 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> |
| 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 |
| 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; |
| 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 */ |
| 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 |
|
|