Module Name: othersrc Committed By: agc Date: Fri Mar 1 07:19:48 UTC 2013
Modified Files: othersrc/external/bsd/getopt2/dist: getopt2.c Log Message: increment the sub-index if we're presented with an argument consisting of single character options, and none is matched: as in "tar -cvzf ..." To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/getopt2/dist/getopt2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: othersrc/external/bsd/getopt2/dist/getopt2.c diff -u othersrc/external/bsd/getopt2/dist/getopt2.c:1.2 othersrc/external/bsd/getopt2/dist/getopt2.c:1.3 --- othersrc/external/bsd/getopt2/dist/getopt2.c:1.2 Wed Nov 28 06:51:23 2012 +++ othersrc/external/bsd/getopt2/dist/getopt2.c Fri Mar 1 07:19:47 2013 @@ -29,6 +29,19 @@ #include "getopt2.h" +static void +increment_index(getopt2_t *options, char **argv, int subind) +{ + if (argv[options->optind][subind] == 0x0) { + options->optsubind = 0; + options->optind += 1; + } else { + options->optsubind = subind; + } +} + +/*******************************************************************/ + int getopt2_init(getopt2_t *options) { @@ -64,7 +77,9 @@ getopt2(getopt2_t *options, int argc, ch return options->optopt = -1; } if ((opt = strchr(optstring, ch)) == NULL) { + /* option given is not one that's recognised */ (void) fprintf(stderr, "getopt2: '%c' unknown option\n", ch); + increment_index(options, argv, subind); return options->optopt = '?'; } switch(*(opt + 1)) { @@ -94,12 +109,7 @@ getopt2(getopt2_t *options, int argc, ch options->optsubind = 0; break; default: - if (argv[options->optind][subind] == 0x0) { - options->optsubind = 0; - options->optind += 1; - } else { - options->optsubind = subind; - } + increment_index(options, argv, subind); options->optarg = NULL; break; }