mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
(vasnprintf): Work around losing snprintf on e.g. HPUX 10.20.
This commit is contained in:
1 parent
14dd23ac24
commit
fd1e5aba83
1 file changed
+16
@@ -707,6 +707,22 @@ vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
|
||||
p[1] = '\0';
|
||||
continue;
|
||||
}
|
||||
else if (retcount < 0)
|
||||
{
|
||||
/* The system's snprintf is sorely deficient:
|
||||
it doesn't recognize the `%n' directive, and it
|
||||
returns -1 (rather than the length that would
|
||||
have been required) when the buffer is too small.
|
||||
This is the case at with least HPUX 10.20.
|
||||
Double the memory allocation. */
|
||||
size_t n = allocated;
|
||||
if (n < 2 * allocated)
|
||||
{
|
||||
n = 2 * allocated;
|
||||
ENSURE_ALLOCATION (n);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
count = retcount;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user