Removed imap_match().
Showing
1 changed file
with
14 additions
and
51 deletions
... | @@ -53,7 +53,6 @@ struct inode_list | ... | @@ -53,7 +53,6 @@ struct inode_list |
53 | but it does not match ahierarchy delimiter. */ | 53 | but it does not match ahierarchy delimiter. */ |
54 | 54 | ||
55 | static int match __P ((const char *, const char *, const char *)); | 55 | static int match __P ((const char *, const char *, const char *)); |
56 | static int imap_match __P ((const char *, const char *, const char *)); | ||
57 | static void list_file __P ((const char *, const char *, const char *, const char *, struct inode_list *)); | 56 | static void list_file __P ((const char *, const char *, const char *, const char *, struct inode_list *)); |
58 | static void print_file __P ((const char *, const char *, const char *)); | 57 | static void print_file __P ((const char *, const char *, const char *)); |
59 | static void print_dir __P ((const char *, const char *, const char *)); | 58 | static void print_dir __P ((const char *, const char *, const char *)); |
... | @@ -328,7 +327,20 @@ static int | ... | @@ -328,7 +327,20 @@ static int |
328 | match (const char *entry, const char *pattern, const char *delim) | 327 | match (const char *entry, const char *pattern, const char *delim) |
329 | { | 328 | { |
330 | struct stat stats; | 329 | struct stat stats; |
331 | int status = imap_match (entry, pattern, delim); | 330 | int status = util_wcard_match (entry, pattern, delim); |
331 | |||
332 | switch (status) | ||
333 | { | ||
334 | case WCARD_RECURSE_MATCH: | ||
335 | status = RECURSE_MATCH; | ||
336 | break; | ||
337 | case WCARD_MATCH: | ||
338 | status = MATCH; | ||
339 | break; | ||
340 | case WCARD_NOMATCH: | ||
341 | status = NOMATCH; | ||
342 | } | ||
343 | |||
332 | if (status) | 344 | if (status) |
333 | { | 345 | { |
334 | if (stat (entry, &stats) == 0) | 346 | if (stat (entry, &stats) == 0) |
... | @@ -337,52 +349,3 @@ match (const char *entry, const char *pattern, const char *delim) | ... | @@ -337,52 +349,3 @@ match (const char *entry, const char *pattern, const char *delim) |
337 | return status; | 349 | return status; |
338 | } | 350 | } |
339 | 351 | ||
340 | /* Match STRING against the filename pattern PATTERN, returning zero if | ||
341 | it matches, nonzero if not. */ | ||
342 | static int | ||
343 | imap_match (const char *string, const char *pattern, const char *delim) | ||
344 | { | ||
345 | const char *p = pattern, *n = string; | ||
346 | char c; | ||
347 | |||
348 | for (;(c = *p++) != '\0' && *n; n++) | ||
349 | { | ||
350 | switch (c) | ||
351 | { | ||
352 | case '%': | ||
353 | if (*p == '\0') | ||
354 | { | ||
355 | /* Matches everything except '/' */ | ||
356 | for (; *n && *n != delim[0]; n++) | ||
357 | ; | ||
358 | return (*n == '/') ? RECURSE_MATCH : MATCH; | ||
359 | } | ||
360 | else | ||
361 | for (; *n != '\0'; ++n) | ||
362 | if (imap_match (n, p, delim) == MATCH) | ||
363 | return MATCH; | ||
364 | break; | ||
365 | |||
366 | case '*': | ||
367 | if (*p == '\0') | ||
368 | return RECURSE_MATCH; | ||
369 | for (; *n != '\0'; ++n) | ||
370 | { | ||
371 | int status = imap_match (n, p, delim); | ||
372 | if (status == MATCH || status == RECURSE_MATCH) | ||
373 | return status; | ||
374 | } | ||
375 | break; | ||
376 | |||
377 | default: | ||
378 | if (c != *n) | ||
379 | return NOMATCH; | ||
380 | } | ||
381 | } | ||
382 | |||
383 | if (!c && !*n) | ||
384 | return MATCH; | ||
385 | |||
386 | return NOMATCH; | ||
387 | |||
388 | } | ... | ... |
-
Please register or sign in to post a comment