The MinGW.org Windows System Libraries
Revision | 3b6176993803b355a0ad5eb704e3783f7df8cbbd (tree) |
---|---|
Time | 2013-10-22 05:28:32 |
Author | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
Fix bug [#2062]: preserve case in patterns without glob tokens.
@@ -1,5 +1,13 @@ | ||
1 | 1 | RELEASE 4.1: |
2 | 2 | |
3 | +2013-10-21 Keith Marshall <keithmarshall@users.sourceforge.net> | |
4 | + | |
5 | + Fix bug [#2062]: preserve case in patterns without glob tokens. | |
6 | + | |
7 | + * src/libcrt/misc/glob.c (accept_glob_nocheck_match): New static | |
8 | + inline function; it identifies the situation for case preservation. | |
9 | + (glob_match): Use it. | |
10 | + | |
3 | 11 | 2013-10-06 Earnie Boyd <earnie@users.sourceforge.net> |
4 | 12 | |
5 | 13 | * include/oaidl.h: Include objidl.h. |
@@ -717,6 +717,17 @@ glob_store_collated_entries( struct glob_collator *collator, glob_t *gl_buf ) | ||
717 | 717 | free( collator ); |
718 | 718 | } |
719 | 719 | |
720 | +GLOB_INLINE int | |
721 | +accept_glob_nocheck_match( const char *pattern, int flags ) | |
722 | +{ | |
723 | + /* Helper to check whether a pattern may be stored into gl_pathv as is, | |
724 | + * without attempting to find any file system match; (this is permitted | |
725 | + * only when the caller has set the GLOB_NOCHECK flag, and the pattern | |
726 | + * is devoid of any globbing token). | |
727 | + */ | |
728 | + return (flags & GLOB_NOCHECK) && (is_glob_pattern( pattern, flags ) == 0); | |
729 | +} | |
730 | + | |
720 | 731 | static int |
721 | 732 | glob_match( const char *pattern, int flags, int (*errfn)(), glob_t *gl_buf ) |
722 | 733 | { |
@@ -799,7 +810,25 @@ glob_match( const char *pattern, int flags, int (*errfn)(), glob_t *gl_buf ) | ||
799 | 810 | * at the outset, we have yet to match this pattern to anything. |
800 | 811 | */ |
801 | 812 | status = GLOB_NOMATCH; |
802 | - for( dirp = local_gl_buf.gl_pathv; *dirp != NULL; free( *dirp++ ) ) | |
813 | + | |
814 | + /* When the caller has enabled the GLOB_NOCHECK option, then in the | |
815 | + * case of any pattern with no prefix, and which contains no explicit | |
816 | + * globbing token... | |
817 | + */ | |
818 | + if( (dir == NULL) && accept_glob_nocheck_match( pattern, flags ) ) | |
819 | + { | |
820 | + /* ...we prefer to store it as is, without any attempt to find | |
821 | + * a glob match, (which could also induce a case transliteration | |
822 | + * on a case-insensitive file system)... | |
823 | + */ | |
824 | + glob_store_entry( glob_strdup( pattern ), gl_buf ); | |
825 | + status = GLOB_SUCCESS; | |
826 | + } | |
827 | + /* ...otherwise we initiate glob matching, to find all possible | |
828 | + * file system matches for the designated pattern, within each of | |
829 | + * the identified prefix directory paths. | |
830 | + */ | |
831 | + else for( dirp = local_gl_buf.gl_pathv; *dirp != NULL; free( *dirp++ ) ) | |
803 | 832 | { |
804 | 833 | /* Provided an earlier cycle hasn't scheduled an abort... |
805 | 834 | */ |
@@ -1040,3 +1069,5 @@ __mingw_globfree( glob_t *gl_data ) | ||
1040 | 1069 | */ |
1041 | 1070 | glob_registry( GLOB_FREE, gl_data ); |
1042 | 1071 | } |
1072 | + | |
1073 | +/* $RCSfile: glob.c,v $: end of file */ |