summaryrefslogtreecommitdiff
path: root/lib/vasnprintf.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2003-10-20 10:51:59 +0000
committerBruno Haible <bruno@clisp.org>2003-10-20 10:51:59 +0000
commit8ad6a4a39b9e011b35b61d4113dedfbe2a9428c4 (patch)
treef73df631421e78750b2f6848f83b050ff9e948ea /lib/vasnprintf.c
parent31889b6179b5eadabe2772bea4d4731b63ed83f4 (diff)
downloadgnulib-8ad6a4a39b9e011b35b61d4113dedfbe2a9428c4.tar.gz
Portability to HP-UX 10, found by Jim Meyering.
Diffstat (limited to 'lib/vasnprintf.c')
-rw-r--r--lib/vasnprintf.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 9c701f1c61..246c75bdfa 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -707,7 +707,23 @@ vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
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