From 093e816c37f6d3e757bdfc63d7ba5aaf477e20ed Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 2 Aug 2004 07:40:34 +0000 Subject: [PATCH] Allow better wildcard matching against the short-option letters in the "refuse options" handling. --- options.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/options.c b/options.c index a27e68b6..c4db5ed2 100644 --- a/options.c +++ b/options.c @@ -439,8 +439,10 @@ void option_error(void) static void set_refuse_options(char *bp) { struct poptOption *op; - char *cp; - int match_short, is_wild; + char *cp, shortname[2]; + int is_wild; + + shortname[1] = '\0'; while (1) { while (*bp == ' ') bp++; @@ -451,8 +453,7 @@ static void set_refuse_options(char *bp) /* If they specify "delete", reject all delete options. */ if (strcmp(bp, "delete") == 0) bp = "delete*"; - match_short = !bp[1] && *bp != '*'; - is_wild = !match_short && strpbrk(bp, "*?[") != NULL; + is_wild = strpbrk(bp, "*?[") != NULL; for (op = long_options; ; op++) { if (!op->longName) { rprintf(FLOG, @@ -460,8 +461,8 @@ static void set_refuse_options(char *bp) bp); break; } - if (match_short ? *bp == op->shortName - : wildmatch(bp, op->longName)) { + *shortname = op->shortName; + if (wildmatch(bp, op->longName) || wildmatch(bp, shortname)) { op->val = (op - long_options) + OPT_REFUSED_BASE; if (!is_wild) break; -- 2.34.1