2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #if defined(LIBC_SCCS) && !defined(lint)
38 static char sccsid
[] = "@(#)vfscanf.c 8.1 (Berkeley) 6/4/93";
39 #endif /* LIBC_SCCS and not lint */
40 #include <sys/cdefs.h>
41 __FBSDID("$FreeBSD: src/lib/libc/stdio/vfscanf.c,v 1.37 2004/05/02 10:55:05 das Exp $");
43 #include "xlocale_private.h"
45 #include "namespace.h"
56 #include "un-namespace.h"
59 #include "libc_private.h"
62 #ifndef NO_FLOATING_POINT
66 #define BUF 513 /* Maximum length of numeric string. */
69 * Flags used during conversion.
71 #define LONG 0x01 /* l: long or double */
72 #define LONGDBL 0x02 /* L: long double */
73 #define SHORT 0x04 /* h: short */
74 #define SUPPRESS 0x08 /* *: suppress assignment */
75 #define POINTER 0x10 /* p: void * (as hex) */
76 #define NOSKIP 0x20 /* [ or c: do not skip blanks */
77 #define LONGLONG 0x400 /* ll: long long (+ deprecated q: quad) */
78 #define INTMAXT 0x800 /* j: intmax_t */
79 #define PTRDIFFT 0x1000 /* t: ptrdiff_t */
80 #define SIZET 0x2000 /* z: size_t */
81 #define SHORTSHORT 0x4000 /* hh: char */
82 #define UNSIGNED 0x8000 /* %[oupxX] conversions */
85 * The following are used in integral conversions only:
86 * SIGNOK, NDIGITS, PFXOK, and NZDIGITS
88 #define SIGNOK 0x40 /* +/- is (still) legal */
89 #define NDIGITS 0x80 /* no digits detected */
90 #define PFXOK 0x100 /* 0x prefix is (still) legal */
91 #define NZDIGITS 0x200 /* no zero digits detected */
92 #define HAVESIGN 0x10000 /* sign detected */
97 #define CT_CHAR 0 /* %c conversion */
98 #define CT_CCL 1 /* %[...] conversion */
99 #define CT_STRING 2 /* %s conversion */
100 #define CT_INT 3 /* %[dioupxX] conversion */
101 #define CT_FLOAT 4 /* %[efgEFG] conversion */
103 static const u_char
*__sccl(char *, const u_char
*, locale_t
);
104 #ifndef NO_FLOATING_POINT
105 static int parsefloat(FILE *, char **, size_t, locale_t
);
106 #endif /* !NO_FLOATING_POINT */
109 * For ppc, we need to have the 64-bit long double version defining storage for
110 * __scanfdebug, to be compatible with 10.3. For ppc64 and i386, we want the
111 * storage defined in the only version.
113 #if defined(__ppc__) && !defined(BUILDING_VARIANT)
114 extern int __scanfdebug
;
115 #else /* !__ppc__ || BUILDING_VARIANT */
116 int __scanfdebug
= 0;
117 #endif /* __ppc__ && !BUILDING_VARIANT */
119 __weak_reference(__vfscanf
, vfscanf
);
122 * __vfscanf - MT-safe version
125 __vfscanf(FILE * __restrict fp
, char const * __restrict fmt0
, va_list ap
)
130 ret
= __svfscanf_l(fp
, __current_locale(), fmt0
, ap
);
136 vfscanf_l(FILE * __restrict fp
, locale_t loc
, char const * __restrict fmt0
, va_list ap
)
140 NORMALIZE_LOCALE(loc
);
142 ret
= __svfscanf_l(fp
, loc
, fmt0
, ap
);
148 * __svfscanf - non-MT-safe version of __vfscanf
150 __private_extern__
int
151 __svfscanf_l(FILE * __restrict fp
, locale_t loc
, const char * __restrict fmt0
, va_list ap
)
153 const u_char
*fmt
= (const u_char
*)fmt0
;
154 int c
; /* character from format, or conversion */
155 size_t width
; /* field width, or 0 */
156 char *p
; /* points into all kinds of strings */
157 int n
; /* handy integer */
158 int flags
; /* flags as defined above */
159 char *p0
; /* saves original value of p when necessary */
160 int nassigned
; /* number of fields assigned */
161 int nread
; /* number of characters consumed from fp */
162 int base
; /* base argument to conversion function */
163 char ccltab
[256]; /* character class table for %[...] */
164 char buf
[BUF
]; /* buffer for numeric and mb conversions */
165 wchar_t *wcp
; /* handy wide character pointer */
166 wchar_t *wcp0
; /* saves original value of wcp */
167 size_t nconv
; /* length of multibyte sequence converted */
168 int index
; /* %index$, zero if unset */
169 va_list ap_orig
; /* to reset ap to first argument */
170 static const mbstate_t initial
;
174 /* `basefix' is used to avoid `if' tests in the integer scanner */
175 static short basefix
[17] =
176 { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
178 NORMALIZE_LOCALE(loc
);
179 mb_cur_max
= MB_CUR_MAX_L(loc
);
184 va_copy(ap_orig
, ap
);
189 if (isspace_l(c
, loc
)) {
190 while ((fp
->_r
> 0 || __srefill(fp
) == 0) && isspace_l(*fp
->_p
, loc
))
191 nread
++, fp
->_r
--, fp
->_p
++;
195 if (fp
->_r
<= 0 && __srefill(fp
))
202 * switch on the format. continue if done;
203 * break once format type is derived.
208 /* Consume leading white space */
210 if (fp
->_r
<= 0 && __srefill(fp
))
212 if (!isspace_l(*fp
->_p
, loc
))
227 if (index
< 1 || index
> NL_ARGMAX
|| fmt
[-3] != '%') {
232 va_copy(ap
, ap_orig
); /* reset to %1$ */
233 for (; index
> 1; index
--) {
251 flags
|= LONGLONG
; /* not quite */
270 case '0': case '1': case '2': case '3': case '4':
271 case '5': case '6': case '7': case '8': case '9':
272 width
= width
* 10 + c
- '0';
302 flags
|= PFXOK
; /* enable 0x prefixing */
308 #ifndef NO_FLOATING_POINT
309 case 'A': case 'E': case 'F': case 'G':
310 case 'a': case 'e': case 'f': case 'g':
323 fmt
= __sccl(ccltab
, fmt
, loc
);
336 case 'p': /* pointer format is like hex */
337 flags
|= POINTER
| PFXOK
;
338 c
= CT_INT
; /* assumes sizeof(uintmax_t) */
339 flags
|= UNSIGNED
; /* >= sizeof(uintptr_t) */
344 if (flags
& SUPPRESS
) /* ??? */
346 if (flags
& SHORTSHORT
)
347 *va_arg(ap
, char *) = nread
;
348 else if (flags
& SHORT
)
349 *va_arg(ap
, short *) = nread
;
350 else if (flags
& LONG
)
351 *va_arg(ap
, long *) = nread
;
352 else if (flags
& LONGLONG
)
353 *va_arg(ap
, long long *) = nread
;
354 else if (flags
& INTMAXT
)
355 *va_arg(ap
, intmax_t *) = nread
;
356 else if (flags
& SIZET
)
357 *va_arg(ap
, size_t *) = nread
;
358 else if (flags
& PTRDIFFT
)
359 *va_arg(ap
, ptrdiff_t *) = nread
;
361 *va_arg(ap
, int *) = nread
;
368 * Disgusting backwards compatibility hack. XXX
370 case '\0': /* compat */
375 * We have a conversion that requires input.
377 if (fp
->_r
<= 0 && __srefill(fp
))
381 * Consume leading white space, except for formats
382 * that suppress this.
384 if ((flags
& NOSKIP
) == 0) {
385 while (isspace_l(*fp
->_p
, loc
)) {
389 else if (__srefill(fp
))
393 * Note that there is at least one character in
394 * the buffer, so conversions that do not set NOSKIP
395 * ca no longer result in an input failure.
405 /* scan arbitrary characters (sets NOSKIP) */
409 if ((flags
& SUPPRESS
) == 0)
410 wcp
= va_arg(ap
, wchar_t *);
415 if (n
== mb_cur_max
) {
416 fp
->_flags
|= __SERR
;
423 nconv
= mbrtowc_l(wcp
, buf
, n
, &mbs
, loc
);
424 if (nconv
== (size_t)-1) {
425 fp
->_flags
|= __SERR
;
428 if (nconv
== 0 && !(flags
& SUPPRESS
))
430 if (nconv
!= (size_t)-2) {
433 if (!(flags
& SUPPRESS
))
437 if (fp
->_r
<= 0 && __srefill(fp
)) {
439 fp
->_flags
|= __SERR
;
445 if (!(flags
& SUPPRESS
))
447 } else if (flags
& SUPPRESS
) {
450 if ((n
= fp
->_r
) < width
) {
468 size_t r
= fread((void *)va_arg(ap
, char *), 1,
479 /* scan a (nonempty) character class (sets NOSKIP) */
481 width
= (size_t)~0; /* `infinity' */
482 /* take only those things in the class */
487 if ((flags
& SUPPRESS
) == 0)
488 wcp
= wcp0
= va_arg(ap
, wchar_t *);
494 if (n
== mb_cur_max
) {
495 fp
->_flags
|= __SERR
;
502 nconv
= mbrtowc_l(wcp
, buf
, n
, &mbs
, loc
);
503 if (nconv
== (size_t)-1) {
504 fp
->_flags
|= __SERR
;
509 if (nconv
!= (size_t)-2) {
510 if (wctob_l(*wcp
, loc
) != EOF
&&
511 !ccltab
[wctob_l(*wcp
, loc
)]) {
521 if (!(flags
& SUPPRESS
))
526 if (fp
->_r
<= 0 && __srefill(fp
)) {
528 fp
->_flags
|= __SERR
;
535 fp
->_flags
|= __SERR
;
541 if (!(flags
& SUPPRESS
)) {
545 } else if (flags
& SUPPRESS
) {
547 while (ccltab
[*fp
->_p
]) {
548 n
++, fp
->_r
--, fp
->_p
++;
551 if (fp
->_r
<= 0 && __srefill(fp
)) {
560 p0
= p
= va_arg(ap
, char *);
561 while (ccltab
[*fp
->_p
]) {
566 if (fp
->_r
<= 0 && __srefill(fp
)) {
582 /* like CCL, but zero-length string OK, & no NOSKIP */
588 if ((flags
& SUPPRESS
) == 0)
589 wcp
= va_arg(ap
, wchar_t *);
594 if (n
== mb_cur_max
) {
595 fp
->_flags
|= __SERR
;
602 nconv
= mbrtowc_l(wcp
, buf
, n
, &mbs
, loc
);
603 if (nconv
== (size_t)-1) {
604 fp
->_flags
|= __SERR
;
609 if (nconv
!= (size_t)-2) {
610 if (iswspace_l(*wcp
, loc
)) {
620 if (!(flags
& SUPPRESS
))
624 if (fp
->_r
<= 0 && __srefill(fp
)) {
626 fp
->_flags
|= __SERR
;
632 if (!(flags
& SUPPRESS
)) {
636 } else if (flags
& SUPPRESS
) {
638 while (!isspace_l(*fp
->_p
, loc
)) {
639 n
++, fp
->_r
--, fp
->_p
++;
642 if (fp
->_r
<= 0 && __srefill(fp
))
647 p0
= p
= va_arg(ap
, char *);
648 while (!isspace_l(*fp
->_p
, loc
)) {
653 if (fp
->_r
<= 0 && __srefill(fp
))
663 /* scan an integer as if by the conversion function */
665 if (width
== 0 || width
> sizeof(buf
) - 1)
666 width
= sizeof(buf
) - 1;
668 /* size_t is unsigned, hence this optimisation */
669 if (--width
> sizeof(buf
) - 2)
670 width
= sizeof(buf
) - 2;
673 flags
|= SIGNOK
| NDIGITS
| NZDIGITS
;
674 for (p
= buf
; width
; width
--) {
677 * Switch on the character; `goto ok'
678 * if we accept it as a part of number.
683 * The digit 0 is always legal, but is
684 * special. For %i conversions, if no
685 * digits (zero or nonzero) have been
686 * scanned (only signs), we will have
687 * base==0. In that case, we should set
688 * it to 8 and enable 0x prefixing.
689 * Also, if we have not scanned zero digits
690 * before this, do not turn off prefixing
691 * (someone else will turn it off if we
692 * have scanned any nonzero digits).
699 if (flags
& NZDIGITS
)
700 flags
&= ~(SIGNOK
|NZDIGITS
|NDIGITS
);
702 flags
&= ~(SIGNOK
|PFXOK
|NDIGITS
);
705 /* 1 through 7 always legal */
706 case '1': case '2': case '3':
707 case '4': case '5': case '6': case '7':
708 base
= basefix
[base
];
709 flags
&= ~(SIGNOK
| PFXOK
| NDIGITS
);
712 /* digits 8 and 9 ok iff decimal or hex */
714 base
= basefix
[base
];
716 break; /* not legal here */
717 flags
&= ~(SIGNOK
| PFXOK
| NDIGITS
);
720 /* letters ok iff hex */
721 case 'A': case 'B': case 'C':
722 case 'D': case 'E': case 'F':
723 case 'a': case 'b': case 'c':
724 case 'd': case 'e': case 'f':
725 /* no need to fix base here */
727 break; /* not legal here */
728 flags
&= ~(SIGNOK
| PFXOK
| NDIGITS
);
731 /* sign ok only as first character */
733 if (flags
& SIGNOK
) {
741 * x ok iff flag still set & 2nd char (or
742 * 3rd char if we have a sign).
745 if (flags
& PFXOK
&& p
==
746 buf
+ 1 + !!(flags
& HAVESIGN
)) {
747 base
= 16; /* if %i */
755 * If we got here, c is not a legal character
756 * for a number. Stop accumulating digits.
761 * c is legal: store it and look at the next.
766 else if (__srefill(fp
))
770 * If we had only a sign, it is no good; push
771 * back the sign. If the number ends in `x',
772 * it was [sign] '0' 'x', so push back the x
773 * and treat it as [sign] '0'.
775 if (flags
& NDIGITS
) {
777 (void) __ungetc(*(u_char
*)--p
, fp
);
780 c
= ((u_char
*)p
)[-1];
781 if (c
== 'x' || c
== 'X') {
783 (void) __ungetc(c
, fp
);
785 if ((flags
& SUPPRESS
) == 0) {
789 if ((flags
& UNSIGNED
) == 0)
790 res
= strtoimax_l(buf
, (char **)NULL
, base
, loc
);
792 res
= strtoumax_l(buf
, (char **)NULL
, base
, loc
);
794 *va_arg(ap
, void **) =
795 (void *)(uintptr_t)res
;
796 else if (flags
& SHORTSHORT
)
797 *va_arg(ap
, char *) = res
;
798 else if (flags
& SHORT
)
799 *va_arg(ap
, short *) = res
;
800 else if (flags
& LONG
)
801 *va_arg(ap
, long *) = res
;
802 else if (flags
& LONGLONG
)
803 *va_arg(ap
, long long *) = res
;
804 else if (flags
& INTMAXT
)
805 *va_arg(ap
, intmax_t *) = res
;
806 else if (flags
& PTRDIFFT
)
807 *va_arg(ap
, ptrdiff_t *) = res
;
808 else if (flags
& SIZET
)
809 *va_arg(ap
, size_t *) = res
;
811 *va_arg(ap
, int *) = res
;
817 #ifndef NO_FLOATING_POINT
821 /* scan a floating point number as if by strtod */
822 if ((width
= parsefloat(fp
, &pbuf
, width
, loc
)) == 0)
824 if ((flags
& SUPPRESS
) == 0) {
825 if (flags
& LONGDBL
) {
826 long double res
= strtold_l(pbuf
, &p
, loc
);
827 *va_arg(ap
, long double *) = res
;
828 } else if (flags
& LONG
) {
829 double res
= strtod_l(pbuf
, &p
, loc
);
830 *va_arg(ap
, double *) = res
;
832 float res
= strtof_l(pbuf
, &p
, loc
);
833 *va_arg(ap
, float *) = res
;
835 if (__scanfdebug
&& p
- pbuf
!= width
)
836 LIBC_ABORT("p - pbuf %ld != width %ld", (long)(p
- pbuf
), width
);
842 #endif /* !NO_FLOATING_POINT */
846 return (nassigned
? nassigned
: EOF
);
852 __svfscanf(FILE * __restrict fp
, const char * __restrict fmt0
, va_list ap
)
854 return __svfscanf_l(fp
, __current_locale(), fmt0
, ap
);
858 * Fill in the given table from the scanset at the given format
859 * (just after `['). Return a pointer to the character past the
860 * closing `]'. The table has a 1 wherever characters should be
861 * considered part of the scanset.
863 static const u_char
*
864 __sccl(tab
, fmt
, loc
)
871 /* first `clear' the whole table */
872 c
= *fmt
++; /* first char hat => negated scanset */
874 v
= 1; /* default => accept */
875 c
= *fmt
++; /* get new first char */
877 v
= 0; /* default => reject */
879 /* XXX: Will not work if sizeof(tab*) > sizeof(char) */
880 (void) memset(tab
, v
, 256);
883 return (fmt
- 1);/* format ended before closing ] */
886 * Now set the entries corresponding to the actual scanset
887 * to the opposite of the above.
889 * The first character may be ']' (or '-') without being special;
890 * the last character may be '-'.
894 tab
[c
] = v
; /* take character c */
896 n
= *fmt
++; /* and examine the next */
899 case 0: /* format ended too soon */
905 * A scanset of the form
907 * is defined as `the digit 0, the digit 1,
908 * the character +, the character -', but
909 * the effect of a scanset such as
911 * is implementation defined. The V7 Unix
912 * scanf treats `a-z' as `the letters a through
913 * z', but treats `a-a' as `the letter a, the
914 * character -, and the letter a'.
916 * For compatibility, the `-' is not considerd
917 * to define a range if the character following
918 * it is either a close bracket (required by ANSI)
919 * or is not numerically greater than the character
920 * we just stored in the table (c).
924 || (loc
->__collate_load_error
? n
< c
:
925 __collate_range_cmp (n
, c
, loc
) < 0
929 break; /* resume the for(;;) */
932 /* fill in the range */
933 if (loc
->__collate_load_error
) {
938 for (i
= 0; i
< 256; i
++)
939 if ( __collate_range_cmp (c
, i
, loc
) < 0
940 && __collate_range_cmp (i
, n
, loc
) <= 0
944 #if 1 /* XXX another disgusting compatibility hack */
947 * Alas, the V7 Unix scanf also treats formats
948 * such as [a-c-e] as `the letters a through e'.
949 * This too is permitted by the standard....
961 case ']': /* end of scanset */
964 default: /* just another character */
972 #ifndef NO_FLOATING_POINT
974 * Maintain a per-thread parsefloat buffer, shared by __svfscanf_l and
977 #ifdef BUILDING_VARIANT
978 extern char *__parsefloat_buf(size_t s
);
979 #else /* !BUILDING_VARIANT */
980 __private_extern__
char *
981 __parsefloat_buf(size_t s
)
984 static pthread_key_t parsefloat_tsd_key
= (pthread_key_t
)-1;
985 static pthread_mutex_t parsefloat_tsd_lock
= PTHREAD_MUTEX_INITIALIZER
;
986 static size_t bsiz
= 0;
988 if (parsefloat_tsd_key
== (pthread_key_t
)-1) {
989 pthread_mutex_lock(&parsefloat_tsd_lock
);
990 if (parsefloat_tsd_key
== (pthread_key_t
)-1) {
991 parsefloat_tsd_key
= __LIBC_PTHREAD_KEY_PARSEFLOAT
;
992 pthread_key_init_np(parsefloat_tsd_key
, free
);
994 pthread_mutex_unlock(&parsefloat_tsd_lock
);
996 if ((b
= (char *)pthread_getspecific(parsefloat_tsd_key
)) == NULL
) {
997 bsiz
= s
> BUF
? s
: BUF
;
998 b
= (char *)malloc(bsiz
);
1003 pthread_setspecific(parsefloat_tsd_key
, b
);
1007 b
= (char *)reallocf(b
, s
);
1008 pthread_setspecific(parsefloat_tsd_key
, b
);
1017 #endif /* BUILDING_VARIANT */
1020 parsefloat(FILE *fp
, char **buf
, size_t width
, locale_t loc
)
1025 S_START
, S_GOTSIGN
, S_INF
, S_NAN
, S_MAYBEHEX
,
1026 S_DIGITS
, S_FRAC
, S_EXP
, S_EXPDIGITS
, S_DECIMAL_POINT
1029 unsigned char *decpt
= (unsigned char *)localeconv_l(loc
)->decimal_point
;
1031 _Bool gotmantdig
= 0, ishex
= 0;
1036 s
= (width
== 0 ? BUF
: (width
+ 1));
1037 if ((b
= __parsefloat_buf(s
)) == NULL
) {
1043 * We set commit = p whenever the string we have read so far
1044 * constitutes a valid representation of a floating point
1045 * number by itself. At some point, the parse will complete
1046 * or fail, and we will ungetc() back to the last commit point.
1047 * To ensure that the file offset gets updated properly, it is
1048 * always necessary to read at least one character that doesn't
1049 * match; thus, we can't short-circuit "infinity" or "nan(...)".
1052 for (p
= b
; width
== 0 || p
< e
; ) {
1058 if (c
== '-' || c
== '+')
1082 if (infnanpos
> 6 ||
1083 (c
!= "nfinity"[infnanpos
] &&
1084 c
!= "NFINITY"[infnanpos
]))
1086 if (infnanpos
== 1 || infnanpos
== 6)
1087 commit
= p
; /* inf or infinity */
1091 switch (infnanpos
) {
1092 case -1: /* XXX kludge to deal with nan(...) */
1095 if (c
!= 'A' && c
!= 'a')
1099 if (c
!= 'N' && c
!= 'n')
1112 } else if (!isalnum_l(c
, loc
) && c
!= '_')
1120 if (c
== 'X' || c
== 'x') {
1123 } else { /* we saw a '0', but no 'x' */
1128 if ((ishex
&& isxdigit_l(c
, loc
)) || isdigit_l(c
, loc
))
1131 state
= S_DECIMAL_POINT
;
1138 case S_DECIMAL_POINT
:
1147 /* not decimal point */
1149 if (decpt_start
== p
)
1151 while (decpt_start
< --p
)
1152 __ungetc(*(u_char
*)p
, fp
);
1156 if (((c
== 'E' || c
== 'e') && !ishex
) ||
1157 ((c
== 'P' || c
== 'p') && ishex
)) {
1162 } else if ((ishex
&& isxdigit_l(c
, loc
)) || isdigit_l(c
, loc
)) {
1169 state
= S_EXPDIGITS
;
1170 if (c
== '-' || c
== '+')
1175 if (isdigit_l(c
, loc
))
1181 LIBC_ABORT("unknown state %d", state
);
1184 ssize_t diff
= (p
- b
);
1185 ssize_t com
= (commit
- b
);
1187 b
= __parsefloat_buf(s
);
1199 else if (__srefill(fp
))
1204 while (commit
< --p
)
1205 __ungetc(*(u_char
*)p
, fp
);
1208 return (commit
- b
);