Changeset 105 for trunk/src/helpers/stringh.c
- Timestamp:
- Sep 27, 2001, 10:29:02 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/stringh.c
r94 r105 1914 1914 /* 1915 1915 * 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 * 1923 1927 * Note that this function is recursive. 1924 1928 * … … 1944 1948 if (*name == 0) 1945 1949 return FNM_MATCH; 1946 if ((flags & _FNM_PATHPREFIX) && IS_OS2_COMP_SEP(*name))1950 if ((flags & FNM_PATHPREFIX) && IS_OS2_COMP_SEP(*name)) 1947 1951 return FNM_MATCH; 1948 1952 return FNM_NOMATCH; … … 1959 1963 * is ignored at the end of NAME. */ 1960 1964 1961 if ((flags & _FNM_PATHPREFIX) && mask[1] == 0 && *name == 0)1965 if ((flags & FNM_PATHPREFIX) && mask[1] == 0 && *name == 0) 1962 1966 return FNM_MATCH; 1963 1967 … … 1994 1998 if (IS_OS2_COMP_END(*name)) 1995 1999 return FNM_NOMATCH; 1996 if (*name == '.' && (flags & _FNM_STYLE_MASK) == _FNM_DOS)2000 if (*name == '.' && (flags & FNM_STYLE_MASK) == FNM_DOS) 1997 2001 return FNM_NOMATCH; 1998 2002 ++name; … … 2015 2019 /* All other characters match themselves. */ 2016 2020 2017 if (flags & _FNM_IGNORECASE)2021 if (flags & FNM_IGNORECASE) 2018 2022 { 2019 2023 if (tolower(*mask) != tolower(*name)) … … 2033 2037 /* 2034 2038 * 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 * 2040 2047 * Return FNM_MATCH iff MASK and NAME match. 2041 2048 * … … 2049 2056 const unsigned char *s; 2050 2057 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: 2055 2062 2056 2063 /* For OS/2 and DOS styles, we add an implicit dot at the end of … … 2080 2087 /* 2081 2088 * 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 2085 2094 * backslash character is used for escaping ? and * unless 2086 2095 * FNM_NOESCAPE is set. … … 2110 2119 if (*name == 0) 2111 2120 return FNM_MATCH; 2112 if ((flags & _FNM_PATHPREFIX) && IS_UNIX_COMP_SEP(*name))2121 if ((flags & FNM_PATHPREFIX) && IS_UNIX_COMP_SEP(*name)) 2113 2122 return FNM_MATCH; 2114 2123 return FNM_NOMATCH; … … 2164 2173 2165 2174 if (!(IS_UNIX_COMP_SEP(*name) 2166 || ((flags & _FNM_PATHPREFIX) && *name == 02175 || ((flags & FNM_PATHPREFIX) && *name == 0 2167 2176 && (mask[1] == 0 2168 2177 || (!(flags & FNM_NOESCAPE) && mask[1] == '\\' … … 2292 2301 /* All other characters match themselves. */ 2293 2302 2294 if (flags & _FNM_IGNORECASE)2303 if (flags & FNM_IGNORECASE) 2295 2304 { 2296 2305 if (tolower(*mask) != tolower(*name)) … … 2327 2336 unsigned flags) 2328 2337 { 2329 int m_drive, n_drive, 2330 rc; 2338 int m_drive, 2339 n_drive, 2340 rc; 2331 2341 2332 2342 /* Match and skip the drive name if present. */ … … 2339 2349 if (m_drive == -1 || n_drive == -1) 2340 2350 return FNM_NOMATCH; 2341 if (!(flags & _FNM_IGNORECASE))2351 if (!(flags & FNM_IGNORECASE)) 2342 2352 return FNM_NOMATCH; 2343 2353 if (tolower(m_drive) != tolower(n_drive)) … … 2359 2369 * "\*\server\path". Ditto for /. */ 2360 2370 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: 2365 2375 2366 2376 if (IS_OS2_COMP_SEP(name[0]) && IS_OS2_COMP_SEP(name[1])) … … 2373 2383 break; 2374 2384 2375 case _FNM_POSIX:2385 case FNM_POSIX: 2376 2386 2377 2387 if (name[0] == '/' && name[1] == '/') … … 2404 2414 * is reached even if there are components left in NAME. */ 2405 2415 2406 if (*mask == 0 && (flags & _FNM_PATHPREFIX))2416 if (*mask == 0 && (flags & FNM_PATHPREFIX)) 2407 2417 return FNM_MATCH; 2408 2418 … … 2436 2446 */ 2437 2447 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) 2448 BOOL 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 2466 BOOL 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) 2444 2473 == FNM_MATCH) 2445 2474 );
Note:
See TracChangeset
for help on using the changeset viewer.