diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-06-28 23:07:55 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-06-28 23:07:55 +0000 |
commit | 11fd0bc3fdbe7b5eb9266a728a81d0bcac91fe32 (patch) | |
tree | 7c40f096dd973943ef563ec87b2a68d8205db4fb /lib/util/vasprintf.c | |
parent | 89c6ec14eb7514630aea5abc4b90b51d1473d33a (diff) | |
download | netpbm-mirror-11fd0bc3fdbe7b5eb9266a728a81d0bcac91fe32.tar.gz netpbm-mirror-11fd0bc3fdbe7b5eb9266a728a81d0bcac91fe32.tar.xz netpbm-mirror-11fd0bc3fdbe7b5eb9266a728a81d0bcac91fe32.zip |
Promote Stable to Super_stable
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@3640 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/util/vasprintf.c')
-rw-r--r-- | lib/util/vasprintf.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/lib/util/vasprintf.c b/lib/util/vasprintf.c index 47b4079d..a947f763 100644 --- a/lib/util/vasprintf.c +++ b/lib/util/vasprintf.c @@ -1,19 +1,21 @@ #define _GNU_SOURCE - /* Due to conditional compilation, this is GNU source only if the C library - is GNU. + /* Because of conditional compilation, this is GNU source only if the C + library is GNU. */ #include <stdlib.h> #include <string.h> #include "pm_config.h" +#include "pm_c_util.h" + #include "nstring.h" void -vasprintfN(const char ** const resultP, - const char * const format, - va_list varargs) { +pm_vasprintf(const char ** const resultP, + const char * const format, + va_list varargs) { char * result; @@ -23,7 +25,7 @@ vasprintfN(const char ** const resultP, rc = vasprintf(&result, format, varargs); if (rc < 0) - *resultP = strsol; + *resultP = pm_strsol; else *resultP = result; #else @@ -38,16 +40,22 @@ vasprintfN(const char ** const resultP, So instead, we just allocate 4K and truncate or waste as necessary. + + Note that we don't recognize the floating point specifiers (%f, %e, %g) + - we render them as 'f', 'e', and 'g'. It would be too much work to + make this code handle those, just for the few systems on which it runs. + Instead, we have pm_vasprintf_knows_float(), and any caller that cares + enough can avoid using these specifiers where they don't work. */ size_t const allocSize = 4096; result = malloc(allocSize); if (result == NULL) - *resultP = strsol; + *resultP = pm_strsol; else { size_t realLen; - vsnprintfN(result, allocSize, format, varargs, &realLen); + pm_vsnprintf(result, allocSize, format, varargs, &realLen); if (realLen >= allocSize) strcpy(result + allocSize - 15, "<<<TRUNCATED"); @@ -56,3 +64,14 @@ vasprintfN(const char ** const resultP, } #endif } + + + +bool +pm_vasprintf_knows_float(void) { +#if HAVE_VASPRINTF + return true; +#else + return false; +#endif +} |