From: Bruno Haible Date: Mon, 20 Oct 2003 10:57:53 +0000 (+0000) Subject: Fix a bug with snprintf() on HP-UX 10. X-Git-Tag: v0.13~202 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10afe84cba6107153ca2b59793e43d6616f4ba88;p=thirdparty%2Fgettext.git Fix a bug with snprintf() on HP-UX 10. --- diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog index f6ce5efee..1521e3df6 100644 --- a/gettext-runtime/intl/ChangeLog +++ b/gettext-runtime/intl/ChangeLog @@ -1,3 +1,7 @@ +2003-10-19 Jim Meyering + + * vasnprintf.c (VASNPRINTF): Work around losing snprintf on HPUX 10.20. + 2003-10-09 Bruno Haible * relocatable.c: Include xalloc.h instead of xmalloc.h. diff --git a/gettext-runtime/intl/vasnprintf.c b/gettext-runtime/intl/vasnprintf.c index 7a46ca99a..5a37a0f39 100644 --- a/gettext-runtime/intl/vasnprintf.c +++ b/gettext-runtime/intl/vasnprintf.c @@ -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 diff --git a/gettext-runtime/libasprintf/ChangeLog b/gettext-runtime/libasprintf/ChangeLog index 5fd769531..dbfae8b0e 100644 --- a/gettext-runtime/libasprintf/ChangeLog +++ b/gettext-runtime/libasprintf/ChangeLog @@ -1,3 +1,7 @@ +2003-10-19 Jim Meyering + + * vasnprintf.c (VASNPRINTF): Work around losing snprintf on HPUX 10.20. + 2003-08-29 Bruno Haible * configure.ac: Test whether _snprintf is declared, not only existent diff --git a/gettext-runtime/libasprintf/vasnprintf.c b/gettext-runtime/libasprintf/vasnprintf.c index 7a46ca99a..5a37a0f39 100644 --- a/gettext-runtime/libasprintf/vasnprintf.c +++ b/gettext-runtime/libasprintf/vasnprintf.c @@ -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