Changeset 999 for trunk/dll/literal.c
- Timestamp:
- Mar 15, 2008, 7:34:05 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/literal.c
r985 r999 18 18 16 Nov 07 SHL Report fixup buffer overflow 19 19 29 Feb 08 GKY Use xfree where appropriate 20 15 Mar 08 KOMH Fix wildcard for multiple dots 20 21 21 22 ***********************************************************************/ … … 198 199 } 199 200 200 /* Check wildcard match201 /** Check wildcard match 201 202 * @parm pszBuf Buffer to check 202 203 * @parm pszWildCard wildcard to match … … 206 207 207 208 BOOL wildcard(const PSZ pszBuf, const PSZ pszWildCard, 209 const BOOL fNotFileSpec) 210 { 211 PSZ fstr = pszBuf; 212 PSZ fcard = pszWildCard; 213 214 while (*fstr && *fcard) { 215 switch (*fcard) { 216 case '*' : 217 { 218 PSZ fstr1; 219 220 // find next non-wild character in wildcard 221 while (*fcard && ( *fcard == '*' || *fcard == '?')) 222 fcard++; 223 224 // if last char of wildcard is *, it matches 225 if (!*fcard) 226 return TRUE; 227 228 fstr1 = fstr; 229 while (*fstr1) { 230 // skip until partition, match, or eos 231 while (*fstr1 && toupper( *fstr1 ) != toupper( *fcard ) && 232 (fNotFileSpec || ( *fstr1 != '/' && *fstr1 != '\\'))) 233 fstr1++; 234 235 if (!*fstr1 || ( !fNotFileSpec && ( *fstr1 == '/' || *fstr1 == '\\'))) 236 break; 237 238 if (wildcard( fstr1, fcard, fNotFileSpec ) == TRUE) 239 return TRUE; 240 241 fstr1++; 242 } 243 244 fstr = fstr1; 245 break; 246 } 247 248 case '?' : // character substitution 249 fcard++; 250 251 if (fNotFileSpec || ( *fstr != '.' && *fstr != '/' && *fstr != '\\')) 252 fstr++; // skip (match) next character 253 break; 254 255 default : 256 if (fNotFileSpec || (*fstr != '/' && *fstr != '\\') || 257 (*fcard != '/' && *fcard != '\\')) { 258 if (toupper( *fstr ) != toupper( *fcard)) 259 return FALSE; 260 } 261 262 fcard++; 263 fstr++; 264 break; 265 } 266 } 267 268 if (!*fstr) { 269 // remove trailing * and ? 270 while (*fcard && ( *fcard == '?' || *fcard == '*')) 271 fcard++; 272 273 if (!fNotFileSpec) { 274 // remove trailing . 275 while (*fcard && *fcard == '.') 276 fcard++; 277 } 278 } 279 280 return (*fstr == *fcard); 281 } 282 283 284 /*BOOL wildcard(const PSZ pszBuf, const PSZ pszWildCard, 208 285 const BOOL fNotFileSpec) 209 286 { … … 237 314 } 238 315 switch (*fcard) { //fm2 standard forward search for all other cases 239 case '?': / * character substitution */316 case '?': // character substitution / 240 317 fcard++; 241 318 if (fNotFileSpec || (*fstr != '.' && *fstr != '/' && *fstr != '\\')) 242 fstr++; / * skip (match) next character */319 fstr++; // skip (match) next character 243 320 break; 244 321 245 322 case '*': 246 / * find next non-wild character in wildcard */323 // find next non-wild character in wildcard 247 324 while (*fcard && (*fcard == '?' || *fcard == '*')) 248 325 fcard++; 249 if (!*fcard){ / * if last char of wildcard is *, it matches */326 if (!*fcard){ // if last char of wildcard is *, it matches 250 327 if (reverse){ 251 328 fstr = strrev(pszBuf); … … 254 331 return TRUE; 255 332 } 256 / * skip until partition, match, or eos */333 // skip until partition, match, or eos 257 334 while (*fstr && toupper(*fstr) != toupper(*fcard) && 258 335 (fNotFileSpec || (*fstr != '\\' && 259 336 *fstr != '/' && *fstr != '.'))) 260 337 fstr++; 261 if (!fNotFileSpec && !*fstr) / * implicit '.' */338 if (!fNotFileSpec && !*fstr) // implicit '.' 262 339 if (*fcard == '.') 263 340 fcard++; … … 290 367 return wmatch; 291 368 } 292 } 369 } */ 293 370 294 371
Note:
See TracChangeset
for help on using the changeset viewer.