From: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] Long line makes pattern matching (by //) hog Zsh
Date: Sun, 5 Jun 2016 21:39:51 +0100 [thread overview]
Message-ID: <20160605213951.4af7294a@ntlworld.com> (raw)
In-Reply-To: <20160605203708.3701c7a2@ntlworld.com>
On Sun, 5 Jun 2016 20:37:08 +0100
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> The problem is the patterns are pathological. Each of them can match
> the same characters. So it's spending a lot of time repartitioning the
> mathches between the possibilities of 1. and 2. and 3. in the above.
> That's not polynomially bounded. I'm not sure if it's even
> exponentially bounded.
>
> What I'm not sure is if there's a way of improving this without some
> special case or, obviously, making the patterns more specific.
We are maybe being naive in treating [...] expressions as if they are
"simple". I think we have better protection against pathological
backtracking for more complicated patterns.
Does the following help?
pws
diff --git a/Src/pattern.c b/Src/pattern.c
index 4e2f236..bec980f 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -1425,7 +1425,7 @@ patcomppiece(int *flagp, int paren)
case Inbrack:
DPUTS(zpc_special[ZPC_INBRACK] == Marker,
"Treating '[' as pattern character although disabled");
- flags |= P_SIMPLE;
+ /*flags |= P_SIMPLE;*/
if (*patparse == Hat || *patparse == Bang) {
patparse++;
starter = patnode(P_ANYBUT);
next prev parent reply other threads:[~2016-06-05 20:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-05 14:36 Sebastian Gniazdowski
2016-06-05 19:10 ` Bart Schaefer
2016-06-05 19:37 ` Peter Stephenson
2016-06-05 20:39 ` Peter Stephenson [this message]
2016-06-05 21:21 ` Sebastian Gniazdowski
2016-06-06 0:07 ` Bart Schaefer
2016-06-05 19:47 ` Sebastian Gniazdowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160605213951.4af7294a@ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).