Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH]: =~ parsing littering pattern state fix
- X-seq: zsh-workers 28338
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH]: =~ parsing littering pattern state fix
- Date: Sat, 9 Oct 2010 19:54:00 -0400
- Cc: Mikael Magnusson <mikachu@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d200912; h=Content-Type:MIME-Version:Message-ID:Subject:Cc:To:From:Date; bh=q3OH8pIjWAEmFw/ARdH4mPu+JYIWoHZCtKKkdBK2lk0=; b=lP1MqWR52hDda394qOKVxwEVjq3nAffvyUYwuRFV1OafzlZeRMX6RyMb7hNGneZuJ87OZMjHt2lBjVgRxM1sDqlSFNPYlognLVWWOV+ieGtbnIIfTH3x6mS4QZzmRbAnN3BYK6eMUI0RQ3k/M7BbVTR7XWJsFkywg31vgUQBvQs=;
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: zsh-workers@xxxxxxx, Mikael Magnusson <mikachu@xxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
This is the problem reported by Mikael, wherein if an =~ condition is
followed by &&/|| then the following condition is prefixed with an
implicit negation.
The problem has been present since I added =~ and is a result of my not
understanding the parsing code and cargo-culting the layout, while
playing tricks on the system.
Per the comments in parse.c, in WC_COND, type == COND_MODI is followed
by name/left/right. When consuming in evalcond(), COND_REGEX maps to an
implicit COND_MODI, which I modified to only consume the 'name' if an
overridename is not provided. However, when cargo-culting, I followed
the pattern of ==/!= and also provided the pattern-number,
ecadd(ecnpats++) in the parsing. This is the source of the error.
See attached.
-Phil
Index: Src/parse.c
===================================================================
RCS file: /home/cvsroot/zsh/Src/parse.c,v
retrieving revision 1.84
diff -a -u -p -r1.84 parse.c
--- Src/parse.c 14 Sep 2010 14:46:26 -0000 1.84
+++ Src/parse.c 9 Oct 2010 23:43:52 -0000
@@ -2172,10 +2172,11 @@ par_cond_triple(char *a, char *b, char *
ecadd(ecnpats++);
} else if ((b[0] == Equals || b[0] == '=') &&
(b[1] == '~' || b[1] == Tilde) && !b[2]) {
+ /* We become an implicit COND_MODI but do not provide the first
+ * item, it's skipped */
ecadd(WCB_COND(COND_REGEX, 0));
ecstr(a);
ecstr(c);
- ecadd(ecnpats++);
} else if (b[0] == '-') {
if ((t0 = get_cond_num(b + 1)) > -1) {
ecadd(WCB_COND(t0 + COND_NT, 0));
Index: Test/C02cond.ztst
===================================================================
RCS file: /home/cvsroot/zsh/Test/C02cond.ztst,v
retrieving revision 1.26
diff -a -u -p -r1.26 C02cond.ztst
--- Test/C02cond.ztst 19 Feb 2010 12:45:37 -0000 1.26
+++ Test/C02cond.ztst 9 Oct 2010 23:52:40 -0000
@@ -285,6 +285,19 @@ F:Failures in these cases do not indicat
0:MATCH, MBEGIN, MEND, match, mbegin, mend
>OK
+ (if zmodload -i zsh/regex 2>/dev/null; then
+ if [[ a =~ a && b == b ]]; then
+ print OK
+ else
+ print "regex =~ inverted following test"
+ fi
+ else
+ # not a test error
+ print OK
+ fi)
+0:regex infix operator should not invert following conditions
+>OK
+
[[ -fail badly ]]
2:Error message for unknown prefix condition
?(eval):1: unknown condition: -fail
Messages sorted by:
Reverse Date,
Date,
Thread,
Author