]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Refactor lafe_setprogname slightly to avoid the repeated logic about default handling
authorTim Kientzle <kientzle@gmail.com>
Fri, 20 Dec 2013 04:10:46 +0000 (20:10 -0800)
committerTim Kientzle <kientzle@gmail.com>
Fri, 20 Dec 2013 04:10:46 +0000 (20:10 -0800)
cpio/cpio.c
libarchive_fe/err.c
libarchive_fe/err.h
tar/bsdtar.c

index 933bedf3ce6ab900d197c3ab3de82d747b788c96..98fd83cc7e485cdff3d2865d2cf3b97401e344ea 100644 (file)
@@ -150,9 +150,7 @@ main(int argc, char *argv[])
 #endif
 
        /* Set lafe_progname before calling lafe_warnc. */
-       if (*argv == NULL)
-               *argv = "bsdcpio";
-       lafe_setprogname(*argv);
+       lafe_setprogname(*argv, "bsdcpio");
 
 #if HAVE_SETLOCALE
        if (setlocale(LC_ALL, "") == NULL)
index 408c2029fe88f149d5da223bd82c84fa3bd10211..8618a94ea5d56dc14b6de3c25590ce58e4c3e177 100644 (file)
@@ -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)
index c351cba8892f3775678cee691b11e0fe49eff1e1..ebf5de814f5e5cbb1e6484ff70a011afa51bab3c 100644 (file)
@@ -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
index 8b05b401523fa161a043e8105dcaa156c7e256a9..d743718f1b0d86c7d43a14d3d81f784887189de2 100644 (file)
@@ -179,9 +179,7 @@ main(int argc, char **argv)
 #endif
 
        /* Set lafe_progname before calling lafe_warnc. */
-       if (*argv == NULL)
-               *argv = "bsdtar";
-       lafe_setprogname(*argv);
+       lafe_setprogname(*argv, "bsdtar");
 
 #if HAVE_SETLOCALE
        if (setlocale(LC_ALL, "") == NULL)