| 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 |
| 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" |
| 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 |
| 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; |
| 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 |
| 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 |
} |
} |