about summary refs log tree commit diff
path: root/Src/lex.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2016-01-19 17:24:12 +0000
committerPeter Stephenson <pws@zsh.org>2016-01-19 17:24:12 +0000
commitad16356e1923ec1b4daf97b27b10a835cfe73ba7 (patch)
tree714fe0c1d6c89a32ac5194475402fa6dc3f8d218 /Src/lex.c
parent8eb9070d6785f423dd9bdbbb0513aa47c8a08d62 (diff)
downloadzsh-ad16356e1923ec1b4daf97b27b10a835cfe73ba7.tar.gz
zsh-ad16356e1923ec1b4daf97b27b10a835cfe73ba7.tar.xz
zsh-ad16356e1923ec1b4daf97b27b10a835cfe73ba7.zip
37689: ! and ^ need to be tokenised in character sets
Diffstat (limited to 'Src/lex.c')
-rw-r--r--Src/lex.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/Src/lex.c b/Src/lex.c
index 9a7e3b8fe..0202d2559 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -35,7 +35,7 @@
 /* tokens */
 
 /**/
-mod_export char ztokens[] = "#$^*(())$=|{}[]`<>>?~`,-'\"\\\\";
+mod_export char ztokens[] = "#$^*(())$=|{}[]`<>>?~`,-!'\"\\\\";
 
 /* parts of the current token */
 
@@ -395,8 +395,9 @@ ctxtlex(void)
 #define LX2_BQUOTE 16
 #define LX2_COMMA 17
 #define LX2_DASH 18
-#define LX2_OTHER 19
-#define LX2_META 20
+#define LX2_BANG 19
+#define LX2_OTHER 20
+#define LX2_META 21
 
 static unsigned char lexact1[256], lexact2[256], lextok2[256];
 
@@ -406,10 +407,10 @@ initlextabs(void)
 {
     int t0;
     static char *lx1 = "\\q\n;!&|(){}[]<>";
-    static char *lx2 = ";)|$[]~({}><=\\\'\"`,-";
+    static char *lx2 = ";)|$[]~({}><=\\\'\"`,-!";
 
     for (t0 = 0; t0 != 256; t0++) {
-	lexact1[t0] = LX1_OTHER;
+       lexact1[t0] = LX1_OTHER;
 	lexact2[t0] = LX2_OTHER;
 	lextok2[t0] = t0;
     }
@@ -1361,12 +1362,20 @@ gettokstr(int c, int sub)
 	     */
 	    if (seen_brct)
 		c = Dash;
-	    else
-		c = '-';
-	    break;
-	}
-	add(c);
-	c = hgetc();
+           else
+               c = '-';
+           break;
+       case LX2_BANG:
+           /*
+            * Same logic as Dash, for ! to perform negation in range.
+            */
+           if (seen_brct)
+               c = Bang;
+           else
+               c = '!';
+       }
+       add(c);
+       c = hgetc();
 	if (intpos)
 	    intpos--;
 	if (lexstop)