about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-07-13 08:42:10 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-07-13 08:42:10 +0000
commitc3082d546e19df8fa70f179e1151c6b742ba5388 (patch)
treee598b63d43686f1b06bf12346924a8df930d8a88 /Src
parent6ef0d9767fc86b39c17bc29ec633dfb07baadd6e (diff)
downloadzsh-c3082d546e19df8fa70f179e1151c6b742ba5388.tar.gz
zsh-c3082d546e19df8fa70f179e1151c6b742ba5388.tar.xz
zsh-c3082d546e19df8fa70f179e1151c6b742ba5388.zip
slightly improved (z) flag for parsing conditions; recognising glob flags in conditions still doesn't work (12237)
Diffstat (limited to 'Src')
-rw-r--r--Src/hist.c15
-rw-r--r--Src/lex.c9
2 files changed, 16 insertions, 8 deletions
diff --git a/Src/hist.c b/Src/hist.c
index 35ab2b1fd..4a7a0fa58 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2057,16 +2057,16 @@ unlockhistfile(char *fn)
 mod_export LinkList
 bufferwords(LinkList list, char *buf, int *index)
 {
-    int num = 0, cur = -1, got = 0, ne = noerrs, ocs = cs;
-    int owb = wb, owe = we, oadx = addedx, ozp = zleparse, oexp = expanding;
+    int num = 0, cur = -1, got = 0, ne = noerrs, ocs = cs, oll = ll;
+    int owb = wb, owe = we, oadx = addedx, ozp = zleparse, onc = nocomments;
     char *p;
 
     if (!list)
 	list = newlinklist();
 
-    zleparse = 3;
+    zleparse = 1;
     addedx = 0;
-    noerrs = expanding = 1;
+    noerrs = 1;
     lexsave();
     if (buf) {
 	int l = strlen(buf);
@@ -2076,7 +2076,8 @@ bufferwords(LinkList list, char *buf, int *index)
 	p[l] = ' ';
 	p[l + 1] = '\0';
 	inpush(p, 0, NULL);
-	cs = 0;
+	cs = strlen(p) + 1;
+	nocomments = 1;
     } else if (!isfirstln && chline) {
 	p = (char *) zhalloc(hptr - chline + ll + 2);
 	memcpy(p, chline, hptr - chline);
@@ -2092,6 +2093,7 @@ bufferwords(LinkList list, char *buf, int *index)
 	p[ll + 1] = '\0';
 	inpush(p, 0, NULL);
     }
+    ll = strlen(p);
     if (cs)
 	cs--;
     strinbeg(0);
@@ -2133,10 +2135,11 @@ bufferwords(LinkList list, char *buf, int *index)
     inpop();
     errflag = 0;
     zleparse = ozp;
-    expanding = oexp;
+    nocomments = onc;
     noerrs = ne;
     lexrestore();
     cs = ocs;
+    ll = oll;
     wb = owb;
     we = owe;
     addedx = oadx;
diff --git a/Src/lex.c b/Src/lex.c
index 5aa63ece5..db2c2c8bd 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -116,7 +116,12 @@ mod_export int parbegin;
 
 /**/
 mod_export int parend;
+
+/* don't recognize comments */
  
+/**/
+mod_export int nocomments;
+
 /* text of puctuation tokens */
 
 /**/
@@ -672,8 +677,8 @@ gettok(void)
 
     /* chars in initial position in word */
 
-    if (c == hashchar &&
-	((zleparse != 3 && isset(INTERACTIVECOMMENTS)) ||
+    if (c == hashchar && !nocomments &&
+	(isset(INTERACTIVECOMMENTS) ||
 	 (!zleparse && !expanding &&
 	  (!interact || unset(SHINSTDIN) || strin)))) {
 	/* History is handled here to prevent extra  *