Lines Matching +full:end +full:- +full:of +full:- +full:conversion
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
5 * The Regents of the University of California. All rights reserved.
12 * Copyright (c) 2023 Dag-Erling Smørgrav
14 * Portions of this software were developed by David Chisnall
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
23 * notice, this list of conditions and the following disclaimer in the
25 * 3. Neither the name of the University nor the names of its contributors
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 #include "un-namespace.h"
59 #define BUF 513 /* Maximum length of numeric string. */
62 * Flags used during conversion.
79 * Conversion types.
81 #define CT_CHAR 0 /* %c conversion */
82 #define CT_CCL 1 /* %[...] conversion */
83 #define CT_STRING 2 /* %s conversion */
84 #define CT_INT 3 /* %[dioupxX] conversion */
85 #define CT_FLOAT 4 /* %[efgEFG] conversion */
93 const wchar_t *end; /* character class end */ member
101 if (ccl->compl) { in inccl()
102 return (wmemchr(ccl->start, wi, ccl->end - ccl->start) in inccl()
105 return (wmemchr(ccl->start, wi, ccl->end - ccl->start) != NULL); in inccl()
110 * Conversion functions are passed a pointer to this object instead of
111 * a real parameter to indicate that the assignment-suppression (*)
122 * The following conversion functions return the number of characters consumed,
123 * or -1 on input failure. Character class conversion returns 0 on match
137 while (width-- != 0 && (wi = __fgetwc(fp, locale)) != WEOF) { in convert_char()
140 if (nconv == (size_t)-1) in convert_char()
141 return (-1); in convert_char()
147 return (-1); in convert_char()
158 while (width-- != 0 && (wi = __fgetwc(fp, locale)) != WEOF) { in convert_wchar()
164 return (-1); in convert_wchar()
180 width-- != 0 && inccl(ccl, wi)) { in convert_ccl()
183 if (nconv == (size_t)-1) in convert_ccl()
184 return (-1); in convert_ccl()
207 width-- != 0 && inccl(ccl, wi)) in convert_wccl()
214 width-- != 0 && inccl(ccl, wi)) in convert_wccl()
218 n = wcp - wcp0; in convert_wccl()
236 while ((wi = __fgetwc(fp, locale)) != WEOF && width-- != 0 && in convert_string()
240 if (nconv == (size_t)-1) in convert_string()
241 return (-1); in convert_string()
262 width-- != 0 && !iswspace(wi)) in convert_wstring()
268 width-- != 0 && !iswspace(wi)) { in convert_wstring()
292 case '-': in parseint_fsm()
329 if (*base > c - '0') { in parseint_fsm()
354 if (*base > c - 'a' + 10) { in parseint_fsm()
379 if (*base > c - 'A' + 10) { in parseint_fsm()
402 * Return 0 on a match failure, and the number of characters read
413 for (wcp = buf; width; width--) { in parseint()
425 * because we read a non-number character, push it back. in parseint()
428 wcp--; in parseint()
431 wcp--; in parseint()
436 return (wcp - buf); in parseint()
440 * MT-safe version.
462 * Non-MT-safe version.
469 wint_t c; /* character from format, or conversion */ in __vfwscanf()
472 int nassigned; /* number of fields assigned */ in __vfwscanf()
473 int nconversions; /* number of conversions */ in __vfwscanf()
474 int nr; /* characters read by the current conversion */ in __vfwscanf()
475 int nread; /* number of characters consumed from fp */ in __vfwscanf()
476 int base; /* base argument to conversion function */ in __vfwscanf()
484 ccl.start = ccl.end = NULL; in __vfwscanf()
539 * Fixed-width integer types. On all platforms we in __vfwscanf()
592 width = width * 10 + c - '0'; in __vfwscanf()
659 ccl.end = fmt; in __vfwscanf()
724 * Do the conversion. in __vfwscanf()
764 /* like CCL, but zero-length string OK, & no NOSKIP */ in __vfwscanf()
779 /* scan an integer as if by the conversion function */ in __vfwscanf()
781 sizeof(*buf) - 1) in __vfwscanf()
782 width = sizeof(buf) / sizeof(*buf) - 1; in __vfwscanf()
821 sizeof(*buf) - 1) in __vfwscanf()
822 width = sizeof(buf) / sizeof(*buf) - 1; in __vfwscanf()
854 parsefloat(FILE *fp, wchar_t *buf, wchar_t *end, locale_t locale) in parsefloat() argument
869 nconv = mbrtowc(&decpt, localeconv()->decimal_point, MB_CUR_MAX, &mbs); in parsefloat()
870 if (nconv == (size_t)-1 || nconv == (size_t)-2) in parsefloat()
875 * constitutes a valid representation of a floating point in parsefloat()
880 * match; thus, we can't short-circuit "infinity" or "nan(...)". in parsefloat()
882 commit = buf - 1; in parsefloat()
884 for (p = buf; p < end; ) { in parsefloat()
891 if (c == '-' || c == '+') in parsefloat()
986 if (c == '-' || c == '+') in parsefloat()
1006 while (commit < --p) in parsefloat()
1009 return (commit - buf); in parsefloat()