From 5c4b026c4ad992badb261268a5d368d245ad80cd Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Thu, 19 Dec 2013 20:10:46 -0800 Subject: Refactor lafe_setprogname slightly to avoid the repeated logic about default handling --- libarchive_fe/err.c | 6 ++++-- libarchive_fe/err.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'libarchive_fe') diff --git a/libarchive_fe/err.c b/libarchive_fe/err.c index 408c2029..8618a94e 100644 --- a/libarchive_fe/err.c +++ b/libarchive_fe/err.c @@ -52,9 +52,11 @@ lafe_getprogname(void) } void -lafe_setprogname(const char *name) +lafe_setprogname(const char *name, const char *defaultname) { - + + if (name == NULL) + name = defaultname; #if defined(_WIN32) && !defined(__CYGWIN__) lafe_progname = strrchr(name, '\\'); if (strrchr(name, '/') > lafe_progname) diff --git a/libarchive_fe/err.h b/libarchive_fe/err.h index c351cba8..ebf5de81 100644 --- a/libarchive_fe/err.h +++ b/libarchive_fe/err.h @@ -45,6 +45,6 @@ void lafe_errc(int eval, int code, const char *fmt, ...) __LA_DEAD __LA_PRINTFLIKE(3, 4); const char * lafe_getprogname(void); -void lafe_setprogname(const char *); +void lafe_setprogname(const char *name, const char *defaultname); #endif -- cgit v1.2.1