Changeset 1039 for trunk/dll/literal.c
- Timestamp:
- Jul 6, 2008, 12:16:21 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/dll/literal.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/literal.c
r1009 r1039 32 32 #include "errutil.h" // Dos_Error... 33 33 #include "fm3dll.h" 34 #include "fortify.h" 34 35 35 36 static PSZ pszSrcFile = __FILE__; … … 194 195 cBufBytes = pszOut - pszWork; /* Calc string length excluding terminator */ 195 196 memcpy(pszBuf, pszWork, cBufBytes + 1); /* Overwrite including terminator */ 196 xfree(pszWork, pszSrcFile, __LINE__);197 free(pszWork); 197 198 198 199 return cBufBytes; /* Return string length */ … … 280 281 return (*fstr == *fcard); 281 282 } 282 283 284 /*BOOL wildcard(const PSZ pszBuf, const PSZ pszWildCard,285 const BOOL fNotFileSpec)286 {287 const CHAR *fstr = pszBuf;288 PSZ fcard = pszWildCard;289 CHAR *tcard;290 INT wmatch = TRUE;291 BOOL reverse = FALSE;292 293 while (wmatch && *fcard && *fstr) {294 if (*fcard == '*' && fcard[strlen(fcard) - 1] == '*' && !reverse){295 tcard = xstrdup(fcard + 1, __FILE__, __LINE__);296 tcard[strlen(tcard) - 1] = 0;297 if (!(strchr(tcard, '?')) && !(strchr(tcard, '*'))){298 if (strstr(fstr, tcard)){ //strstr match for *stuff* pattern no wildcards in "stuff"299 xfree(tcard, pszSrcFile, __LINE__);300 return TRUE;301 }302 else{303 xfree(tcard, pszSrcFile, __LINE__);304 return FALSE;305 }306 }307 xfree(tcard, pszSrcFile, __LINE__);308 }309 else //reverse search for *stuff pattern "stuff" can contain wildcards310 if (*fcard == '*' && fcard[strlen(fcard) - 1] != '*'){311 fstr = strrev(pszBuf);312 fcard = strrev(pszWildCard);313 reverse = TRUE;314 }315 switch (*fcard) { //fm2 standard forward search for all other cases316 case '?': // character substitution /317 fcard++;318 if (fNotFileSpec || (*fstr != '.' && *fstr != '/' && *fstr != '\\'))319 fstr++; // skip (match) next character320 break;321 322 case '*':323 // find next non-wild character in wildcard324 while (*fcard && (*fcard == '?' || *fcard == '*'))325 fcard++;326 if (!*fcard){ // if last char of wildcard is *, it matches327 if (reverse){328 fstr = strrev(pszBuf);329 fcard = strrev(pszWildCard);330 }331 return TRUE;332 }333 // skip until partition, match, or eos334 while (*fstr && toupper(*fstr) != toupper(*fcard) &&335 (fNotFileSpec || (*fstr != '\\' &&336 *fstr != '/' && *fstr != '.')))337 fstr++;338 if (!fNotFileSpec && !*fstr) // implicit '.'339 if (*fcard == '.')340 fcard++;341 break;342 343 default:344 if (!fNotFileSpec && ((*fstr == '/' || *fstr == '\\') &&345 (*fcard == '/' || *fcard == '\\')))346 wmatch = TRUE;347 else348 wmatch = (toupper(*fstr) == toupper(*fcard));349 fstr++;350 fcard++;351 break;352 }353 } //while354 355 if ((*fcard && *fcard != '*') || *fstr){356 if (reverse){357 fstr = strrev(pszBuf);358 fcard = strrev(pszWildCard);359 }360 return 0;361 }362 else {363 if (reverse){364 fstr = strrev(pszBuf);365 fcard = strrev(pszWildCard);366 }367 return wmatch;368 }369 } */370 371 283 372 284 // fixup - quote literal character array
Note:
See TracChangeset
for help on using the changeset viewer.
