Ignore:
Timestamp:
Jan 31, 2002, 11:12:45 PM (24 years ago)
Author:
umoeller
Message:

Misc speed improvements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/dosh2.c

    r129 r135  
    21132113 *          one will.
    21142114 *
     2115 *      --  THIS COMPARES WITH RESPECT TO CASE.
     2116 *
    21152117 *      This replaces strhMatchOS2 which has been removed with
    21162118 *      V0.9.16 and is a lot faster than the old code, which has
     
    21202122 */
    21212123
    2122 BOOL doshMatch(const char *pcszMask,     // in: mask (e.g. "*.txt")
    2123                const char *pcszName)     // in: string to check (e.g. "test.txt")
     2124BOOL doshMatchCase(const char *pcszMask,     // in: mask (e.g. "*.TXT")
     2125                   const char *pcszName)     // in: string to check (e.g. "TEST.TXT")
    21242126{
    21252127    BOOL    brc = FALSE;
     
    21282130            iNameDrive = -1;
    21292131
    2130     ULONG   cbMask = strlen(pcszMask),
    2131             cbName = strlen(pcszName);
    2132     PSZ     pszMask = (PSZ)_alloca(cbMask + 1),
    2133             pszName = (PSZ)_alloca(cbName + 1);
     2132    // ULONG   cbMask = strlen(pcszMask),
     2133    //         cbName = strlen(pcszName);
     2134    // PSZ     pszMask = (PSZ)_alloca(cbMask + 1),
     2135    //         pszName = (PSZ)_alloca(cbName + 1);
    21342136
    21352137    PCSZ    pLastMaskComponent,
     
    21412143    CHAR    c;
    21422144
    2143     memcpy(pszMask, pcszMask, cbMask + 1);
    2144     nlsUpper(pszMask, cbMask);
    2145     memcpy(pszName, pcszName, cbName + 1);
    2146     nlsUpper(pszName, cbName);
    2147 
    2148     if (pLastMaskComponent = strrchr(pszMask, '\\'))
     2145    if (pLastMaskComponent = strrchr(pcszMask, '\\'))
    21492146    {
    21502147        // length of path component
    2151         cbMaskPath = pLastMaskComponent - pszMask;
     2148        cbMaskPath = pLastMaskComponent - pcszMask;
    21522149        pLastMaskComponent++;
    21532150    }
    21542151    else
    2155         pLastMaskComponent = pszMask;
    2156 
    2157     if (pLastNameComponent = strrchr(pszName, '\\'))
     2152        pLastMaskComponent = pcszMask;
     2153
     2154    if (pLastNameComponent = strrchr(pcszName, '\\'))
    21582155    {
    21592156        // length of path component
    2160         cbNamePath = pLastNameComponent - pszName;
     2157        cbNamePath = pLastNameComponent - pcszName;
    21612158        pLastNameComponent++;
    21622159    }
    21632160    else
    2164         pLastNameComponent = pszName;
     2161        pLastNameComponent = pcszName;
    21652162
    21662163    // compare paths; if the lengths are different
     
    21682165    if (    (cbMaskPath == cbNamePath)      // can both be null
    21692166         && (    (cbMaskPath == 0)
    2170               || (!memcmp(pszMask, pszName, cbMaskPath))
     2167              || (!memcmp(pcszMask, pcszName, cbMaskPath))
    21712168            )
    21722169       )
     
    21832180}
    21842181
    2185 
     2182/*
     2183 *@@ doshMatch:
     2184 *      like doshMatchCase, but compares without respect
     2185 *      to case.
     2186 *
     2187 *@@added V0.9.16 (2002-01-26) [umoeller]
     2188 */
     2189
     2190BOOL doshMatch(const char *pcszMask,     // in: mask (e.g. "*.TXT")
     2191               const char *pcszName)     // in: string to check (e.g. "TEST.TXT")
     2192{
     2193    ULONG   cbMask = strlen(pcszMask),
     2194            cbName = strlen(pcszName);
     2195    PSZ     pszMask = (PSZ)_alloca(cbMask + 1),
     2196            pszName = (PSZ)_alloca(cbName + 1);
     2197
     2198    memcpy(pszMask, pcszMask, cbMask + 1);
     2199    nlsUpper(pszMask, cbMask);
     2200    memcpy(pszName, pcszName, cbName + 1);
     2201    nlsUpper(pszName, cbName);
     2202
     2203    return (doshMatchCase(pszMask,
     2204                          pszName));
     2205}
Note: See TracChangeset for help on using the changeset viewer.