summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2009-02-27 02:14:00 +0100
committerBruno Haible <bruno@clisp.org>2009-02-27 02:15:26 +0100
commitf7beddb6d03f25560cbce2423ee9d2bcbbfed6e6 (patch)
tree2b9eb7825a6c326d94bfc19b0c6d09493a026770
parentf26544f660df049ff2195f6b40762d96742d0228 (diff)
downloadgnulib-f7beddb6d03f25560cbce2423ee9d2bcbbfed6e6.tar.gz
Work around a *printf bug with %ls on Solaris.
-rw-r--r--ChangeLog19
-rw-r--r--doc/glibc-functions/obstack_printf.texi4
-rw-r--r--doc/glibc-functions/obstack_vprintf.texi4
-rw-r--r--doc/posix-functions/fprintf.texi4
-rw-r--r--doc/posix-functions/printf.texi4
-rw-r--r--doc/posix-functions/snprintf.texi4
-rw-r--r--doc/posix-functions/sprintf.texi4
-rw-r--r--doc/posix-functions/vfprintf.texi4
-rw-r--r--doc/posix-functions/vprintf.texi4
-rw-r--r--doc/posix-functions/vsnprintf.texi4
-rw-r--r--doc/posix-functions/vsprintf.texi4
-rw-r--r--m4/printf.m443
12 files changed, 92 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index a34e3f835c..583fa8f13e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,23 @@
2009-02-26 Eric Blake <ebb9@byu.net>
+ Bruno Haible <bruno@clisp.org>
+
+ Work around a *printf bug with %ls on Solaris.
+ * m4/printf.m4 (gl_PRINTF_DIRECTIVE_LS): Also test whether, when a
+ precision is specified, sprintf stops converting the wide string
+ argument when the number of bytes that have been produced by this
+ conversion equals or exceeds the precision.
+ * doc/posix-functions/fprintf.texi: Update.
+ * doc/posix-functions/printf.texi: Update.
+ * doc/posix-functions/snprintf.texi: Update.
+ * doc/posix-functions/sprintf.texi: Update.
+ * doc/posix-functions/vfprintf.texi: Update.
+ * doc/posix-functions/vprintf.texi: Update.
+ * doc/posix-functions/vsnprintf.texi: Update.
+ * doc/posix-functions/vsprintf.texi: Update.
+ * doc/glibc-functions/obstack_printf.texi: Update.
+ * doc/glibc-functions/obstack_vprintf.texi: Update.
+
+2009-02-26 Eric Blake <ebb9@byu.net>
stdlib: favor compiler check of random.h
* m4/stdlib_h.m4 (gl_STDLIB_H): Skip preprocessor check. Needed
diff --git a/doc/glibc-functions/obstack_printf.texi b/doc/glibc-functions/obstack_printf.texi
index 83d4c6ce69..7a5726486f 100644
--- a/doc/glibc-functions/obstack_printf.texi
+++ b/doc/glibc-functions/obstack_printf.texi
@@ -38,6 +38,10 @@ Cygwin 1.5.x, mingw, BeOS.
This function does not support the @samp{ls} directive on some platforms:
OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku.
@item
+This function does not support precisions in the @samp{ls} directive correctly
+on some platforms:
+Solaris 10.
+@item
This function does not support format directives that access arguments in an
arbitrary order, such as @code{"%2$s"}, on some platforms:
NetBSD 3.0, mingw, BeOS.
diff --git a/doc/glibc-functions/obstack_vprintf.texi b/doc/glibc-functions/obstack_vprintf.texi
index ef0d6f5272..8556f74b7b 100644
--- a/doc/glibc-functions/obstack_vprintf.texi
+++ b/doc/glibc-functions/obstack_vprintf.texi
@@ -38,6 +38,10 @@ Cygwin 1.5.x, mingw, BeOS.
This function does not support the @samp{ls} directive on some platforms:
OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku.
@item
+This function does not support precisions in the @samp{ls} directive correctly
+on some platforms:
+Solaris 10.
+@item
This function does not support format directives that access arguments in an
arbitrary order, such as @code{"%2$s"}, on some platforms:
NetBSD 3.0, mingw, BeOS.
diff --git a/doc/posix-functions/fprintf.texi b/doc/posix-functions/fprintf.texi
index 0af41ae876..0434e4422e 100644
--- a/doc/posix-functions/fprintf.texi
+++ b/doc/posix-functions/fprintf.texi
@@ -32,6 +32,10 @@ Cygwin 1.5.x, mingw, BeOS.
This function does not support the @samp{ls} directive on some platforms:
OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku.
@item
+This function does not support precisions in the @samp{ls} directive correctly
+on some platforms:
+Solaris 10.
+@item
This function does not support format directives that access arguments in an
arbitrary order, such as @code{"%2$s"}, on some platforms:
NetBSD 3.0, mingw, BeOS.
diff --git a/doc/posix-functions/printf.texi b/doc/posix-functions/printf.texi
index da57b21051..1783ad2262 100644
--- a/doc/posix-functions/printf.texi
+++ b/doc/posix-functions/printf.texi
@@ -32,6 +32,10 @@ Cygwin 1.5.x, mingw, BeOS.
This function does not support the @samp{ls} directive on some platforms:
OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku.
@item
+This function does not support precisions in the @samp{ls} directive correctly
+on some platforms:
+Solaris 10.
+@item
This function does not support format directives that access arguments in an
arbitrary order, such as @code{"%2$s"}, on some platforms:
NetBSD 3.0, mingw, BeOS.
diff --git a/doc/posix-functions/snprintf.texi b/doc/posix-functions/snprintf.texi
index a0ab770b0e..d8ecbcccd6 100644
--- a/doc/posix-functions/snprintf.texi
+++ b/doc/posix-functions/snprintf.texi
@@ -43,6 +43,10 @@ Cygwin 1.5.x, mingw, BeOS.
This function does not support the @samp{ls} directive on some platforms:
OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku.
@item
+This function does not support precisions in the @samp{ls} directive correctly
+on some platforms:
+Solaris 10.
+@item
This function does not support format directives that access arguments in an
arbitrary order, such as @code{"%2$s"}, on some platforms:
NetBSD 3.0, mingw, BeOS.
diff --git a/doc/posix-functions/sprintf.texi b/doc/posix-functions/sprintf.texi
index 756feec5f6..003fb44b85 100644
--- a/doc/posix-functions/sprintf.texi
+++ b/doc/posix-functions/sprintf.texi
@@ -32,6 +32,10 @@ Cygwin 1.5.x, mingw, BeOS.
This function does not support the @samp{ls} directive on some platforms:
OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku.
@item
+This function does not support precisions in the @samp{ls} directive correctly
+on some platforms:
+Solaris 10.
+@item
This function does not support format directives that access arguments in an
arbitrary order, such as @code{"%2$s"}, on some platforms:
NetBSD 3.0, mingw, BeOS.
diff --git a/doc/posix-functions/vfprintf.texi b/doc/posix-functions/vfprintf.texi
index 90d9fa11d5..37c2d11b1f 100644
--- a/doc/posix-functions/vfprintf.texi
+++ b/doc/posix-functions/vfprintf.texi
@@ -32,6 +32,10 @@ Cygwin 1.5.x, mingw, BeOS.
This function does not support the @samp{ls} directive on some platforms:
OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku.
@item
+This function does not support precisions in the @samp{ls} directive correctly
+on some platforms:
+Solaris 10.
+@item
This function does not support format directives that access arguments in an
arbitrary order, such as @code{"%2$s"}, on some platforms:
NetBSD 3.0, mingw, BeOS.
diff --git a/doc/posix-functions/vprintf.texi b/doc/posix-functions/vprintf.texi
index f3462bc34e..453117245f 100644
--- a/doc/posix-functions/vprintf.texi
+++ b/doc/posix-functions/vprintf.texi
@@ -32,6 +32,10 @@ Cygwin 1.5.x, mingw, BeOS.
This function does not support the @samp{ls} directive on some platforms:
OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku.
@item
+This function does not support precisions in the @samp{ls} directive correctly
+on some platforms:
+Solaris 10.
+@item
This function does not support format directives that access arguments in an
arbitrary order, such as @code{"%2$s"}, on some platforms:
NetBSD 3.0, mingw, BeOS.
diff --git a/doc/posix-functions/vsnprintf.texi b/doc/posix-functions/vsnprintf.texi
index 294c6eafa9..f09e0543ac 100644
--- a/doc/posix-functions/vsnprintf.texi
+++ b/doc/posix-functions/vsnprintf.texi
@@ -43,6 +43,10 @@ Cygwin 1.5.x, mingw, BeOS.
This function does not support the @samp{ls} directive on some platforms:
OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku.
@item
+This function does not support precisions in the @samp{ls} directive correctly
+on some platforms:
+Solaris 10.
+@item
This function does not support format directives that access arguments in an
arbitrary order, such as @code{"%2$s"}, on some platforms:
NetBSD 3.0, mingw, BeOS.
diff --git a/doc/posix-functions/vsprintf.texi b/doc/posix-functions/vsprintf.texi
index beda4a8deb..d477b4b3f4 100644
--- a/doc/posix-functions/vsprintf.texi
+++ b/doc/posix-functions/vsprintf.texi
@@ -32,6 +32,10 @@ Cygwin 1.5.x, mingw, BeOS.
This function does not support the @samp{ls} directive on some platforms:
OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku.
@item
+This function does not support precisions in the @samp{ls} directive correctly
+on some platforms:
+Solaris 10.
+@item
This function does not support format directives that access arguments in an
arbitrary order, such as @code{"%2$s"}, on some platforms:
NetBSD 3.0, mingw, BeOS.
diff --git a/m4/printf.m4 b/m4/printf.m4
index f3e201b529..4207ace49f 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -1,4 +1,4 @@
-# printf.m4 serial 30
+# printf.m4 serial 31
dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -626,7 +626,10 @@ changequote([,])dnl
])
dnl Test whether the *printf family of functions supports the %ls format
-dnl directive.
+dnl directive and in particular, when a precision is specified, whether
+dnl the functions stop converting the wide string argument when the number
+dnl of bytes that have been produced by this conversion equals or exceeds
+dnl the precision.
dnl Result is gl_cv_func_printf_directive_ls.
AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
@@ -646,19 +649,40 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
#include <time.h>
#include <wchar.h>
#include <string.h>
-static wchar_t wstring[] = { 'a', 'b', 'c', 0 };
int main ()
{
char buf[100];
- buf[0] = '\0';
- sprintf (buf, "%ls", wstring);
- return strcmp (buf, "abc") != 0;
+ /* Test whether %ls works at all.
+ This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku. */
+ {
+ static const wchar_t wstring[] = { 'a', 'b', 'c', 0 };
+ buf[0] = '\0';
+ if (sprintf (buf, "%ls", wstring) < 0
+ || strcmp (buf, "abc") != 0)
+ return 1;
+ }
+ /* Test whether precisions in %ls are supported as specified in ISO C 99
+ section 7.19.6.1:
+ "If a precision is specified, no more than that many bytes are written
+ (including shift sequences, if any), and the array shall contain a
+ null wide character if, to equal the multibyte character sequence
+ length given by the precision, the function would need to access a
+ wide character one past the end of the array."
+ This test fails on Solaris 10. */
+ {
+ static const wchar_t wstring[] = { 'a', 'b', (wchar_t) 0xfdfdfdfd, 0 };
+ buf[0] = '\0';
+ if (sprintf (buf, "%.2ls", wstring) < 0
+ || strcmp (buf, "ab") != 0)
+ return 1;
+ }
+ return 0;
}], [gl_cv_func_printf_directive_ls=yes], [gl_cv_func_printf_directive_ls=no],
[
changequote(,)dnl
case "$host_os" in
openbsd*) gl_cv_func_printf_directive_ls="guessing no";;
- solaris2.[1-6]*) gl_cv_func_printf_directive_ls="guessing no";;
+ solaris*) gl_cv_func_printf_directive_ls="guessing no";;
irix*) gl_cv_func_printf_directive_ls="guessing no";;
beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
*) gl_cv_func_printf_directive_ls="guessing yes";;
@@ -1362,9 +1386,8 @@ dnl MacOS X 10.3.9 . . . . # . . . . . . # . # .
dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . .
dnl Cygwin 2007 (= Cygwin 1.5.24) . . . . # # . . . . ? # ? ? . . . . . .
dnl Cygwin 2006 (= Cygwin 1.5.19) # . . . # # . ? . # ? # ? ? . . . . . .
-dnl Solaris 10 . . # # # . . . . . . # . . . . . . . .
-dnl Solaris 7 ... 9 # . # # # # . . . . . # . . . . . . . .
-dnl Solaris 2.6 # . # # # # . # . . . # . . . . . . . .
+dnl Solaris 10 . . # # # . . # . . . # . . . . . . . .
+dnl Solaris 2.6 ... 9 # . # # # # . # . . . # . . . . . . . .
dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # #
dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . .
dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . . . . .