Changeset 1039 for trunk/dll/literal.c


Ignore:
Timestamp:
Jul 6, 2008, 12:16:21 AM (17 years ago)
Author:
Gregg Young
Message:

Removed unnecessary xfrees and included fortify.h where needed; moved several misplaced (x)frees;

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/literal.c

    r1009 r1039  
    3232#include "errutil.h"                    // Dos_Error...
    3333#include "fm3dll.h"
     34#include "fortify.h"
    3435
    3536static PSZ pszSrcFile = __FILE__;
     
    194195  cBufBytes = pszOut - pszWork;                /* Calc string length excluding terminator */
    195196  memcpy(pszBuf, pszWork, cBufBytes + 1);        /* Overwrite including terminator */
    196   xfree(pszWork, pszSrcFile, __LINE__);
     197  free(pszWork);
    197198
    198199  return cBufBytes;                        /* Return string length */
     
    280281    return (*fstr == *fcard);
    281282}
    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 wildcards
    310       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 cases
    316       case '?':                                // character substitution /
    317         fcard++;
    318         if (fNotFileSpec || (*fstr != '.' && *fstr != '/' && *fstr != '\\'))
    319           fstr++;                                // skip (match) next character
    320         break;
    321 
    322       case '*':
    323         // find next non-wild character in wildcard
    324         while (*fcard && (*fcard == '?' || *fcard == '*'))
    325           fcard++;
    326         if (!*fcard){                        // if last char of wildcard is *, it matches
    327           if (reverse){
    328             fstr = strrev(pszBuf);
    329             fcard = strrev(pszWildCard);
    330           }
    331           return TRUE;
    332         }
    333         // skip until partition, match, or eos
    334         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         else
    348           wmatch = (toupper(*fstr) == toupper(*fcard));
    349         fstr++;
    350         fcard++;
    351         break;
    352       }
    353   }  //while
    354 
    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 
    371283
    372284// fixup - quote literal character array
Note: See TracChangeset for help on using the changeset viewer.