diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2013-12-26 06:13:41 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2013-12-26 06:13:41 +0000 |
commit | 51ffbae51ba9379bad460566cdf9babaa63b14c3 (patch) | |
tree | 441f6e9297c478261bdce544497decaf6abc31a4 /lib/util | |
parent | d6f45222d7b29adb9defdd79dd8ad1dbc97bb3e1 (diff) | |
download | netpbm-mirror-51ffbae51ba9379bad460566cdf9babaa63b14c3.tar.gz netpbm-mirror-51ffbae51ba9379bad460566cdf9babaa63b14c3.tar.xz netpbm-mirror-51ffbae51ba9379bad460566cdf9babaa63b14c3.zip |
Update to current Development release - 10.65.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@2083 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/Makefile | 11 | ||||
-rw-r--r-- | lib/util/nstring.c | 22 | ||||
-rw-r--r-- | lib/util/pm_c_util.h | 2 | ||||
-rw-r--r-- | lib/util/vasprintf.c | 6 |
4 files changed, 23 insertions, 18 deletions
diff --git a/lib/util/Makefile b/lib/util/Makefile index 5bf1995e..28dfddfe 100644 --- a/lib/util/Makefile +++ b/lib/util/Makefile @@ -5,6 +5,8 @@ endif SUBDIR = lib/util VPATH=.:$(SRCDIR)/$(SUBDIR) +default:all + include $(BUILDDIR)/config.mk # nstring is required for asprintf(), etc. Also some systems don't have @@ -22,13 +24,14 @@ UTILOBJECTS = \ MERGE_OBJECTS = +include $(SRCDIR)/common.mk + all: $(UTILOBJECTS) -include $(SRCDIR)/common.mk +$(UTILOBJECTS): CFLAGS_TARGET=$(CFLAGS_SHLIB) $(UTILOBJECTS):%.o:%.c importinc - $(CC) -c $(INCLUDES) -DNDEBUG $(CPPFLAGS) $(CFLAGS) $(CFLAGS_SHLIB) \ - $(CFLAGS_PERSONAL) $(CADD) -o $@ $< + $(CC) -c $(INCLUDES) $(CFLAGS_ALL) -o $@ $< testnstring: test.c nstring.h nstring.o - $(CC) $(CFLAGS) $(CADD) -o $@ nstring.o $< + $(CC) $(CFLAGS_ALL) -o $@ nstring.o $< diff --git a/lib/util/nstring.c b/lib/util/nstring.c index e95d9824..bb2ba92e 100644 --- a/lib/util/nstring.c +++ b/lib/util/nstring.c @@ -134,12 +134,6 @@ #include "nstring.h" -#if (defined(__GLIBC__) || defined(__GNU_LIBRARY__)) - #define HAVE_VASPRINTF 1 -#else - #define HAVE_VASPRINTF 0 -#endif - #ifdef isdigit #undef isdigit #endif @@ -797,9 +791,12 @@ pm_asprintf(const char ** const resultP, va_list varargs; #if HAVE_VASPRINTF + int rc; va_start(varargs, fmt); - vasprintf((char **)&result, fmt, varargs); + rc = vasprintf((char **)&result, fmt, varargs); va_end(varargs); + if (rc < 0) + result = pm_strsol; #else size_t dryRunLen; @@ -811,20 +808,23 @@ pm_asprintf(const char ** const resultP, if (dryRunLen + 1 < dryRunLen) /* arithmetic overflow */ - result = NULL; + result = pm_strsol; else { size_t const allocSize = dryRunLen + 1; - result = malloc(allocSize); - if (result != NULL) { + char * buffer; + buffer = malloc(allocSize); + if (buffer != NULL) { va_list varargs; size_t realLen; va_start(varargs, fmt); - pm_vsnprintf(result, allocSize, fmt, varargs, &realLen); + pm_vsnprintf(buffer, allocSize, fmt, varargs, &realLen); assert(realLen == dryRunLen); va_end(varargs); + + result = buffer; } } #endif diff --git a/lib/util/pm_c_util.h b/lib/util/pm_c_util.h index 79897cf0..01a07657 100644 --- a/lib/util/pm_c_util.h +++ b/lib/util/pm_c_util.h @@ -83,7 +83,7 @@ #define TRUE true #endif #ifndef FALSE -#define FALSE false + #define FALSE false #endif #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) diff --git a/lib/util/vasprintf.c b/lib/util/vasprintf.c index 209827eb..e38252fa 100644 --- a/lib/util/vasprintf.c +++ b/lib/util/vasprintf.c @@ -18,9 +18,11 @@ pm_vasprintf(const char ** const resultP, char * result; #if HAVE_VASPRINTF - vasprintf(&result, format, varargs); + int rc; - if (result == NULL) + rc = vasprintf(&result, format, varargs); + + if (rc < 0) *resultP = pm_strsol; else *resultP = result; |