]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Fix a bug with snprintf() on HP-UX 10.
authorBruno Haible <bruno@clisp.org>
Mon, 20 Oct 2003 10:57:53 +0000 (10:57 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:11:04 +0000 (12:11 +0200)
gettext-runtime/intl/ChangeLog
gettext-runtime/intl/vasnprintf.c
gettext-runtime/libasprintf/ChangeLog
gettext-runtime/libasprintf/vasnprintf.c

index f6ce5efee9257eefd1f21c71ccbaa3bac413fc51..1521e3df627fbbaf3c324ef24d46a8b978080d49 100644 (file)
@@ -1,3 +1,7 @@
+2003-10-19  Jim Meyering  <jim@meyering.net>
+
+       * vasnprintf.c (VASNPRINTF): Work around losing snprintf on HPUX 10.20.
+
 2003-10-09  Bruno Haible  <bruno@clisp.org>
 
        * relocatable.c: Include xalloc.h instead of xmalloc.h.
index 7a46ca99aee16b48b4bd7c305d41e770ea785a57..5a37a0f396fc2b8d3bc21186a2632542616cc62c 100644 (file)
@@ -760,7 +760,23 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
                            p[1] = '\0';
                            continue;
                          }
-                       count = retcount;
+                       else
+                         {
+                           /* Look at the snprintf() return value.  */
+                           if (retcount < 0)
+                             {
+                               /* HP-UX 10.20 snprintf() is doubly deficient:
+                                  It doesn't understand the '%n' directive,
+                                  *and* it returns -1 (rather than the length
+                                  that would have been required) when the
+                                  buffer is too small.  */
+                               size_t bigger_need = 2 * allocated + 12;
+                               ENSURE_ALLOCATION (bigger_need);
+                               continue;
+                             }
+                           else
+                             count = retcount;
+                         }
                      }
 #endif
 
index 5fd76953133dc732674ea7cfd77c6e264c2d4101..dbfae8b0e53264bcbbd5396fcc046d495ec865b1 100644 (file)
@@ -1,3 +1,7 @@
+2003-10-19  Jim Meyering  <jim@meyering.net>
+
+       * vasnprintf.c (VASNPRINTF): Work around losing snprintf on HPUX 10.20.
+
 2003-08-29  Bruno Haible  <bruno@clisp.org>
 
        * configure.ac: Test whether _snprintf is declared, not only existent
index 7a46ca99aee16b48b4bd7c305d41e770ea785a57..5a37a0f396fc2b8d3bc21186a2632542616cc62c 100644 (file)
@@ -760,7 +760,23 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
                            p[1] = '\0';
                            continue;
                          }
-                       count = retcount;
+                       else
+                         {
+                           /* Look at the snprintf() return value.  */
+                           if (retcount < 0)
+                             {
+                               /* HP-UX 10.20 snprintf() is doubly deficient:
+                                  It doesn't understand the '%n' directive,
+                                  *and* it returns -1 (rather than the length
+                                  that would have been required) when the
+                                  buffer is too small.  */
+                               size_t bigger_need = 2 * allocated + 12;
+                               ENSURE_ALLOCATION (bigger_need);
+                               continue;
+                             }
+                           else
+                             count = retcount;
+                         }
                      }
 #endif