zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: 3.1.5 - (Sven) Case-insensitive globbing
@ 1998-10-31 10:14 Bart Schaefer
  1998-11-02  9:21 ` Zefram
  0 siblings, 1 reply; 21+ messages in thread
From: Bart Schaefer @ 1998-10-31 10:14 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~1998-11-06 13:50 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-31 10:14 PATCH: 3.1.5 - (Sven) Case-insensitive globbing Bart Schaefer
1998-11-02  9:21 ` Zefram
1998-11-02 17:07   ` Peter Stephenson
1998-11-02 17:45     ` Bruce Stephens
1998-11-02 18:06     ` Zefram
1998-11-03  8:12       ` Sven Wischnowsky
1998-11-03 12:22         ` Bruce Stephens
1998-11-03 12:47           ` Bruce Stephens
1998-11-03 15:01             ` Zefram
1998-11-03 15:27               ` Bruce Stephens
     [not found]         ` <MLIST_vbn269dkyw.fsf@snake.isode.com>
1998-11-03 18:09           ` Jarkko Hietaniemi
1998-11-03 18:54             ` Zefram
1998-11-03 19:14               ` Jarkko Hietaniemi
1998-11-03 19:27                 ` Zefram
1998-11-03 19:36                   ` Jarkko Hietaniemi
1998-11-04 18:48                     ` Bart Schaefer
1998-11-05  9:26                       ` PATCH: 3.1.5: Case-insensitive globbing (2) Peter Stephenson
1998-11-05 18:15                         ` Bart Schaefer
1998-11-06 11:01                           ` PATCH: 3.1.5: doc fix, was re: Case-insensitive globbing Peter Stephenson
1998-11-06 13:43                             ` Bruce Stephens
1998-11-06  9:24                     ` Approximate matching Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).