diff options
Diffstat (limited to 'libc/stdio/_scanf.c')
-rw-r--r-- | libc/stdio/_scanf.c | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c index 2957d6748..cb768cffb 100644 --- a/libc/stdio/_scanf.c +++ b/libc/stdio/_scanf.c @@ -77,10 +77,10 @@ #include <bits/uClibc_fpmax.h> #endif /* __UCLIBC_HAS_FLOATS__ */ -libc_hidden_proto(memcmp) -libc_hidden_proto(memset) -libc_hidden_proto(strcpy) -libc_hidden_proto(strlen) +/* Experimentally off - libc_hidden_proto(memcmp) */ +/* Experimentally off - libc_hidden_proto(memset) */ +/* Experimentally off - libc_hidden_proto(strcpy) */ +/* Experimentally off - libc_hidden_proto(strlen) */ libc_hidden_proto(ungetc) libc_hidden_proto(vfscanf) libc_hidden_proto(vsscanf) @@ -100,7 +100,7 @@ libc_hidden_proto(fgetwc_unlocked) #endif #ifdef __UCLIBC_HAS_XLOCALE__ libc_hidden_proto(__ctype_b_loc) -#elif __UCLIBC_HAS_CTYPE_TABLES__ +#elif defined __UCLIBC_HAS_CTYPE_TABLES__ libc_hidden_proto(__ctype_b) #endif @@ -265,17 +265,13 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap) #ifdef __UCLIBC_HAS_THREADS__ f.__user_locking = 1; /* Set user locking. */ -#ifdef __USE_STDIO_FUTEXES__ - _IO_lock_init (f._lock); -#else - __stdio_init_mutex(&f.__lock); -#endif + STDIO_INIT_MUTEX(f.__lock); #endif f.__nextopen = NULL; /* Set these last since __bufgetc initialization depends on * __user_locking and only gets set if user locking is on. */ - f.__bufstart = + f.__bufstart = f.__bufpos = (unsigned char *) ((void *) sp); f.__bufread = f.__bufend = f.__bufstart + strlen(sp); @@ -317,11 +313,7 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap) #ifdef __UCLIBC_HAS_THREADS__ f.f.__user_locking = 1; /* Set user locking. */ -#ifdef __USE_STDIO_FUTEXES__ - _IO_lock_init (f.f._lock); -#else - __stdio_init_mutex(&f.f.__lock); -#endif + STDIO_INIT_MUTEX(f.f.__lock); #endif f.f.__nextopen = NULL; @@ -454,11 +446,7 @@ int vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict format, #ifdef __UCLIBC_HAS_THREADS__ f.__user_locking = 1; /* Set user locking. */ -#ifdef __USE_STDIO_FUTEXES__ - _IO_lock_init (f._lock); -#else - __stdio_init_mutex(&f.__lock); -#endif + STDIO_INIT_MUTEX(f.__lock); #endif f.__nextopen = NULL; @@ -518,7 +506,7 @@ enum { FLAG_THOUSANDS = 0x20, FLAG_I18N = 0x40, /* only works for d, i, u */ FLAG_MALLOC = 0x80, /* only works for s, S, and [ (and l[)*/ -}; +}; #define SPEC_RANGES { CONV_n, CONV_p, CONV_i, CONV_A, \ @@ -743,7 +731,7 @@ void attribute_hidden __init_scan_cookie(register struct scan_cookie *sc, sc->decpt = __UCLIBC_CURLOCALE_DATA.decimal_point; sc->decpt_len = __UCLIBC_CURLOCALE_DATA.decimal_point_len; #else /* __UCLIBC_HAS_LOCALE__ */ - sc->fake_decpt = sc->decpt = decpt_str; + sc->fake_decpt = sc->decpt = (unsigned char *) decpt_str; sc->decpt_len = 1; #endif /* __UCLIBC_HAS_LOCALE__ */ #ifdef __UCLIBC_HAS_WCHAR__ @@ -1036,7 +1024,7 @@ static int scan_getwc(register struct scan_cookie *sc) __set_errno(EILSEQ); /* In case of incomplete conversion. */ sc->mb_fail = 1; } - + SUCCESS: sc->width = width; /* Restore width. */ @@ -1080,9 +1068,6 @@ static int sc_getc(register struct scan_cookie *sc) wc = '.'; } else #endif /* __UCLIBC_HAS_FLOATS__ */ - if (!__isascii(wc)) { - wc = '?'; - } sc->wc = sc->ungot_char = wc; return (int) wc; @@ -1378,7 +1363,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) if (psfs.conv_num == CONV_percent) { goto MATCH_CHAR; - } + } if (psfs.conv_num == CONV_n) { #ifdef __UCLIBC_MJN3_ONLY__ @@ -1422,7 +1407,6 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) { b = (psfs.store ? ((unsigned char *) psfs.cur_ptr) : buf); fail = 1; - if (psfs.conv_num == CONV_c) { if (sc.width == INT_MAX) { @@ -1463,7 +1447,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) if (*++fmt == '^') { ++fmt; invert = 1; - } + } memset(scanset, invert, sizeof(scanset)); invert = 1-invert; @@ -1531,7 +1515,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg) wb = (psfs.store ? ((wchar_t *) psfs.cur_ptr) : wbuf); fail = 1; - + if (psfs.conv_num == CONV_C) { if (sc.width == INT_MAX) { sc.width = 1; @@ -1808,7 +1792,6 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc) unsigned char usflag, base; unsigned char nonzero = 0; unsigned char seendigit = 0; - #ifdef __UCLIBC_MJN3_ONLY__ #warning CONSIDER: What should be returned for an invalid conversion specifier? @@ -1840,7 +1823,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc) if (psfs->store) { ++psfs->cnt; _store_inttype(psfs->cur_ptr, psfs->dataargtype, - (uintmax_t) NULL); + (uintmax_t)0); } return 0; } @@ -2101,7 +2084,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc) } ++psfs->cnt; _store_inttype(psfs->cur_ptr, psfs->dataargtype, - (uintmax_t) STRTOUIM(buf, NULL, base, 1-usflag)); + (uintmax_t) STRTOUIM((char *) buf, NULL, base, 1-usflag)); } return 0; } @@ -2115,7 +2098,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc) p = sc->fake_decpt; do { if (!*p) { - strcpy(b, sc->decpt); + strcpy((char *) b, (char *) sc->decpt); b += sc->decpt_len; break; } @@ -2222,7 +2205,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc) assert(seendigit); seendigit = 0; nonzero = 0; - + if (sc->cc == '0') { seendigit = 1; *b++ = '0'; @@ -2238,7 +2221,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc) } __scan_getc(sc); } - + if (!seendigit) { /* No digits. Unrecoverable. */ goto DONE_DO_UNGET; } @@ -2250,7 +2233,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc) { __fpmax_t x; char *e; - x = __strtofpmax(buf, &e, exp_adjust); + x = __strtofpmax((char *) buf, &e, exp_adjust); assert(!*e); if (psfs->store) { if (psfs->dataargtype & PA_FLAG_LONG_LONG) { |