summaryrefslogtreecommitdiff
path: root/libc/stdio/printf.c
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-09-23 22:49:24 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-09-23 22:49:24 +0000
commit326aad046922ca3802dc330123a2c050975fb12f (patch)
tree8ba19dc5b4c4578e7133354b21d0c3d339950afa /libc/stdio/printf.c
parentf9243338185186b9fd9cb8c34c6b53899b17cdec (diff)
Quick fix to make sure vfprintf always checks stream orientation when
wchar support is enabled.
Diffstat (limited to 'libc/stdio/printf.c')
-rw-r--r--libc/stdio/printf.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libc/stdio/printf.c b/libc/stdio/printf.c
index 1cc121212..bc184ee5f 100644
--- a/libc/stdio/printf.c
+++ b/libc/stdio/printf.c
@@ -75,6 +75,9 @@
*
* Sep 5, 2003
* Implement *s*scanf for the non-buffered stdio case with old_vfprintf.
+ *
+ * Sep 23, 2003
+ * vfprintf was not always checking for narrow stream orientation.
*/
/* TODO:
@@ -3200,6 +3203,18 @@ int VFPRINTF (FILE * __restrict stream,
count = 0;
s = format;
+#if defined(L_vfprintf) && defined(__UCLIBC_HAS_WCHAR__)
+ /* Sigh... I forgot that by calling _stdio_fwrite, vfprintf doesn't
+ * always check the stream's orientation. This is just a temporary
+ * fix until I rewrite the stdio core work routines. */
+ if (stream->modeflags & __FLAG_WIDE) {
+ stream->modeflags |= __FLAG_ERROR;
+ count = -1;
+ goto DONE;
+ }
+ stream->modeflags |= __FLAG_NARROW;
+#endif
+
if (_PPFS_init(&ppfs, format) < 0) { /* Bad format string. */
OUTNSTR(stream, (const FMT_TYPE *) ppfs.fmtpos,
STRLEN((const FMT_TYPE *)(ppfs.fmtpos)));
@@ -3245,6 +3260,10 @@ int VFPRINTF (FILE * __restrict stream,
va_end(ppfs.arg); /* Need to clean up after va_copy! */
}
+#if defined(L_vfprintf) && defined(__UCLIBC_HAS_WCHAR__)
+ DONE:
+#endif
+
__STDIO_THREADUNLOCK(stream);
return count;