• R/O
  • HTTP
  • SSH
  • HTTPS

mingw-org-wsl: Commit

The MinGW.org Windows System Libraries


Commit MetaInfo

Revision3b6176993803b355a0ad5eb704e3783f7df8cbbd (tree)
Time2013-10-22 05:28:32
AuthorKeith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

Fix bug [#2062]: preserve case in patterns without glob tokens.

Change Summary

Incremental Difference

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
11 RELEASE 4.1:
22
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+
311 2013-10-06 Earnie Boyd <earnie@users.sourceforge.net>
412
513 * include/oaidl.h: Include objidl.h.
--- a/src/libcrt/misc/glob.c
+++ b/src/libcrt/misc/glob.c
@@ -717,6 +717,17 @@ glob_store_collated_entries( struct glob_collator *collator, glob_t *gl_buf )
717717 free( collator );
718718 }
719719
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+
720731 static int
721732 glob_match( const char *pattern, int flags, int (*errfn)(), glob_t *gl_buf )
722733 {
@@ -799,7 +810,25 @@ glob_match( const char *pattern, int flags, int (*errfn)(), glob_t *gl_buf )
799810 * at the outset, we have yet to match this pattern to anything.
800811 */
801812 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++ ) )
803832 {
804833 /* Provided an earlier cycle hasn't scheduled an abort...
805834 */
@@ -1040,3 +1069,5 @@ __mingw_globfree( glob_t *gl_data )
10401069 */
10411070 glob_registry( GLOB_FREE, gl_data );
10421071 }
1072+
1073+/* $RCSfile: glob.c,v $: end of file */
Show on old repository browser