Changeset 832 for trunk/dll/literal.c


Ignore:
Timestamp:
Sep 5, 2007, 4:09:22 AM (18 years ago)
Author:
Gregg Young
Message:

Initial implimentation of a more flexible mask matching system to address multiple "." in file names

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/literal.c

    r795 r832  
    204204              const BOOL fNotFileSpec)
    205205{
    206   const CHAR *fstr = pszBuf;
    207   PSZ fcard = pszWildCard;
     206
     207  const CHAR *fstr = strrev(pszBuf);
     208  PSZ fcard = strrev(pszWildCard);
    208209  INT wmatch = TRUE;
    209 
    210210  while (wmatch && *fcard && *fstr) {
    211     switch (*fcard) {
     211  switch (*fcard) {
    212212    case '?':                                /* character substitution */
    213213      fcard++;
     
    219219      /* find next non-wild character in wildcard */
    220220      while (*fcard && (*fcard == '?' || *fcard == '*'))
    221         fcard++;
    222       if (!*fcard)                        /* if last char of wildcard is *, it matches */
     221       fcard++;
     222      if (!*fcard){                        /* if last char of wildcard is *, it matches */
     223        fstr = strrev(pszBuf);
     224        fcard = strrev(pszWildCard);
    223225        return TRUE;
     226      }
    224227      /* skip until partition, match, or eos */
    225228      while (*fstr && toupper(*fstr) != toupper(*fcard) &&
    226229             (fNotFileSpec || (*fstr != '\\' &&
    227                                *fstr != '/' && *fstr != '.')))
     230                             *fstr != '/' && *fstr != '.')))
    228231        fstr++;
    229232      if (!fNotFileSpec && !*fstr)        /* implicit '.' */
     
    234237    default:
    235238      if (!fNotFileSpec && ((*fstr == '/' || *fstr == '\\') &&
    236                             (*fcard == '/' || *fcard == '\\')))
     239                          (*fcard == '/' || *fcard == '\\')))
    237240        wmatch = TRUE;
    238241      else
     
    243246    }
    244247  }
     248  if ((*fcard && *fcard != '*') || *fstr){
     249    fstr = strrev(pszBuf);
     250    fcard = strrev(pszWildCard);
     251    return 0;
     252  }
     253  else{
     254    fstr = strrev(pszBuf);
     255    fcard = strrev(pszWildCard);
     256    return wmatch;
     257  }
     258}
     259
     260BOOL 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         else
     297           wmatch = (toupper(*fstr) == toupper(*fcard));
     298         fstr++;
     299         fcard++;
     300         break;
     301       }
     302  }  //while
    245303
    246304  if ((*fcard && *fcard != '*') || *fstr)
     
    249307    return wmatch;
    250308}
     309
    251310
    252311// fixup - quote literal character array
     
    298357}
    299358
    300 #pragma alloc_text(LITERAL,literal,index,fixup,wildcard)
    301 
     359#pragma alloc_text(LITERAL,literal,index,fixup,wildcard, wildcard2)
     360
Note: See TracChangeset for help on using the changeset viewer.