@@ -18,9 +18,6 @@ typedef unsigned char uchar;
18
18
#define NEGATE_CLASS '!'
19
19
#define NEGATE_CLASS2 '^'
20
20
21
- #define FALSE 0
22
- #define TRUE 1
23
-
24
21
#define CC_EQ (class , len , litmatch ) ((len) == sizeof (litmatch)-1 \
25
22
&& *(class) == *(litmatch) \
26
23
&& strncmp((char*)class, litmatch, len) == 0)
@@ -64,7 +61,7 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
64
61
int matched , match_slash , negated ;
65
62
uchar t_ch , prev_ch ;
66
63
if ((t_ch = * text ) == '\0' && p_ch != '*' )
67
- return ABORT_ALL ;
64
+ return WM_ABORT_ALL ;
68
65
if (force_lower_case && ISUPPER (t_ch ))
69
66
t_ch = tolower (t_ch );
70
67
if (force_lower_case && ISUPPER (p_ch ))
@@ -77,12 +74,12 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
77
74
/* FALLTHROUGH */
78
75
default :
79
76
if (t_ch != p_ch )
80
- return NOMATCH ;
77
+ return WM_NOMATCH ;
81
78
continue ;
82
79
case '?' :
83
80
/* Match anything but '/'. */
84
81
if (t_ch == '/' )
85
- return NOMATCH ;
82
+ return WM_NOMATCH ;
86
83
continue ;
87
84
case '*' :
88
85
if (* ++ p == '*' ) {
@@ -101,135 +98,136 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
101
98
* both foo/bar and foo/a/bar.
102
99
*/
103
100
if (p [0 ] == '/' &&
104
- dowild (p + 1 , text , force_lower_case ) == MATCH )
105
- return MATCH ;
106
- match_slash = TRUE ;
101
+ dowild (p + 1 , text , force_lower_case ) == WM_MATCH )
102
+ return WM_MATCH ;
103
+ match_slash = 1 ;
107
104
} else
108
- return ABORT_MALFORMED ;
105
+ return WM_ABORT_MALFORMED ;
109
106
} else
110
- match_slash = FALSE ;
107
+ match_slash = 0 ;
111
108
if (* p == '\0' ) {
112
109
/* Trailing "**" matches everything. Trailing "*" matches
113
110
* only if there are no more slash characters. */
114
111
if (!match_slash ) {
115
112
if (strchr ((char * )text , '/' ) != NULL )
116
- return NOMATCH ;
113
+ return WM_NOMATCH ;
117
114
}
118
- return MATCH ;
115
+ return WM_MATCH ;
119
116
}
120
117
while (1 ) {
121
118
if (t_ch == '\0' )
122
119
break ;
123
- if ((matched = dowild (p , text , force_lower_case )) != NOMATCH ) {
124
- if (!match_slash || matched != ABORT_TO_STARSTAR )
120
+ if ((matched = dowild (p , text , force_lower_case )) != WM_NOMATCH ) {
121
+ if (!match_slash || matched != WM_ABORT_TO_STARSTAR )
125
122
return matched ;
126
123
} else if (!match_slash && t_ch == '/' )
127
- return ABORT_TO_STARSTAR ;
124
+ return WM_ABORT_TO_STARSTAR ;
128
125
t_ch = * ++ text ;
129
126
}
130
- return ABORT_ALL ;
127
+ return WM_ABORT_ALL ;
131
128
case '[' :
132
129
p_ch = * ++ p ;
133
130
#ifdef NEGATE_CLASS2
134
131
if (p_ch == NEGATE_CLASS2 )
135
132
p_ch = NEGATE_CLASS ;
136
133
#endif
137
- /* Assign literal TRUE/FALSE because of "matched" comparison. */
138
- negated = p_ch == NEGATE_CLASS ? TRUE : FALSE ;
134
+ /* Assign literal 1/0 because of "matched" comparison. */
135
+ negated = p_ch == NEGATE_CLASS ? 1 : 0 ;
139
136
if (negated ) {
140
137
/* Inverted character class. */
141
138
p_ch = * ++ p ;
142
139
}
143
140
prev_ch = 0 ;
144
- matched = FALSE ;
141
+ matched = 0 ;
145
142
do {
146
143
if (!p_ch )
147
- return ABORT_ALL ;
144
+ return WM_ABORT_ALL ;
148
145
if (p_ch == '\\' ) {
149
146
p_ch = * ++ p ;
150
147
if (!p_ch )
151
- return ABORT_ALL ;
148
+ return WM_ABORT_ALL ;
152
149
if (t_ch == p_ch )
153
- matched = TRUE ;
150
+ matched = 1 ;
154
151
} else if (p_ch == '-' && prev_ch && p [1 ] && p [1 ] != ']' ) {
155
152
p_ch = * ++ p ;
156
153
if (p_ch == '\\' ) {
157
154
p_ch = * ++ p ;
158
155
if (!p_ch )
159
- return ABORT_ALL ;
156
+ return WM_ABORT_ALL ;
160
157
}
161
158
if (t_ch <= p_ch && t_ch >= prev_ch )
162
- matched = TRUE ;
159
+ matched = 1 ;
163
160
p_ch = 0 ; /* This makes "prev_ch" get set to 0. */
164
161
} else if (p_ch == '[' && p [1 ] == ':' ) {
165
162
const uchar * s ;
166
163
int i ;
167
164
for (s = p += 2 ; (p_ch = * p ) && p_ch != ']' ; p ++ ) {} /*SHARED ITERATOR*/
168
165
if (!p_ch )
169
- return ABORT_ALL ;
166
+ return WM_ABORT_ALL ;
170
167
i = p - s - 1 ;
171
168
if (i < 0 || p [-1 ] != ':' ) {
172
169
/* Didn't find ":]", so treat like a normal set. */
173
170
p = s - 2 ;
174
171
p_ch = '[' ;
175
172
if (t_ch == p_ch )
176
- matched = TRUE ;
173
+ matched = 1 ;
177
174
continue ;
178
175
}
179
176
if (CC_EQ (s ,i , "alnum" )) {
180
177
if (ISALNUM (t_ch ))
181
- matched = TRUE ;
178
+ matched = 1 ;
182
179
} else if (CC_EQ (s ,i , "alpha" )) {
183
180
if (ISALPHA (t_ch ))
184
- matched = TRUE ;
181
+ matched = 1 ;
185
182
} else if (CC_EQ (s ,i , "blank" )) {
186
183
if (ISBLANK (t_ch ))
187
- matched = TRUE ;
184
+ matched = 1 ;
188
185
} else if (CC_EQ (s ,i , "cntrl" )) {
189
186
if (ISCNTRL (t_ch ))
190
- matched = TRUE ;
187
+ matched = 1 ;
191
188
} else if (CC_EQ (s ,i , "digit" )) {
192
189
if (ISDIGIT (t_ch ))
193
- matched = TRUE ;
190
+ matched = 1 ;
194
191
} else if (CC_EQ (s ,i , "graph" )) {
195
192
if (ISGRAPH (t_ch ))
196
- matched = TRUE ;
193
+ matched = 1 ;
197
194
} else if (CC_EQ (s ,i , "lower" )) {
198
195
if (ISLOWER (t_ch ))
199
- matched = TRUE ;
196
+ matched = 1 ;
200
197
} else if (CC_EQ (s ,i , "print" )) {
201
198
if (ISPRINT (t_ch ))
202
- matched = TRUE ;
199
+ matched = 1 ;
203
200
} else if (CC_EQ (s ,i , "punct" )) {
204
201
if (ISPUNCT (t_ch ))
205
- matched = TRUE ;
202
+ matched = 1 ;
206
203
} else if (CC_EQ (s ,i , "space" )) {
207
204
if (ISSPACE (t_ch ))
208
- matched = TRUE ;
205
+ matched = 1 ;
209
206
} else if (CC_EQ (s ,i , "upper" )) {
210
207
if (ISUPPER (t_ch ))
211
- matched = TRUE ;
208
+ matched = 1 ;
212
209
} else if (CC_EQ (s ,i , "xdigit" )) {
213
210
if (ISXDIGIT (t_ch ))
214
- matched = TRUE ;
211
+ matched = 1 ;
215
212
} else /* malformed [:class:] string */
216
- return ABORT_ALL ;
213
+ return WM_ABORT_ALL ;
217
214
p_ch = 0 ; /* This makes "prev_ch" get set to 0. */
218
215
} else if (t_ch == p_ch )
219
- matched = TRUE ;
216
+ matched = 1 ;
220
217
} while (prev_ch = p_ch , (p_ch = * ++ p ) != ']' );
221
218
if (matched == negated || t_ch == '/' )
222
- return NOMATCH ;
219
+ return WM_NOMATCH ;
223
220
continue ;
224
221
}
225
222
}
226
223
227
- return * text ? NOMATCH : MATCH ;
224
+ return * text ? WM_NOMATCH : WM_MATCH ;
228
225
}
229
226
230
227
/* Match the "pattern" against the "text" string. */
231
- int wildmatch (const char * pattern , const char * text , int flags )
228
+ int wildmatch (const char * pattern , const char * text ,
229
+ unsigned int flags , struct wildopts * wo )
232
230
{
233
231
return dowild ((const uchar * )pattern , (const uchar * )text ,
234
- flags & FNM_CASEFOLD ? 1 :0 );
232
+ flags & WM_CASEFOLD ? 1 :0 );
235
233
}
0 commit comments