Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: c



A while ago I cravenly refused to mark a variable in zle imaginatively
called `c' for export, which it really needs to be.  (There are numerous
other uses of `c' in the code, too.)

This renames it to `lastchar' and exports it for the completion modules
(in particular complist).  This should make Cygwin happier.

Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.58
diff -u -r1.58 complist.c
--- Src/Zle/complist.c	19 Feb 2004 09:11:40 -0000	1.58
+++ Src/Zle/complist.c	8 Mar 2004 11:31:21 -0000
@@ -1859,7 +1859,7 @@
     msearchpush(ptr, back);
 
     if (ins) {
-        s[0] = c;
+        s[0] = lastchar;
         s[1] = '\0';
 
         msearchstr = dyncat(msearchstr, s);
@@ -2754,9 +2754,9 @@
                     }
                 }
                 if (cmd == Th(z_selfinsertunmeta)) {
-                    c &= 0x7f;
-                    if (c == '\r')
-                        c = '\n';
+                    lastchar &= 0x7f;
+                    if (lastchar == '\r')
+                        lastchar = '\n';
                 }
                 wrap = 0;
                 np = msearch(p, ins, (ins ? (mode == MM_BSEARCH) : back),
Index: Src/Zle/zle_hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v
retrieving revision 1.10
diff -u -r1.10 zle_hist.c
--- Src/Zle/zle_hist.c	20 Feb 2004 15:27:53 -0000	1.10
+++ Src/Zle/zle_hist.c	8 Mar 2004 11:31:21 -0000
@@ -949,17 +949,17 @@
 		sbuf[sbptr] = '^';
 		zrefresh();
 	    }
-	    if ((c = getkey(0)) == EOF)
+	    if ((lastchar = getkey(0)) == EOF)
 		feep = 1;
 	    else
 		goto ins;
 	} else {
 	    if(cmd == Th(z_selfinsertunmeta)) {
-		c &= 0x7f;
-		if(c == '\r')
-		    c = '\n';
+		lastchar &= 0x7f;
+		if(lastchar == '\r')
+		    lastchar = '\n';
 	    } else if (cmd == Th(z_magicspace))
-		c = ' ';
+		lastchar = ' ';
 	    else if (cmd != Th(z_selfinsert)) {
 		ungetkeycmd();
 		if (cmd == Th(z_sendbreak))
@@ -977,7 +977,7 @@
 		sbuf = ibuf + FIRST_SEARCH_CHAR;
 		sibuf *= 2;
 	    }
-	    sbuf[sbptr++] = c;
+	    sbuf[sbptr++] = lastchar;
 	}
 	if (feep)
 	    handlefeep(zlenoargs);
@@ -1091,7 +1091,7 @@
 	    break;
 	}
 	if(cmd == Th(z_magicspace)) {
-	    c = ' ';
+	    lastchar = ' ';
 	    cmd = Th(z_selfinsert);
 	}
 	if(cmd == Th(z_redisplay)) {
@@ -1126,15 +1126,15 @@
 		sbuf[sptr] = '^';
 		zrefresh();
 	    }
-	    if ((c = getkey(0)) == EOF)
+	    if ((lastchar = getkey(0)) == EOF)
 		feep = 1;
 	    else
 		goto ins;
 	} else if(cmd == Th(z_selfinsertunmeta) || cmd == Th(z_selfinsert)) {
 	    if(cmd == Th(z_selfinsertunmeta)) {
-		c &= 0x7f;
-		if(c == '\r')
-		    c = '\n';
+		lastchar &= 0x7f;
+		if(lastchar == '\r')
+		    lastchar = '\n';
 	    }
 	  ins:
 	    if(sptr == ssbuf - 1) {
@@ -1142,7 +1142,7 @@
 		strcpy(newbuf, sbuf);
 		statusline = sbuf = newbuf;
 	    }
-	    sbuf[sptr++] = c;
+	    sbuf[sptr++] = lastchar;
 	} else {
 	    feep = 1;
 	}
Index: Src/Zle/zle_keymap.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_keymap.c,v
retrieving revision 1.12
diff -u -r1.12 zle_keymap.c
--- Src/Zle/zle_keymap.c	29 Oct 2003 19:17:48 -0000	1.12
+++ Src/Zle/zle_keymap.c	8 Mar 2004 11:31:21 -0000
@@ -1257,11 +1257,11 @@
 {
     Thingy func = t_undefinedkey;
     char *str = NULL;
-    int lastlen = 0, lastc = c;
+    int lastlen = 0, lastc = lastchar;
 
     keybuflen = 0;
     keybuf[0] = 0;
-    while((c = getkeybuf(!!lastlen)) != EOF) {
+    while((lastchar = getkeybuf(!!lastlen)) != EOF) {
 	char *s;
 	Thingy f;
 	int loc = 1;
@@ -1274,7 +1274,7 @@
 	    lastlen = keybuflen;
 	    func = f;
 	    str = s;
-	    lastc = c;
+	    lastc = lastchar;
 	}
 	if(!keyisprefix((loc ? localkeymap : km), keybuf))
 	    break;
@@ -1282,7 +1282,7 @@
     if(!lastlen && keybuflen)
 	lastlen = keybuflen;
     else
-	c = lastc;
+	lastchar = lastc;
     if(lastlen != keybuflen) {
 	unmetafy(keybuf + lastlen, &keybuflen);
 	ungetkeys(keybuf+lastlen, keybuflen);
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.39
diff -u -r1.39 zle_main.c
--- Src/Zle/zle_main.c	15 Dec 2003 22:45:29 -0000	1.39
+++ Src/Zle/zle_main.c	8 Mar 2004 11:31:21 -0000
@@ -76,7 +76,7 @@
 /* last character pressed */
 
 /**/
-int c;
+mod_export int lastchar;
 
 /* the bindings for the previous and for this key */
 
@@ -688,7 +688,7 @@
 	selectlocalmap(NULL);
 	bindk = getkeycmd();
 	if (!ll && isfirstln && !(zlereadflags & ZLRF_IGNOREEOF) &&
-	    c == eofchar) {
+	    lastchar == eofchar) {
 	    eofsent = 1;
 	    break;
 	}
Index: Src/Zle/zle_misc.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_misc.c,v
retrieving revision 1.9
diff -u -r1.9 zle_misc.c
--- Src/Zle/zle_misc.c	29 Jul 2003 09:53:26 -0000	1.9
+++ Src/Zle/zle_misc.c	8 Mar 2004 11:31:21 -0000
@@ -62,11 +62,11 @@
 {
     char s[3], *p = s;
 
-    if(imeta(c)) {
+    if(imeta(lastchar)) {
 	*p++ = Meta;
-	c ^= 32;
+	lastchar ^= 32;
     }
-    *p++ = c;
+    *p++ = lastchar;
     *p = 0;
     doinsert(s);
     return 0;
@@ -76,9 +76,9 @@
 int
 selfinsertunmeta(char **args)
 {
-    c &= 0x7f;
-    if (c == '\r')
-	c = '\n';
+    lastchar &= 0x7f;
+    if (lastchar == '\r')
+	lastchar = '\n';
     return selfinsert(args);
 }
 
@@ -489,11 +489,11 @@
     sob.sg_flags = (sob.sg_flags | RAW) & ~ECHO;
     ioctl(SHTTY, TIOCSETN, &sob);
 #endif
-    c = getkey(0);
+    lastchar = getkey(0);
 #ifndef HAS_TIO
     zsetterm();
 #endif
-    if (c < 0)
+    if (lastchar < 0)
 	return 1;
     else
 	return selfinsert(args);
@@ -506,7 +506,7 @@
     int sign = (zmult < 0) ? -1 : 1;
 
     /* allow metafied as well as ordinary digits */
-    if ((c & 0x7f) < '0' || (c & 0x7f) > '9')
+    if ((lastchar & 0x7f) < '0' || (lastchar & 0x7f) > '9')
 	return 1;
 
     if (!(zmod.flags & MOD_TMULT))
@@ -514,10 +514,10 @@
     if (zmod.flags & MOD_NEG) {
 	/* If we just had a negative argument, this is the digit, *
 	 * rather than the -1 assumed by negargument()            */
-	zmod.tmult = sign * (c & 0xf);
+	zmod.tmult = sign * (lastchar & 0xf);
 	zmod.flags &= ~MOD_NEG;
     } else
-	zmod.tmult = zmod.tmult * 10 + sign * (c & 0xf);
+	zmod.tmult = zmod.tmult * 10 + sign * (lastchar & 0xf);
     zmod.flags |= MOD_TMULT;
     prefixflag = 1;
     return 0;
@@ -764,16 +764,16 @@
 	} else if(cmd == Th(z_viquotedinsert)) {
 	    *ptr = '^';
 	    zrefresh();
-	    c = getkey(0);
-	    if(c == EOF || !c || len == NAMLEN)
+	    lastchar = getkey(0);
+	    if(lastchar == EOF || !lastchar || len == NAMLEN)
 		feep = 1;
 	    else
-		*ptr++ = c, len++, curlist = 0;
+		*ptr++ = lastchar, len++, curlist = 0;
 	} else if(cmd == Th(z_quotedinsert)) {
-	    if((c = getkey(0)) == EOF || !c || len == NAMLEN)
+	    if((lastchar = getkey(0)) == EOF || !lastchar || len == NAMLEN)
 		feep = 1;
 	    else
-		*ptr++ = c, len++, curlist = 0;
+		*ptr++ = lastchar, len++, curlist = 0;
 	} else if(cmd == Th(z_backwarddeletechar) ||
 	    	cmd == Th(z_vibackwarddeletechar)) {
 	    if (len)
@@ -811,15 +811,15 @@
 		unrefthingy(r);
 	    }
 	    if(cmd == Th(z_selfinsertunmeta)) {
-		c &= 0x7f;
-		if(c == '\r')
-		    c = '\n';
+		lastchar &= 0x7f;
+		if(lastchar == '\r')
+		    lastchar = '\n';
 		cmd = Th(z_selfinsert);
 	    }
 	    if (cmd == Th(z_listchoices) || cmd == Th(z_deletecharorlist) ||
 		cmd == Th(z_expandorcomplete) || cmd == Th(z_completeword) ||
 		cmd == Th(z_expandorcompleteprefix) || cmd == Th(z_vicmdmode) ||
-		cmd == Th(z_acceptline) || c == ' ' || c == '\t') {
+		cmd == Th(z_acceptline) || lastchar == ' ' || lastchar == '\t') {
 		cmdambig = 100;
 
 		cmdll = newlinklist();
@@ -866,10 +866,11 @@
 		    len = cmdambig;
 		}
 	    } else {
-		if (len == NAMLEN || icntrl(c) || cmd != Th(z_selfinsert))
+		if (len == NAMLEN || icntrl(lastchar) ||
+		    cmd != Th(z_selfinsert))
 		    feep = 1;
 		else
-		    *ptr++ = c, len++, curlist = 0;
+		    *ptr++ = lastchar, len++, curlist = 0;
 	    }
 	}
 	if (feep)
Index: Src/Zle/zle_move.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_move.c,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 zle_move.c
--- Src/Zle/zle_move.c	3 Jul 1999 13:18:00 -0000	1.1.1.7
+++ Src/Zle/zle_move.c	8 Mar 2004 11:31:21 -0000
@@ -483,7 +483,7 @@
     int ch;
 
     ch = getkey(0);
-    if (ch == c)
+    if (ch == lastchar)
 	ch = 26;
     else {
 	if (ch < 'a' || ch > 'z')
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.41
diff -u -r1.41 zle_tricky.c
--- Src/Zle/zle_tricky.c	20 Aug 2002 15:21:56 -0000	1.41
+++ Src/Zle/zle_tricky.c	8 Mar 2004 11:31:22 -0000
@@ -193,7 +193,7 @@
     usemenu = !!isset(MENUCOMPLETE);
     useglob = isset(GLOBCOMPLETE);
     wouldinstab = 0;
-    if (c == '\t' && usetab())
+    if (lastchar == '\t' && usetab())
 	return selfinsert(args);
     else {
 	int ret;
@@ -215,7 +215,7 @@
     usemenu = 1;
     useglob = isset(GLOBCOMPLETE);
     wouldinstab = 0;
-    if (c == '\t' && usetab())
+    if (lastchar == '\t' && usetab())
 	return selfinsert(args);
     else
 	return docomplete(COMP_COMPLETE);
@@ -262,7 +262,7 @@
 {
     usemenu = useglob = 0;
     wouldinstab = 0;
-    if (c == '\t' && usetab())
+    if (lastchar == '\t' && usetab())
 	return selfinsert(args);
     else
 	return docomplete(COMP_EXPAND);
@@ -275,7 +275,7 @@
     usemenu = !!isset(MENUCOMPLETE);
     useglob = isset(GLOBCOMPLETE);
     wouldinstab = 0;
-    if (c == '\t' && usetab())
+    if (lastchar == '\t' && usetab())
 	return selfinsert(args);
     else {
 	int ret;
@@ -297,7 +297,7 @@
     usemenu = 1;
     useglob = isset(GLOBCOMPLETE);
     wouldinstab = 0;
-    if (c == '\t' && usetab())
+    if (lastchar == '\t' && usetab())
 	return selfinsert(args);
     else
 	return docomplete(COMP_EXPAND_COMPLETE);
@@ -2294,7 +2294,7 @@
 {
     char *bangq;
     int ret;
-    c = ' ';
+    lastchar = ' ';
     for (bangq = (char *)line; (bangq = strchr(bangq, bangchar)); bangq += 2)
 	if (bangq[1] == '"' && (bangq == (char *)line || bangq[-1] != '\\'))
 	    break;
Index: Src/Zle/zle_vi.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_vi.c,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 zle_vi.c
--- Src/Zle/zle_vi.c	3 Jul 1999 13:18:04 -0000	1.1.1.9
+++ Src/Zle/zle_vi.c	8 Mar 2004 11:31:22 -0000
@@ -78,7 +78,7 @@
 	if (vichgbuf)
 	    free(vichgbuf);
 	vichgbuf = (char *)zalloc(vichgbufsz = 16);
-	vichgbuf[0] = c;
+	vichgbuf[0] = lastchar;
 	vichgbufptr = 1;
 	vichgrepeat = 0;
     }
@@ -102,10 +102,10 @@
     char m[3], *str;
     Thingy cmd;
 
-    if((c = getkey(0)) == EOF)
+    if((lastchar = getkey(0)) == EOF)
 	return -1;
 
-    m[0] = c;
+    m[0] = lastchar;
     metafy(m, 1, META_NOALLOC);
     if(mn)
 	cmd = keybind(mn, m, &str);
@@ -115,20 +115,20 @@
     if (!cmd || cmd == Th(z_sendbreak)) {
 	return -1;
     } else if (cmd == Th(z_quotedinsert)) {
-	if ((c = getkey(0)) == EOF)
+	if ((lastchar = getkey(0)) == EOF)
 	    return -1;
     } else if(cmd == Th(z_viquotedinsert)) {
 	char sav = line[cs];
 
 	line[cs] = '^';
 	zrefresh();
-	c = getkey(0);
+	lastchar = getkey(0);
 	line[cs] = sav;
-	if(c == EOF)
+	if(lastchar == EOF)
 	    return -1;
     } else if (cmd == Th(z_vicmdmode))
 	return -1;
-    return c;
+    return lastchar;
 }
 
 /**/
@@ -897,12 +897,12 @@
     sob.sg_flags = (sob.sg_flags | RAW) & ~ECHO;
     ioctl(SHTTY, TIOCSETN, &sob);
 #endif
-    c = getkey(0);
+    lastchar = getkey(0);
 #ifndef HAS_TIO
     zsetterm();
 #endif
     foredel(1);
-    if(c < 0)
+    if(lastchar < 0)
 	return 1;
     else
 	return selfinsert(args);

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author