summaryrefslogtreecommitdiff
path: root/Src/pattern.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2000-04-14 11:49:31 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2000-04-14 11:49:31 +0000
commit2295c59fcb4f1e31ef05555318bf3b3b4a2df8f9 (patch)
tree564d732962ee8faa96689a21f6c85d5856239986 /Src/pattern.c
parent3f114b3237c9d46f27cb13bec1e2d7a84e5bfead (diff)
downloadzsh-2295c59fcb4f1e31ef05555318bf3b3b4a2df8f9.tar.gz
zsh-2295c59fcb4f1e31ef05555318bf3b3b4a2df8f9.zip
10756: fix (#s) and (#e) for parameter substitution forms
Diffstat (limited to 'Src/pattern.c')
-rw-r--r--Src/pattern.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Src/pattern.c b/Src/pattern.c
index 1c90f72a1..eef88ac6e 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -1757,6 +1757,9 @@ patmatch(Upat prog)
* over, that doesn't matter: we should fail anyway.
* The pointer also tells us where the asserted
* pattern matched for use by the exclusion.
+ *
+ * P.S. in case you were wondering, this code
+ * is horrible.
*/
Upat syncstrp;
unsigned char *oldsyncstr;
@@ -1782,6 +1785,7 @@ patmatch(Upat prog)
char savchar, *testptr;
char *savpatinstart = patinstart;
int savforce = forceerrs, savpatinlen = patinlen;
+ int savpatflags = patflags;
forceerrs = -1;
savglobdots = globdots;
matchederrs = errsfound;
@@ -1800,6 +1804,12 @@ patmatch(Upat prog)
testptr = patinstart + (syncpt - syncstrp->p);
DPUTS(testptr > matchpt, "BUG: EXCSYNC failed");
savchar = *testptr;
+ /*
+ * If this isn't really the end of the string,
+ * remember this for the (#e) assertion.
+ */
+ if (savchar)
+ patflags |= PAT_NOTEND;
*testptr = '\0';
next = PATNEXT(scan);
while (next && P_ISEXCLUDE(next)) {
@@ -1848,6 +1858,7 @@ patmatch(Upat prog)
next = PATNEXT(next);
}
*testptr = savchar;
+ patflags = savpatflags;
globdots = savglobdots;
forceerrs = savforce;
if (ret)
@@ -2015,11 +2026,11 @@ patmatch(Upat prog)
*/
return 0;
case P_ISSTART:
- if (patinput != patinstart)
+ if (patinput != patinstart || (patflags & PAT_NOTSTART))
fail = 1;
break;
case P_ISEND:
- if (*patinput)
+ if (*patinput || (patflags & PAT_NOTEND))
fail = 1;
break;
case P_END: