From: Mike Kazantsev Date: Sat, 5 Apr 2014 22:33:26 +0000 (+0600) Subject: Use getopt() instead of getopt_long() in bsdcat for compatibility reasons. X-Git-Tag: v3.1.900a~308^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30e772e086d42949c6da8bda4e2e6a099f5075a8;p=thirdparty%2Flibarchive.git Use getopt() instead of getopt_long() in bsdcat for compatibility reasons. --- diff --git a/cat/bsdcat.c b/cat/bsdcat.c index e9b344879..c453201a2 100644 --- a/cat/bsdcat.c +++ b/cat/bsdcat.c @@ -25,7 +25,8 @@ #include #include -#include +#include +#include #include "bsdcat.h" #include "err.h" @@ -35,15 +36,8 @@ struct archive *a; struct archive_entry *ae; char *bsdcat_current_path; -int c, err; -static struct option long_options[] = { - {"help", 0, 0, 'h'}, - {"version", 0, 0, 'v'}, - {NULL, 0, NULL, 0} -}; - void usage(void) { @@ -87,15 +81,16 @@ fail: int main(int argc, char **argv) { + int c; + lafe_setprogname(*argv, "bsdcat"); - int option_index = 0; - while ((c = getopt_long(argc, argv, "h", - long_options, &option_index)) != -1) { + while ((c = getopt(argc, argv, "h-")) != -1) { switch (c) { - case 'v': - version(); - break; + case '-': + if (strcmp(argv[optind], "--version") == 0) version(); + if (c == '-' && strcmp(argv[optind], "--help") != 0) + lafe_warnc(0, "invalid option -- '%s'", argv[optind]); default: usage(); }