Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2007-09-18 00:14:29 +0400
committerEric Blake <eblake@redhat.com>2007-09-18 00:14:29 +0400
commitba21046d032462b4bb1f601e0014a0306c201913 (patch)
tree77eafe281ed839a50ee99cd29fac7f6956ccafeb /newlib
parent8e34786463bdb1f7725a728de408183b2870b16d (diff)
Obey POSIX on printf("%.s", (char*)NULL).
* libc/stdio/vfprintf.c (_VFPRINTF_R): Take precision into account for %s on NULL. Skip NULL check when optimizing for size.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog12
-rw-r--r--newlib/libc/stdio/vfprintf.c11
2 files changed, 18 insertions, 5 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 97d4228fb..f35dc5d45 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-17 Eric Blake <ebb9@byu.net>
+
+ Obey POSIX on printf("%.s", (char*)NULL).
+ * libc/stdio/vfprintf.c (_VFPRINTF_R): Take precision into account
+ for %s on NULL. Skip NULL check when optimizing for size.
+
2007-09-07 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/sys/_types.h: Protect all types with flag
@@ -44,11 +50,11 @@
2007-08-31 Antony King <antony.king@st.com>
- * libc/stdlib/mprec.h [_DOUBLE_IS_32BITS}: Define IEEE_Arith
+ * libc/stdlib/mprec.h [_DOUBLE_IS_32BITS}: Define IEEE_Arith
bits and redefine associated dword0 macro (rvalue issue).
* libc/stdio/vfieeefp.h: Ditto.
- * libc/stdlib/strtod.c: Add checks for _DOUBLE_IS_32BITS
- to prevent setting dword1 which is an rvalue only.
+ * libc/stdlib/strtod.c: Add checks for _DOUBLE_IS_32BITS
+ to prevent setting dword1 which is an rvalue only.
2007-08-28 Hans Kester <hans.kester@ellips.nl>
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c
index 491369012..44d46f20c 100644
--- a/newlib/libc/stdio/vfprintf.c
+++ b/newlib/libc/stdio/vfprintf.c
@@ -1029,10 +1029,17 @@ reswitch: switch (ch) {
case 'S':
#endif
sign = '\0';
- if ((cp = GET_ARG (N, ap, char_ptr_t)) == NULL) {
+ cp = GET_ARG (N, ap, char_ptr_t);
+#ifndef __OPTIMIZE_SIZE__
+ /* Behavior is undefined if the user passed a
+ NULL string when precision is not 0.
+ However, if we are not optimizing for size,
+ we might as well mirror glibc behavior. */
+ if (cp == NULL) {
cp = "(null)";
- size = 6;
+ size = ((unsigned) prec > 6U) ? 6 : prec;
}
+#endif /* __OPTIMIZE_SIZE__ */
#ifdef _MB_CAPABLE
else if (ch == 'S' || (flags & LONGINT)) {
mbstate_t ps;