Mail Archives: cygwin/1997/01/20/01:28:58
Bash, being written for UNIX, is case-sensitive. So, if you have a file
named "COPYING", and you press "cop" and <tab> for completions, it won't work.
Since win32 has case-insensitive file names, that doesn't make sense.
These three patches makes file-name completion *and* globbing
case-insensitive, when _WIN32 is defined.
*** complete.c.original Sat Jan 18 21:51:13 1997
--- complete.c Sun Jan 05 13:52:41 1997
***************
*** 1077,1083 ****
--- 1077,1087 ----
/* **************************************************************** */
/* Non-zero means that case is not significant in completion. */
+ #ifdef _WIN32
+ int completion_case_fold = 1;
+ #else
int completion_case_fold = 0;
+ #endif
/* Return an array of (char *) which is a list of completions for TEXT.
If there are no completions, return a NULL pointer.
***************
*** 1176,1181 ****
--- 1180,1199 ----
return (match_list);
}
+ /* Case-insentitive "strncmp" function, for completion on case-insensitive
+ file systems. */
+ int
+ strncmpi ( str1, str2, len )
+ char * str1;
+ char * str2;
+ int len;
+ {
+ while (len-- && *str1)
+ if ( to_lower(*str1++) != to_lower(*str2++))
+ return 1;
+ return 0;
+ }
+
/* Okay, now we write the entry_function for filename completion. In the
general case. Note that completion in the shell is a little different
because of all the pathnames that must be followed when looking up the
***************
*** 1265,1274 ****
{
/* Otherwise, if these match up to the length of filename, then
it is a match. */
! if ((entry->d_name[0] == filename[0]) &&
! (((int)D_NAMLEN (entry)) >= filename_len) &&
! (strncmp (filename, entry->d_name, filename_len) == 0))
! break;
}
}
--- 1283,1302 ----
{
/* Otherwise, if these match up to the length of filename, then
it is a match. */
! if (completion_case_fold)
! {
! if ((to_lower(entry->d_name[0]) == to_lower(filename[0])) &&
! (((int)D_NAMLEN (entry)) >= filename_len) &&
! (strncmpi (filename, entry->d_name, filename_len) == 0))
! break;
! }
! else
! {
! if ((entry->d_name[0] == filename[0]) &&
! (((int)D_NAMLEN (entry)) >= filename_len) &&
! (strncmp (filename, entry->d_name, filename_len) == 0))
! break;
! }
}
}
*** glob.c.original Sat Jan 18 21:51:13 1997
--- glob.c Sun Jan 05 14:28:09 1997
***************
*** 280,285 ****
--- 280,288 ----
continue;
flags = (noglob_dot_filenames ? FNM_PERIOD : 0) | FNM_PATHNAME;
+ #ifdef _WIN32
+ flags |= FNM_FOLDCASE;
+ #endif
if (fnmatch (pat, dp->d_name, flags) != FNM_NOMATCH)
{
*** fnmatch.h.original Sat Jan 18 21:51:13 1997
--- fnmatch.h Sun Jan 05 14:17:47 1997
***************
*** 24,30 ****
#define FNM_PATHNAME (1 << 0)/* No wildcard can ever match `/'. */
#define FNM_NOESCAPE (1 << 1)/* Backslashes don't quote special chars. */
#define FNM_PERIOD (1 << 2)/* Leading `.' is matched only explicitly. */
! #define __FNM_FLAGS (FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD)
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
#define FNM_NOMATCH 1
--- 24,31 ----
#define FNM_PATHNAME (1 << 0)/* No wildcard can ever match `/'. */
#define FNM_NOESCAPE (1 << 1)/* Backslashes don't quote special chars. */
#define FNM_PERIOD (1 << 2)/* Leading `.' is matched only explicitly. */
! #define FNM_FOLDCASE (1 << 3)/* Ignore case when matching. */
! #define __FNM_FLAGS (FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD|FNM_FOLDCASE)
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
#define FNM_NOMATCH 1
*** fnmatch.c.original Sat Jan 18 21:51:13 1997
--- fnmatch.c Sun Jan 05 14:38:43 1997
***************
*** 79,87 ****
{
char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
for (--p; *n != '\0'; ++n)
! if ((c == '[' || *n == c1) &&
! fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
! return (0);
return (FNM_NOMATCH);
}
--- 79,96 ----
{
char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
for (--p; *n != '\0'; ++n)
! if (flags & FNM_FOLDCASE)
! {
! if ((c == '[' || to_lower(*n) == to_lower(c1)) &&
! fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
! return (0);
! }
! else
! {
! if ((c == '[' || *n == c1) &&
! fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
! return (0);
! }
return (FNM_NOMATCH);
}
***************
*** 175,182 ****
break;
default:
! if (c != *n)
! return (FNM_NOMATCH);
}
++n;
--- 184,199 ----
break;
default:
! if (flags & FNM_FOLDCASE)
! {
! if (to_lower(c) != to_lower(*n))
! return (FNM_NOMATCH);
! }
! else
! {
! if (c != *n)
! return (FNM_NOMATCH);
! }
}
++n;
----------
Wade Richards -= WRichard AT Direct DOT CA =-
"Never attribute to malice what can adequately be explained by stupidity."
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -