diff options
author | Jean-Yves Migeon <jeanyves.migeon@free.fr> | 2013-09-06 17:17:57 +0200 |
---|---|---|
committer | Jean-Yves Migeon <jeanyves.migeon@free.fr> | 2013-09-06 17:17:57 +0200 |
commit | dc207e4669c73203f2fe834294157616a82d6287 (patch) | |
tree | 60330e1588e6f7994d6a12555dad94215cbad4fd /cpio | |
parent | 7ba6dff66d176a7ee299258eef1489d0b9ffd225 (diff) | |
download | libarchive-dc207e4669c73203f2fe834294157616a82d6287.tar.gz |
Hide *lafe_progname and provide getter/setter instead.
This factorizes some code between binaries like bsdtar, bsdcpio, and
the soon-to-be mtree.
Diffstat (limited to 'cpio')
-rw-r--r-- | cpio/cpio.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/cpio/cpio.c b/cpio/cpio.c index 3889290a..933bedf3 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -149,20 +149,11 @@ main(int argc, char *argv[]) } #endif - /* Need lafe_progname before calling lafe_warnc. */ + /* Set lafe_progname before calling lafe_warnc. */ if (*argv == NULL) - lafe_progname = "bsdcpio"; - else { -#if defined(_WIN32) && !defined(__CYGWIN__) - lafe_progname = strrchr(*argv, '\\'); - if (strrchr(*argv, '/') > lafe_progname) -#endif - lafe_progname = strrchr(*argv, '/'); - if (lafe_progname != NULL) - lafe_progname++; - else - lafe_progname = *argv; - } + *argv = "bsdcpio"; + lafe_setprogname(*argv); + #if HAVE_SETLOCALE if (setlocale(LC_ALL, "") == NULL) lafe_warnc(0, "Failed to set default locale"); @@ -437,7 +428,7 @@ usage(void) { const char *p; - p = lafe_progname; + p = lafe_getprogname(); fprintf(stderr, "Brief Usage:\n"); fprintf(stderr, " List: %s -it < archive\n", p); @@ -475,7 +466,7 @@ long_help(void) const char *prog; const char *p; - prog = lafe_progname; + prog = lafe_getprogname(); fflush(stderr); |