[uClibc-cvs] uClibc/libc/stdio printf.c,1.48,1.49

Manuel Novoa III mjn3 at uclibc.org
Tue Sep 23 22:49:28 UTC 2003


Update of /var/cvs/uClibc/libc/stdio
In directory winder:/tmp/cvs-serv15130

Modified Files:
	printf.c 
Log Message:
Quick fix to make sure vfprintf always checks stream orientation when
wchar support is enabled.


Index: printf.c
===================================================================
RCS file: /var/cvs/uClibc/libc/stdio/printf.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- printf.c	6 Sep 2003 03:37:17 -0000	1.48
+++ printf.c	23 Sep 2003 22:49:24 -0000	1.49
@@ -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 @@
 	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 @@
 		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;




More information about the uClibc-cvs mailing list