diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2003-04-01 20:27:52 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2003-04-01 20:27:52 +0400 |
commit | 31ee99a41e8050038f346ad238e0955c52fd3f92 (patch) | |
tree | 21f481aa159addaab40e6c2a36c9dc5e9972bad2 /newlib | |
parent | 1727fba007956454046c6cf7a34c9b229f10032e (diff) |
* libc/stdio/sscanf.c: Update flags description.
* libc/stdio/vfscanf.c: Add CHAR flag value to denote 8 bit target
type.
(__svfscanf_r): Add 'hh' and 'll' handling.
Diffstat (limited to 'newlib')
-rw-r--r-- | newlib/ChangeLog | 7 | ||||
-rw-r--r-- | newlib/libc/stdio/sscanf.c | 19 | ||||
-rw-r--r-- | newlib/libc/stdio/vfscanf.c | 50 |
3 files changed, 58 insertions, 18 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 2c8c547c1..14aecaa69 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,5 +1,12 @@ 2003-04-01 Corinna Vinschen <corinna@vinschen.de> + * libc/stdio/sscanf.c: Update flags description. + * libc/stdio/vfscanf.c: Add CHAR flag value to denote 8 bit target + type. + (__svfscanf_r): Add 'hh' and 'll' handling. + +2003-04-01 Corinna Vinschen <corinna@vinschen.de> + * libc/sys/cygwin/sys/dirent.h (struct DIR): Change type of __d_position member to _off_t. diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c index 7cf897c5b..9e9718118 100644 --- a/newlib/libc/stdio/sscanf.c +++ b/newlib/libc/stdio/sscanf.c @@ -152,22 +152,31 @@ DESCRIPTION .Modifier Type(s) -. h d, i, o, u, x convert input to short, +. hh d, i, o, u, x, n convert input to char, +. store in char object +. +. h d, i, o, u, x, n convert input to short, . store in short object . . h D, I, O, U, X no effect -. e, f, c, s, n, p +. e, f, c, s, p . -. l d, i, o, u, x convert input to long, +. l d, i, o, u, x, n convert input to long, . store in long object . . l e, f, g convert input to double . store in a double object . . l D, I, O, U, X no effect -. c, s, n, p +. c, s, p +. +. ll d, i, o, u, x, n convert to long long, +. store in long long +. +. L d, i, o, u, x, n convert to long long, +. store in long long . -. L d, i, o, u, x convert to long double, +. L e, f, g, E, G convert to long double, . store in long double . . L all others no effect diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index fd9ca0a62..bfb31439f 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -151,11 +151,12 @@ extern _LONG_DOUBLE _strtold _PARAMS((char *s, char **sptr)); */ #define LONG 0x01 /* l: long or double */ -#define LONGDBL 0x02 /* L: long double or long long */ +#define LONGDBL 0x02 /* L/ll: long double or long long */ #define SHORT 0x04 /* h: short */ -#define SUPPRESS 0x08 /* suppress assignment */ -#define POINTER 0x10 /* weird %p pointer (`fake hex') */ -#define NOSKIP 0x20 /* do not skip blanks */ +#define CHAR 0x08 /* hh: 8 bit integer */ +#define SUPPRESS 0x10 /* suppress assignment */ +#define POINTER 0x20 /* weird %p pointer (`fake hex') */ +#define NOSKIP 0x40 /* do not skip blanks */ /* * The following are used in numeric conversions only: @@ -163,14 +164,14 @@ extern _LONG_DOUBLE _strtold _PARAMS((char *s, char **sptr)); * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral. */ -#define SIGNOK 0x40 /* +/- is (still) legal */ -#define NDIGITS 0x80 /* no digits detected */ +#define SIGNOK 0x80 /* +/- is (still) legal */ +#define NDIGITS 0x100 /* no digits detected */ -#define DPTOK 0x100 /* (float) decimal point is still legal */ -#define EXPOK 0x200 /* (float) exponent (e+3, etc) still legal */ +#define DPTOK 0x200 /* (float) decimal point is still legal */ +#define EXPOK 0x400 /* (float) exponent (e+3, etc) still legal */ -#define PFXOK 0x100 /* 0x prefix is (still) legal */ -#define NZDIGITS 0x200 /* no zero digits detected */ +#define PFXOK 0x200 /* 0x prefix is (still) legal */ +#define NZDIGITS 0x400 /* no zero digits detected */ /* * Conversion types. @@ -262,6 +263,7 @@ __svfscanf_r (rptr, fp, fmt0, ap) mbstate_t state; /* value to keep track of multibyte state */ #endif + char *cp; short *sp; int *ip; float *flp; @@ -335,13 +337,25 @@ __svfscanf_r (rptr, fp, fmt0, ap) flags |= SUPPRESS; goto again; case 'l': - flags |= LONG; + if (*fmt == 'l') /* Check for 'll' = long long (SUSv3) */ + { + ++fmt; + flags |= LONGDBL; + } + else + flags |= LONG; goto again; case 'L': flags |= LONGDBL; goto again; case 'h': - flags |= SHORT; + if (*fmt == 'h') /* Check for 'hh' = char int (SUSv3) */ + { + ++fmt; + flags |= CHAR; + } + else + flags |= SHORT; goto again; case '0': @@ -440,7 +454,12 @@ __svfscanf_r (rptr, fp, fmt0, ap) case 'n': if (flags & SUPPRESS) /* ??? */ continue; - if (flags & SHORT) + if (flags & CHAR) + { + cp = va_arg (ap, char *); + *cp = nread; + } + else if (flags & SHORT) { sp = va_arg (ap, short *); *sp = nread; @@ -808,6 +827,11 @@ __svfscanf_r (rptr, fp, fmt0, ap) res = (*ccfn) (rptr, buf, (char **) NULL, base); if (flags & POINTER) *(va_arg (ap, _PTR *)) = (_PTR) (unsigned _POINTER_INT) res; + else if (flags & CHAR) + { + cp = va_arg (ap, char *); + *cp = res; + } else if (flags & SHORT) { sp = va_arg (ap, short *); |