wildmatch: replace variable 'special' with better named ones
'special' is too generic and is used for two different purposes. Replace it with 'match_slash' to indicate "**" pattern and 'negated' for "[!...]" and "[^...]". Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Jan 1, 2013 at 09:44 UTC
b6a3d3353f799c8c5afedb2da4df6e7cdc5d00c9
1 file changed
+9
-9
wildmatch.c
+9
-9
@@ -61,7 +61,7 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
61
const uchar *pattern = p;
62
63
for ( ; (p_ch = *p) != '\0'; text++, p++) {
64
- int matched, special;
64
+ int matched, match_slash, negated;
65
uchar t_ch, prev_ch;
66
if ((t_ch = *text) == '\0' && p_ch != '*')
67
return ABORT_ALL;
@@ -103,15 +103,15 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
103
if (p[0] == '/' &&
104
dowild(p + 1, text, force_lower_case) == MATCH)
105
return MATCH;
106
- special = TRUE;
106
+ match_slash = TRUE;
107
} else
108
return ABORT_MALFORMED;
109
} else
110
- special = FALSE;
110
+ match_slash = FALSE;
111
if (*p == '\0') {
112
/* Trailing "**" matches everything. Trailing "*" matches
113
* only if there are no more slash characters. */
114
- if (!special) {
114
+ if (!match_slash) {
115
if (strchr((char*)text, '/') != NULL)
116
return NOMATCH;
117
}
@@ -121,9 +121,9 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
121
if (t_ch == '\0')
122
break;
123
if ((matched = dowild(p, text, force_lower_case)) != NOMATCH) {
124
- if (!special || matched != ABORT_TO_STARSTAR)
124
+ if (!match_slash || matched != ABORT_TO_STARSTAR)
125
return matched;
126
- } else if (!special && t_ch == '/')
126
+ } else if (!match_slash && t_ch == '/')
127
return ABORT_TO_STARSTAR;
128
t_ch = *++text;
129
}
@@ -135,8 +135,8 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
135
p_ch = NEGATE_CLASS;
136
#endif
137
/* Assign literal TRUE/FALSE because of "matched" comparison. */
138
- special = p_ch == NEGATE_CLASS? TRUE : FALSE;
139
- if (special) {
138
+ negated = p_ch == NEGATE_CLASS? TRUE : FALSE;
139
+ if (negated) {
140
/* Inverted character class. */
141
p_ch = *++p;
142
}
@@ -218,7 +218,7 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
218
} else if (t_ch == p_ch)
219
matched = TRUE;
220
} while (prev_ch = p_ch, (p_ch = *++p) != ']');
221
- if (matched == special || t_ch == '/')
221
+ if (matched == negated || t_ch == '/')
222
return NOMATCH;
223
continue;
224
}