* 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.
This commit is contained in:
Corinna Vinschen 2003-04-01 16:27:52 +00:00
parent 1727fba007
commit 31ee99a41e
3 changed files with 58 additions and 18 deletions

View File

@ -1,3 +1,10 @@
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> 2003-04-01 Corinna Vinschen <corinna@vinschen.de>
* libc/sys/cygwin/sys/dirent.h (struct DIR): Change type of * libc/sys/cygwin/sys/dirent.h (struct DIR): Change type of

View File

@ -152,22 +152,31 @@ DESCRIPTION
.Modifier Type(s) .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 . store in short object
. .
. h D, I, O, U, X no effect . 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 . store in long object
. .
. l e, f, g convert input to double . l e, f, g convert input to double
. store in a double object . store in a double object
. .
. l D, I, O, U, X no effect . l D, I, O, U, X no effect
. c, s, n, p . c, s, p
. .
. L d, i, o, u, x convert to long double, . 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 e, f, g, E, G convert to long double,
. store in long double . store in long double
. .
. L all others no effect . L all others no effect

View File

@ -151,11 +151,12 @@ extern _LONG_DOUBLE _strtold _PARAMS((char *s, char **sptr));
*/ */
#define LONG 0x01 /* l: long or double */ #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 SHORT 0x04 /* h: short */
#define SUPPRESS 0x08 /* suppress assignment */ #define CHAR 0x08 /* hh: 8 bit integer */
#define POINTER 0x10 /* weird %p pointer (`fake hex') */ #define SUPPRESS 0x10 /* suppress assignment */
#define NOSKIP 0x20 /* do not skip blanks */ #define POINTER 0x20 /* weird %p pointer (`fake hex') */
#define NOSKIP 0x40 /* do not skip blanks */
/* /*
* The following are used in numeric conversions only: * 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. * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral.
*/ */
#define SIGNOK 0x40 /* +/- is (still) legal */ #define SIGNOK 0x80 /* +/- is (still) legal */
#define NDIGITS 0x80 /* no digits detected */ #define NDIGITS 0x100 /* no digits detected */
#define DPTOK 0x100 /* (float) decimal point is still legal */ #define DPTOK 0x200 /* (float) decimal point is still legal */
#define EXPOK 0x200 /* (float) exponent (e+3, etc) still legal */ #define EXPOK 0x400 /* (float) exponent (e+3, etc) still legal */
#define PFXOK 0x100 /* 0x prefix is (still) legal */ #define PFXOK 0x200 /* 0x prefix is (still) legal */
#define NZDIGITS 0x200 /* no zero digits detected */ #define NZDIGITS 0x400 /* no zero digits detected */
/* /*
* Conversion types. * Conversion types.
@ -262,6 +263,7 @@ __svfscanf_r (rptr, fp, fmt0, ap)
mbstate_t state; /* value to keep track of multibyte state */ mbstate_t state; /* value to keep track of multibyte state */
#endif #endif
char *cp;
short *sp; short *sp;
int *ip; int *ip;
float *flp; float *flp;
@ -335,13 +337,25 @@ __svfscanf_r (rptr, fp, fmt0, ap)
flags |= SUPPRESS; flags |= SUPPRESS;
goto again; goto again;
case 'l': case 'l':
flags |= LONG; if (*fmt == 'l') /* Check for 'll' = long long (SUSv3) */
{
++fmt;
flags |= LONGDBL;
}
else
flags |= LONG;
goto again; goto again;
case 'L': case 'L':
flags |= LONGDBL; flags |= LONGDBL;
goto again; goto again;
case 'h': case 'h':
flags |= SHORT; if (*fmt == 'h') /* Check for 'hh' = char int (SUSv3) */
{
++fmt;
flags |= CHAR;
}
else
flags |= SHORT;
goto again; goto again;
case '0': case '0':
@ -440,7 +454,12 @@ __svfscanf_r (rptr, fp, fmt0, ap)
case 'n': case 'n':
if (flags & SUPPRESS) /* ??? */ if (flags & SUPPRESS) /* ??? */
continue; continue;
if (flags & SHORT) if (flags & CHAR)
{
cp = va_arg (ap, char *);
*cp = nread;
}
else if (flags & SHORT)
{ {
sp = va_arg (ap, short *); sp = va_arg (ap, short *);
*sp = nread; *sp = nread;
@ -808,6 +827,11 @@ __svfscanf_r (rptr, fp, fmt0, ap)
res = (*ccfn) (rptr, buf, (char **) NULL, base); res = (*ccfn) (rptr, buf, (char **) NULL, base);
if (flags & POINTER) if (flags & POINTER)
*(va_arg (ap, _PTR *)) = (_PTR) (unsigned _POINTER_INT) res; *(va_arg (ap, _PTR *)) = (_PTR) (unsigned _POINTER_INT) res;
else if (flags & CHAR)
{
cp = va_arg (ap, char *);
*cp = res;
}
else if (flags & SHORT) else if (flags & SHORT)
{ {
sp = va_arg (ap, short *); sp = va_arg (ap, short *);