summaryrefslogtreecommitdiffstats
path: root/libc/stdio
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdio')
-rw-r--r--libc/stdio/_scanf.c35
-rw-r--r--libc/stdio/_vfprintf.c15
-rw-r--r--libc/stdio/_wfwrite.c4
-rw-r--r--libc/stdio/fgetwc.c8
-rw-r--r--libc/stdio/vswprintf.c6
5 files changed, 30 insertions, 38 deletions
diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c
index da13f1fb2..003cd2469 100644
--- a/libc/stdio/_scanf.c
+++ b/libc/stdio/_scanf.c
@@ -586,13 +586,15 @@ enum {
#define QUAL_CHARS { \
/* j:(u)intmax_t z:(s)size_t t:ptrdiff_t \0:int q:long_long */ \
'h', 'l', 'L', 'j', 'z', 't', 'q', 0, \
- 2, 4, 8, IMS, SS, PDS, 8, 0, /* TODO -- fix!!! */\
- 1, 8 }
+ 2, 4, 8, IMS, SS, PDS, 8, 0, /* TODO -- fix!!! */ \
+ 1, 8 \
+}
/**********************************************************************/
#ifdef L_vfwscanf
+/* FIXME: "warning: the right operand of ">" changes sign when promoted" */
#if WINT_MIN > EOF
#error Unfortunately, we currently need wint_t to be able to store EOF. Sorry.
#endif
@@ -718,7 +720,7 @@ void attribute_hidden __init_scan_cookie(register struct scan_cookie *sc,
#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
if (*(sc->grouping = __UCLIBC_CURLOCALE_DATA.grouping)) {
- sc->thousands_sep = __UCLIBC_CURLOCALE_DATA.thousands_sep;
+ sc->thousands_sep = (const unsigned char *) __UCLIBC_CURLOCALE_DATA.thousands_sep;
sc->tslen = __UCLIBC_CURLOCALE_DATA.thousands_sep_len;
#ifdef __UCLIBC_HAS_WCHAR__
sc->thousands_sep_wc = __UCLIBC_CURLOCALE_DATA.thousands_sep_wc;
@@ -728,7 +730,7 @@ void attribute_hidden __init_scan_cookie(register struct scan_cookie *sc,
#ifdef __UCLIBC_HAS_FLOATS__
#ifdef __UCLIBC_HAS_LOCALE__
- sc->decpt = __UCLIBC_CURLOCALE_DATA.decimal_point;
+ sc->decpt = (const unsigned char *) __UCLIBC_CURLOCALE_DATA.decimal_point;
sc->decpt_len = __UCLIBC_CURLOCALE_DATA.decimal_point_len;
#else /* __UCLIBC_HAS_LOCALE__ */
sc->fake_decpt = sc->decpt = (unsigned char *) decpt_str;
@@ -1154,22 +1156,12 @@ static __inline void kill_scan_cookie(register struct scan_cookie *sc)
#endif
}
-#ifdef L_vfwscanf
-#ifdef __UCLIBC_HAS_FLOATS__
-static const char fake_decpt_str[] = ".";
-#endif
-#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
-static const char fake_thousands_sep_str[] = ",";
-#endif
-#endif /* L_vfwscanf */
-
int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
{
const Wuchar *fmt;
unsigned char *b;
-
#ifdef L_vfwscanf
wchar_t wbuf[1];
wchar_t *wb;
@@ -1181,7 +1173,6 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
struct scan_cookie sc;
psfs_t psfs;
-
int i;
#ifdef __UCLIBC_MJN3_ONLY__
@@ -1233,13 +1224,13 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
if (*sc.grouping) {
- sc.thousands_sep = fake_thousands_sep_str;
+ sc.thousands_sep = (const unsigned char *) ",";
sc.tslen = 1;
}
#endif /* __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ */
#ifdef __UCLIBC_HAS_FLOATS__
- sc.fake_decpt = fake_decpt_str;
+ sc.fake_decpt = (const unsigned char *) ".";
#endif /* __UCLIBC_HAS_FLOATS__ */
#else /* L_vfwscanf */
@@ -1607,7 +1598,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
*wb = sc.wc;
wb += psfs.store;
} else {
- i = wcrtomb(b, sc.wc, &mbstate);
+ i = wcrtomb((char*) b, sc.wc, &mbstate);
if (i < 0) { /* Conversion failure. */
goto DONE_DO_UNGET;
}
@@ -1635,7 +1626,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
*wb = sc.wc;
wb += psfs.store;
} else {
- i = wcrtomb(b, sc.wc, &mbstate);
+ i = wcrtomb((char*) b, sc.wc, &mbstate);
if (i < 0) { /* Conversion failure. */
goto DONE_DO_UNGET;
}
@@ -1709,7 +1700,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
*wb = sc.wc;
wb += psfs.store;
} else {
- i = wcrtomb(b, sc.wc, &mbstate);
+ i = wcrtomb((char*) b, sc.wc, &mbstate);
if (i < 0) { /* Conversion failure. */
goto DONE_DO_UNGET;
}
@@ -1882,7 +1873,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc)
#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
if ((psfs->flags & FLAG_THOUSANDS) && (base == 10)
- && *(p = sc->grouping)
+ && *(p = (const unsigned char *) sc->grouping)
) {
int nblk1, nblk2, nbmax, lastblock, pass, i;
@@ -2004,7 +1995,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc)
p = sc->fake_decpt + k;
do {
if (!*++p) {
- strcpy(b, sc->decpt);
+ strcpy((char*) b, (char*) sc->decpt);
b += sc->decpt_len;
goto GOT_DECPT;
}
diff --git a/libc/stdio/_vfprintf.c b/libc/stdio/_vfprintf.c
index 5ce3f8a59..850c83486 100644
--- a/libc/stdio/_vfprintf.c
+++ b/libc/stdio/_vfprintf.c
@@ -1214,7 +1214,7 @@ static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad);
#define _PPFS_init _ppfs_init
#define OUTPUT(F,S) fputs_unlocked(S,F)
/* #define _outnstr(stream, string, len) __stdio_fwrite(string, len, stream) */
-#define _outnstr(stream, string, len) ((len > 0) ? __stdio_fwrite(string, len, stream) : 0)
+#define _outnstr(stream, string, len) ((len > 0) ? __stdio_fwrite((const unsigned char *)(string), len, stream) : 0)
#define FP_OUT _fp_out_narrow
#ifdef __STDIO_PRINTF_FLOAT
@@ -1232,7 +1232,7 @@ static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf
}
len = buflen;
}
- return r + OUTNSTR(fp, (const unsigned char *) buf, len);
+ return r + OUTNSTR(fp, (const char *) buf, len);
}
#endif /* __STDIO_PRINTF_FLOAT */
@@ -1247,7 +1247,7 @@ static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf
/* Pulls in fseek: */
#define OUTPUT(F,S) fputws(S,F)
/* TODO: #define OUTPUT(F,S) _wstdio_fwrite((S),wcslen(S),(F)) */
-#define _outnwcs(stream, wstring, len) _wstdio_fwrite(wstring, len, stream)
+#define _outnwcs(stream, wstring, len) _wstdio_fwrite((const wchar_t *)(wstring), len, stream)
#define FP_OUT _fp_out_wide
static size_t _outnstr(FILE *stream, const char *s, size_t wclen)
@@ -1428,7 +1428,7 @@ static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad)
FMT_TYPE pad[1];
*pad = padchar;
- while (todo && (OUTNSTR(stream, (const unsigned char *) pad, 1) == 1)) {
+ while (todo && (OUTNSTR(stream, (const char *) pad, 1) == 1)) {
--todo;
}
@@ -1874,7 +1874,7 @@ int VFPRINTF_internal (FILE * __restrict stream,
s = format;
if (_PPFS_init(&ppfs, format) < 0) { /* Bad format string. */
- OUTNSTR(stream, (const unsigned char *) ppfs.fmtpos,
+ OUTNSTR(stream, (const char *) ppfs.fmtpos,
STRLEN((const FMT_TYPE *)(ppfs.fmtpos)));
#if defined(L__vfprintf_internal) && !defined(NDEBUG)
fprintf(stderr,"\nIMbS: \"%s\"\n\n", format);
@@ -1888,8 +1888,9 @@ int VFPRINTF_internal (FILE * __restrict stream,
++format;
}
- if (format-s) { /* output any literal text in format string */
- if ( (r = OUTNSTR(stream, (const unsigned char *) s, format-s)) != (format-s)) {
+ if (format - s) { /* output any literal text in format string */
+ r = OUTNSTR(stream, (const char *) s, format - s);
+ if (r != (format - s)) {
count = -1;
break;
}
diff --git a/libc/stdio/_wfwrite.c b/libc/stdio/_wfwrite.c
index 8fa59f87d..81f5bd4e8 100644
--- a/libc/stdio/_wfwrite.c
+++ b/libc/stdio/_wfwrite.c
@@ -38,7 +38,7 @@ size_t attribute_hidden _wstdio_fwrite(const wchar_t *__restrict ws, size_t n,
}
if (count) {
wmemcpy((wchar_t *)(stream->__bufpos), ws, count);
- stream->__bufpos = (char *)(((wchar_t *)(stream->__bufpos)) + count);
+ stream->__bufpos = (unsigned char *)(((wchar_t *)(stream->__bufpos)) + count);
}
__STDIO_STREAM_VALIDATE(stream);
return n;
@@ -59,7 +59,7 @@ size_t attribute_hidden _wstdio_fwrite(const wchar_t *__restrict ws, size_t n,
++r; /* 0 is returned when nul is reached. */
pw = ws + count + r; /* pw was set to NULL, so correct. */
}
- if (__stdio_fwrite(buf, r, stream) == r) {
+ if (__stdio_fwrite((const unsigned char *)buf, r, stream) == r) {
count = pw - ws;
continue;
}
diff --git a/libc/stdio/fgetwc.c b/libc/stdio/fgetwc.c
index 34327434c..18a6b5bb5 100644
--- a/libc/stdio/fgetwc.c
+++ b/libc/stdio/fgetwc.c
@@ -58,12 +58,12 @@ wint_t fgetwc_unlocked(register FILE *stream)
stream->__ungot_width[0] = 0; /* then reset the width. */
}
- LOOP:
+ LOOP:
if ((n = __STDIO_STREAM_BUFFER_RAVAIL(stream)) == 0) {
goto FILL_BUFFER;
}
- r = mbrtowc(wc, stream->__bufpos, n, &stream->__state);
+ r = mbrtowc(wc, (const char*) stream->__bufpos, n, &stream->__state);
if (((ssize_t) r) >= 0) { /* Success... */
if (r == 0) { /* Nul wide char... means 0 byte for us so */
++r; /* increment r and handle below as single. */
@@ -78,7 +78,7 @@ wint_t fgetwc_unlocked(register FILE *stream)
/* Potentially valid but incomplete and no more buffered. */
stream->__bufpos += n; /* Update bufpos for stream. */
stream->__ungot_width[0] += n;
- FILL_BUFFER:
+ FILL_BUFFER:
if(__STDIO_FILL_READ_BUFFER(stream)) { /* Refill succeeded? */
goto LOOP;
}
@@ -98,7 +98,7 @@ wint_t fgetwc_unlocked(register FILE *stream)
* error indicator is set. */
stream->__modeflags |= __FLAG_ERROR;
- DONE:
+ DONE:
if (stream->__bufstart == sbuf) { /* Need to un-munge the stream. */
munge_stream(stream, NULL);
}
diff --git a/libc/stdio/vswprintf.c b/libc/stdio/vswprintf.c
index beadb8a7d..10f7cc467 100644
--- a/libc/stdio/vswprintf.c
+++ b/libc/stdio/vswprintf.c
@@ -46,8 +46,8 @@ int vswprintf(wchar_t *__restrict buf, size_t size,
size = ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t));
}
- f.__bufstart = (char *) buf;
- f.__bufend = (char *)(buf + size);
+ f.__bufstart = (unsigned char *) buf;
+ f.__bufend = (unsigned char *) (buf + size);
__STDIO_STREAM_INIT_BUFREAD_BUFPOS(&f);
__STDIO_STREAM_DISABLE_GETC(&f);
__STDIO_STREAM_DISABLE_PUTC(&f);
@@ -58,7 +58,7 @@ int vswprintf(wchar_t *__restrict buf, size_t size,
if (f.__bufpos == f.__bufend) {
rv = -1;
if (size) {
- f.__bufpos = (char *)(((wchar_t *) f.__bufpos) - 1);
+ f.__bufpos = (unsigned char *) (((wchar_t *) f.__bufpos) - 1);
}
}
if (size) {