diff options
author | Tim Kientzle <kientzle@FreeBSD.org> | 2004-12-22 03:38:28 +0000 |
---|---|---|
committer | Tim Kientzle <kientzle@FreeBSD.org> | 2004-12-22 03:38:28 +0000 |
commit | 882aa4c9cd647310bc0296e46857ebe161534fb2 (patch) | |
tree | 7025cee90b5c93588d42bd35c2e8da86156d84d0 /usr.bin/tar/bsdtar.c | |
parent | b8b499afc7df09e9ecdd8256d563a025f63a311e (diff) |
Notes
Diffstat (limited to 'usr.bin/tar/bsdtar.c')
-rw-r--r-- | usr.bin/tar/bsdtar.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c index bf99464b5138f..852d4b8cf7e4e 100644 --- a/usr.bin/tar/bsdtar.c +++ b/usr.bin/tar/bsdtar.c @@ -120,6 +120,10 @@ static const char *tar_opts = "+Bb:C:cF:f:HhI:jkLlmnOoPprtT:UuvW:wX:xyZz"; #define OPTION_TOTALS 28 #define OPTION_VERSION 30 +/* + * If you add anything, be very careful + * to keep this list properly sorted. + */ static const struct option tar_longopts[] = { { "absolute-paths", no_argument, NULL, 'P' }, { "append", no_argument, NULL, 'r' }, @@ -753,12 +757,18 @@ bsdtar_getopt(struct bsdtar *bsdtar, const char *optstring, *poption = option; opt = option->val; - /* Check if there's another match. */ - option++; - while (option->name != NULL && - (strlen(option->name) < option_length || - strncmp(p, option->name, option_length) != 0)) { + /* If the first match was exact, we're done. */ + if (strncmp(p, option->name, strlen(option->name)) == 0) { + while (option->name != NULL) + option++; + } else { + /* Check if there's another match. */ option++; + while (option->name != NULL && + (strlen(option->name) < option_length || + strncmp(p, option->name, option_length) != 0)) { + option++; + } } if (option->name != NULL) bsdtar_errc(bsdtar, 1, 0, |