Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: 3.1.5 - (Sven) Case-insensitive globbing
- X-seq: zsh-workers 4474
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: PATCH: 3.1.5 - (Sven) Case-insensitive globbing
- Date: Sat, 31 Oct 1998 02:14:16 -0800
Sven's patch for case-insensitive globbing, applied to 3.1.5. This does NOT
include any of the enhanced compctl stuff that makes use of it.
Index: Doc/Zsh/expn.yo
===================================================================
diff -u -r1.1.1.2 -r1.8
--- expn.yo 1998/10/30 15:56:51 1.1.1.2
+++ expn.yo 1998/10/30 17:52:39 1.8
@@ -1010,6 +1011,14 @@
item(tt(D))(
sets the tt(GLOB_DOTS) option for the current pattern
pindex(GLOB_DOTS, setting in pattern)
+)
+item(tt(f))(
+makes lower case letters in the pattern match themselves and the
+corresponding uppercase letter
+)
+item(tt(F))(
+makes all letters match themselves and their uppercase or lowercase
+counterpart
)
enditem()
Index: Src/glob.c
===================================================================
diff -u -r1.1.1.2 -r1.4
--- glob.c 1998/10/30 15:57:02 1.1.1.2
+++ glob.c 1998/10/30 17:52:44 1.4
@@ -81,6 +81,7 @@
static int qualct, qualorct;
static int range, amc, units;
static int gf_nullglob, gf_markdirs, gf_noglobdots, gf_listtypes, gf_follow;
+static int gf_case = 0;
/* Prefix, suffix for doing zle trickery */
@@ -868,6 +869,7 @@
Complist q; /* pattern after parsing */
char *ostr = (char *)getdata(np); /* the pattern before the parser */
/* chops it up */
+ int gfc = 0; /* case insensitive? */
MUSTUSEHEAP("glob");
if (unset(GLOBOPT) || !haswilds(ostr)) {
@@ -1206,6 +1208,12 @@
++s;
data = qgetnum(&s);
break;
+ case 'f':
+ gfc = 1;
+ break;
+ case 'F':
+ gfc = 2;
+ break;
default:
zerr("unknown file attribute", NULL, 0);
@@ -1262,7 +1270,9 @@
/* The actual processing takes place here: matches go into *
* matchbuf. This is the only top-level call to scanner(). */
+ gf_case = gfc;
scanner(q);
+ gf_case = 0;
/* Deal with failures to match depending on options */
if (matchct)
@@ -2489,7 +2499,9 @@
}
continue;
}
- if (*pptr == *pat) {
+ if (*pptr == *pat ||
+ (gf_case == 1 ? (islower(*pat) && tuupper(*pat) == *pptr) :
+ (gf_case == 2 ? (tulower(*pat) == tulower(*pptr)) : 0))) {
/* just plain old characters */
pptr++;
pat++;
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author