From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1320 invoked from network); 31 Oct 1998 10:21:12 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 31 Oct 1998 10:21:12 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id FAA09500; Sat, 31 Oct 1998 05:15:53 -0500 (EST) Resent-Date: Sat, 31 Oct 1998 05:15:53 -0500 (EST) From: "Bart Schaefer" Message-Id: <981031021416.ZM12242@candle.brasslantern.com> Date: Sat, 31 Oct 1998 02:14:16 -0800 X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-workers@math.gatech.edu Subject: PATCH: 3.1.5 - (Sven) Case-insensitive globbing MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"Cr3Ls3.0.KK2.ODkEs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4474 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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