From 65e9baadda287646ebc2e5593443d7996196c87a Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 2 Oct 2015 02:34:53 +0000 Subject: [PATCH] afs.c: Remove compatibility code in action_if_pattern_matches(). This is no longer needed as there are no more non-lopsub commands left. Now pmd->lpr is non-NULL for all commands which call action_if_pattern_matches(), which allows to simplify the function. Moreover, ->patterns of struct pattern_match_data is unused and can be dropped. --- afs.c | 24 ++++++++---------------- afs.h | 2 -- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/afs.c b/afs.c index f51039b1..fbcffdde 100644 --- a/afs.c +++ b/afs.c @@ -317,31 +317,26 @@ static int action_if_pattern_matches(struct osl_row *row, void *data) struct pattern_match_data *pmd = data; struct osl_object name_obj; const char *p, *name; - int i, ret = osl(osl_get_object(pmd->table, row, pmd->match_col_num, &name_obj)); - const char *pattern_txt = (const char *)pmd->patterns.data; + int i, ret; + ret = osl(osl_get_object(pmd->table, row, pmd->match_col_num, + &name_obj)); if (ret < 0) return ret; name = (char *)name_obj.data; if ((!name || !*name) && (pmd->pm_flags & PM_SKIP_EMPTY_NAME)) return 1; - if ((pmd->lpr && lls_num_inputs(pmd->lpr) == 0) || pmd->patterns.size == 0) { + if (lls_num_inputs(pmd->lpr) == 0) { if (pmd->pm_flags & PM_NO_PATTERN_MATCHES_EVERYTHING) { pmd->num_matches++; return pmd->action(pmd->table, row, name, pmd->data); } } - p = pattern_txt; i = pmd->input_skip; for (;;) { - if (pmd->lpr) { - if (i >= lls_num_inputs(pmd->lpr)) - break; - p = lls_input(i, pmd->lpr); - } else { - if (p >= pattern_txt + pmd->patterns.size) - break; - } + if (i >= lls_num_inputs(pmd->lpr)) + break; + p = lls_input(i, pmd->lpr); ret = fnmatch(p, name, pmd->fnmatch_flags); if (ret != FNM_NOMATCH) { if (ret != 0) @@ -352,10 +347,7 @@ static int action_if_pattern_matches(struct osl_row *row, void *data) return ret; } - if (pmd->lpr) - i++; - else - p += strlen(p) + 1; + i++; } return 1; } diff --git a/afs.h b/afs.h index 3ff94f3b..879331ec 100644 --- a/afs.h +++ b/afs.h @@ -147,8 +147,6 @@ struct pattern_match_data { int fnmatch_flags; /** Obtained by deserializing the query buffer in the callback. */ struct lls_parse_result *lpr; - /** Null-terminated array of patterns. */ - struct osl_object patterns; /** Do not try to match the first inputs of lpr */ unsigned input_skip; /** Data pointer passed to the action function. */ -- 2.39.5