Ignore:
Timestamp:
Sep 27, 2001, 10:29:02 PM (24 years ago)
Author:
umoeller
Message:

Misc changes.

File:
1 edited

Legend:

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

    r94 r105  
    19141914/*
    19151915 * match_comp_os2:
    1916  *      Compare a single component (directory name or file name) of the
    1917  *      paths, for OS/2 and DOS styles.  MASK and NAME point into a
    1918  *      component of the wildcard and the name to be checked, respectively.
    1919  *      Comparing stops at the next separator.  The FLAGS argument is the
    1920  *      same as that of fnmatch().  HAS_DOT is true if a dot is in the
    1921  *      current component of NAME.  The number of dots is not restricted,
    1922  *      even in DOS style.  Return FNM_MATCH iff MASK and NAME match.
     1916 *      compares a single component (directory name or file name)
     1917 *      of the paths, for OS/2 and DOS styles. MASK and NAME point
     1918 *      into a component of the wildcard and the name to be checked,
     1919 *      respectively. Comparing stops at the next separator.
     1920 *      The FLAGS argument is the same as that of fnmatch().
     1921 *
     1922 *      HAS_DOT is true if a dot is in the current component of NAME.
     1923 *      The number of dots is not restricted, even in DOS style.
     1924 *
     1925 *      Returns FNM_MATCH iff MASK and NAME match.
     1926 *
    19231927 *      Note that this function is recursive.
    19241928 *
     
    19441948                if (*name == 0)
    19451949                    return FNM_MATCH;
    1946                 if ((flags & _FNM_PATHPREFIX) && IS_OS2_COMP_SEP(*name))
     1950                if ((flags & FNM_PATHPREFIX) && IS_OS2_COMP_SEP(*name))
    19471951                    return FNM_MATCH;
    19481952                return FNM_NOMATCH;
     
    19591963                 * is ignored at the end of NAME. */
    19601964
    1961                 if ((flags & _FNM_PATHPREFIX) && mask[1] == 0 && *name == 0)
     1965                if ((flags & FNM_PATHPREFIX) && mask[1] == 0 && *name == 0)
    19621966                    return FNM_MATCH;
    19631967
     
    19941998                    if (IS_OS2_COMP_END(*name))
    19951999                        return FNM_NOMATCH;
    1996                     if (*name == '.' && (flags & _FNM_STYLE_MASK) == _FNM_DOS)
     2000                    if (*name == '.' && (flags & FNM_STYLE_MASK) == FNM_DOS)
    19972001                        return FNM_NOMATCH;
    19982002                    ++name;
     
    20152019                /* All other characters match themselves. */
    20162020
    2017                 if (flags & _FNM_IGNORECASE)
     2021                if (flags & FNM_IGNORECASE)
    20182022                {
    20192023                    if (tolower(*mask) != tolower(*name))
     
    20332037/*
    20342038 * match_comp:
    2035  *      compare a single component (directory name or file name) of the
    2036  *      paths, for all styles which need component-by-component matching.
    2037  *      MASK and NAME point to the start of a component of the wildcard and
    2038  *      the name to be checked, respectively.  Comparing stops at the next
    2039  *      separator.  The FLAGS argument is the same as that of fnmatch().
     2039 *      compares a single component (directory name or file
     2040 *      name) of the paths, for all styles which need
     2041 *      component-by-component matching. MASK and NAME point
     2042 *      to the start of a component of the wildcard and the
     2043 *      name to be checked, respectively.  Comparing stops at
     2044 *      the next separator. The FLAGS argument is the same as
     2045 *      that of fnmatch().
     2046 *
    20402047 *      Return FNM_MATCH iff MASK and NAME match.
    20412048 *
     
    20492056    const unsigned char *s;
    20502057
    2051     switch (flags & _FNM_STYLE_MASK)
    2052     {
    2053         case _FNM_OS2:
    2054         case _FNM_DOS:
     2058    switch (flags & FNM_STYLE_MASK)
     2059    {
     2060        case FNM_OS2:
     2061        case FNM_DOS:
    20552062
    20562063            /* For OS/2 and DOS styles, we add an implicit dot at the end of
     
    20802087/*
    20812088 * match_unix:
    2082  *      match complete paths for Unix styles.  The FLAGS argument is the
    2083  *      same as that of fnmatch().  COMP points to the start of the current
    2084  *      component in NAME.  Return FNM_MATCH iff MASK and NAME match.  The
     2089 *      matches complete paths for Unix styles.
     2090 *
     2091 *      The FLAGS argument is the same as that of fnmatch().
     2092 *      COMP points to the start of the current component in
     2093 *      NAME.  Return FNM_MATCH iff MASK and NAME match.  The
    20852094 *      backslash character is used for escaping ? and * unless
    20862095 *      FNM_NOESCAPE is set.
     
    21102119                if (*name == 0)
    21112120                    return FNM_MATCH;
    2112                 if ((flags & _FNM_PATHPREFIX) && IS_UNIX_COMP_SEP(*name))
     2121                if ((flags & FNM_PATHPREFIX) && IS_UNIX_COMP_SEP(*name))
    21132122                    return FNM_MATCH;
    21142123                return FNM_NOMATCH;
     
    21642173
    21652174                if (!(IS_UNIX_COMP_SEP(*name)
    2166                       || ((flags & _FNM_PATHPREFIX) && *name == 0
     2175                      || ((flags & FNM_PATHPREFIX) && *name == 0
    21672176                      && (mask[1] == 0
    21682177                          || (!(flags & FNM_NOESCAPE) && mask[1] == '\\'
     
    22922301                /* All other characters match themselves. */
    22932302
    2294                 if (flags & _FNM_IGNORECASE)
     2303                if (flags & FNM_IGNORECASE)
    22952304                {
    22962305                    if (tolower(*mask) != tolower(*name))
     
    23272336                             unsigned flags)
    23282337{
    2329     int             m_drive, n_drive,
    2330                     rc;
     2338    int     m_drive,
     2339            n_drive,
     2340            rc;
    23312341
    23322342    /* Match and skip the drive name if present. */
     
    23392349        if (m_drive == -1 || n_drive == -1)
    23402350            return FNM_NOMATCH;
    2341         if (!(flags & _FNM_IGNORECASE))
     2351        if (!(flags & FNM_IGNORECASE))
    23422352            return FNM_NOMATCH;
    23432353        if (tolower(m_drive) != tolower(n_drive))
     
    23592369     * "\*\server\path".  Ditto for /. */
    23602370
    2361     switch (flags & _FNM_STYLE_MASK)
    2362     {
    2363         case _FNM_OS2:
    2364         case _FNM_DOS:
     2371    switch (flags & FNM_STYLE_MASK)
     2372    {
     2373        case FNM_OS2:
     2374        case FNM_DOS:
    23652375
    23662376            if (IS_OS2_COMP_SEP(name[0]) && IS_OS2_COMP_SEP(name[1]))
     
    23732383            break;
    23742384
    2375         case _FNM_POSIX:
     2385        case FNM_POSIX:
    23762386
    23772387            if (name[0] == '/' && name[1] == '/')
     
    24042414         * is reached even if there are components left in NAME. */
    24052415
    2406         if (*mask == 0 && (flags & _FNM_PATHPREFIX))
     2416        if (*mask == 0 && (flags & FNM_PATHPREFIX))
    24072417            return FNM_MATCH;
    24082418
     
    24362446 */
    24372447
    2438 BOOL strhMatchOS2(const unsigned char* pcszMask,     // in: mask (e.g. "*.txt")
    2439                   const unsigned char* pcszName)     // in: string to check (e.g. "test.txt")
    2440 {
    2441     return ((BOOL)(_fnmatch_unsigned(pcszMask,
    2442                                      pcszName,
    2443                                      _FNM_OS2 | _FNM_IGNORECASE)
     2448BOOL strhMatchOS2(const char *pcszMask,     // in: mask (e.g. "*.txt")
     2449                  const char *pcszName)     // in: string to check (e.g. "test.txt")
     2450{
     2451    return ((BOOL)(_fnmatch_unsigned((const unsigned char *)pcszMask,
     2452                                     (const unsigned char *)pcszName,
     2453                                     FNM_OS2 | FNM_IGNORECASE)
     2454                   == FNM_MATCH)
     2455           );
     2456}
     2457
     2458/*
     2459 *@@ strhMatchExt:
     2460 *      like strhMatchOS2, but this takes all the flags
     2461 *      for input.
     2462 *
     2463 *@@added V0.9.15 (2001-09-14) [umoeller]
     2464 */
     2465
     2466BOOL strhMatchExt(const char *pcszMask,     // in: mask (e.g. "*.txt")
     2467                  const char *pcszName,     // in: string to check (e.g. "test.txt")
     2468                  unsigned flags)           // in: FNM_* flags
     2469{
     2470    return ((BOOL)(_fnmatch_unsigned((const unsigned char *)pcszMask,
     2471                                     (const unsigned char *)pcszName,
     2472                                     flags)
    24442473                   == FNM_MATCH)
    24452474           );
Note: See TracChangeset for help on using the changeset viewer.