Changeset 834 for trunk/dll/literal.c
- Timestamp:
- Sep 12, 2007, 9:20:07 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/literal.c
r832 r834 204 204 const BOOL fNotFileSpec) 205 205 { 206 207 const CHAR *fstr = strrev(pszBuf);208 PSZ fcard = strrev(pszWildCard);206 const CHAR *fstr = pszBuf; 207 PSZ fcard = pszWildCard; 208 CHAR *tcard; 209 209 INT wmatch = TRUE; 210 BOOL reverse = FALSE; 211 210 212 while (wmatch && *fcard && *fstr) { 211 switch (*fcard) { 212 case '?': /* character substitution */ 213 fcard++; 214 if (fNotFileSpec || (*fstr != '.' && *fstr != '/' && *fstr != '\\')) 215 fstr++; /* skip (match) next character */ 216 break; 217 218 case '*': 219 /* find next non-wild character in wildcard */ 220 while (*fcard && (*fcard == '?' || *fcard == '*')) 221 fcard++; 222 if (!*fcard){ /* if last char of wildcard is *, it matches */ 213 if (*fcard == '*' && fcard[strlen(fcard) - 1] == '*' && !reverse){ 214 tcard = xstrdup(fcard + 1, __FILE__, __LINE__); 215 tcard[strlen(tcard) - 1] = 0; 216 if (!(strchr(tcard, '?')) && !(strchr(tcard, '*'))){ 217 if (strstr(fstr, tcard)){ //strstr match for *stuff* pattern no wildcards in "stuff" 218 xfree(tcard); 219 return TRUE; 220 } 221 else{ 222 xfree(tcard); 223 return FALSE; 224 } 225 } 226 xfree(tcard); 227 } 228 else //reverse search for *stuff pattern "stuff" can contain wildcards 229 if (*fcard == '*' && fcard[strlen(fcard) - 1] != '*'){ 223 230 fstr = strrev(pszBuf); 224 231 fcard = strrev(pszWildCard); 225 return TRUE; 226 } 227 /* skip until partition, match, or eos */ 228 while (*fstr && toupper(*fstr) != toupper(*fcard) && 229 (fNotFileSpec || (*fstr != '\\' && 230 *fstr != '/' && *fstr != '.'))) 232 reverse = TRUE; 233 } 234 switch (*fcard) { //fm2 standard forward search for all other cases 235 case '?': /* character substitution */ 236 fcard++; 237 if (fNotFileSpec || (*fstr != '.' && *fstr != '/' && *fstr != '\\')) 238 fstr++; /* skip (match) next character */ 239 break; 240 241 case '*': 242 /* find next non-wild character in wildcard */ 243 while (*fcard && (*fcard == '?' || *fcard == '*')) 244 fcard++; 245 if (!*fcard){ /* if last char of wildcard is *, it matches */ 246 if (reverse){ 247 fstr = strrev(pszBuf); 248 fcard = strrev(pszWildCard); 249 } 250 return TRUE; 251 } 252 /* skip until partition, match, or eos */ 253 while (*fstr && toupper(*fstr) != toupper(*fcard) && 254 (fNotFileSpec || (*fstr != '\\' && 255 *fstr != '/' && *fstr != '.'))) 256 fstr++; 257 if (!fNotFileSpec && !*fstr) /* implicit '.' */ 258 if (*fcard == '.') 259 fcard++; 260 break; 261 262 default: 263 if (!fNotFileSpec && ((*fstr == '/' || *fstr == '\\') && 264 (*fcard == '/' || *fcard == '\\'))) 265 wmatch = TRUE; 266 else 267 wmatch = (toupper(*fstr) == toupper(*fcard)); 231 268 fstr++; 232 if (!fNotFileSpec && !*fstr) /* implicit '.' */ 233 if (*fcard == '.') 234 fcard++; 235 break; 236 237 default: 238 if (!fNotFileSpec && ((*fstr == '/' || *fstr == '\\') && 239 (*fcard == '/' || *fcard == '\\'))) 240 wmatch = TRUE; 241 else 242 wmatch = (toupper(*fstr) == toupper(*fcard)); 243 fstr++; 244 fcard++; 245 break; 269 fcard++; 270 break; 271 } 272 } //while 273 274 if ((*fcard && *fcard != '*') || *fstr){ 275 if (reverse){ 276 fstr = strrev(pszBuf); 277 fcard = strrev(pszWildCard); 246 278 } 247 }248 if ((*fcard && *fcard != '*') || *fstr){249 fstr = strrev(pszBuf);250 fcard = strrev(pszWildCard);251 279 return 0; 252 280 } 253 else{ 254 fstr = strrev(pszBuf); 255 fcard = strrev(pszWildCard); 281 else { 282 if (reverse){ 283 fstr = strrev(pszBuf); 284 fcard = strrev(pszWildCard); 285 } 256 286 return wmatch; 257 287 } 258 }259 260 BOOL wildcard2(const PSZ pszBuf, const PSZ pszWildCard,261 const BOOL fNotFileSpec)262 {263 const CHAR *fstr = pszBuf;264 PSZ fcard = pszWildCard;265 CHAR tcard[50];266 INT wmatch = TRUE;267 268 while (wmatch && *fcard && *fstr) {269 switch (*fcard) {270 case '?': /* character substitution */271 fcard++;272 if (fNotFileSpec || (*fstr != '.' && *fstr != '/' && *fstr != '\\'))273 fstr++; /* skip (match) next character */274 break;275 276 case '*':277 /* find next non-wild character in wildcard */278 while (*fcard && (*fcard == '?' || *fcard == '*'))279 fcard++;280 if (!*fcard) /* if last char of wildcard is *, it matches */281 return TRUE;282 /* skip until partition, match, or eos */283 while (*fstr && toupper(*fstr) != toupper(*fcard) &&284 (fNotFileSpec || (*fstr != '\\' &&285 *fstr != '/' && *fstr != '.')))286 fstr++;287 if (!fNotFileSpec && !*fstr) /* implicit '.' */288 if (*fcard == '.')289 fcard++;290 break;291 292 default:293 if (!fNotFileSpec && ((*fstr == '/' || *fstr == '\\') &&294 (*fcard == '/' || *fcard == '\\')))295 wmatch = TRUE;296 else297 wmatch = (toupper(*fstr) == toupper(*fcard));298 fstr++;299 fcard++;300 break;301 }302 } //while303 304 if ((*fcard && *fcard != '*') || *fstr)305 return 0;306 else307 return wmatch;308 288 } 309 289 … … 357 337 } 358 338 359 #pragma alloc_text(LITERAL,literal,index,fixup,wildcard , wildcard2)360 339 #pragma alloc_text(LITERAL,literal,index,fixup,wildcard) 340
Note:
See TracChangeset
for help on using the changeset viewer.