zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: PATCH: pattern matching should be interruptible
Date: Tue, 18 Mar 2014 18:23:20 -0700	[thread overview]
Message-ID: <140318182320.ZM3488@torch.brasslantern.com> (raw)
In-Reply-To: <140318144230.ZM15739@torch.brasslantern.com>

On Mar 18,  2:42pm, Bart Schaefer wrote:
}
} You could also try something with the (#a) glob qualifier (approximate
} matching) but it's VERY expensive for strings as long as some of your
} example file names and is entirely impossible to interrupt once it is
} started ("kill -9" territory).

It has been noted before that it is annoying that one cannot interrupt
pattern matching.  Does this fix it?  Are there places inside the "we
were lazy" if-block that need queue_signals/unqueue_signals wrapping?


diff --git a/Src/pattern.c b/Src/pattern.c
index b79c3b4..94a299e 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -2223,6 +2223,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
 
 	return ret;
     } else {
+	int q = queue_signal_level();
+
 	/*
 	 * Test for a `must match' string, unless we're scanning for a match
 	 * in which case we don't need to do this each time.
@@ -2270,6 +2272,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
 
 	patinput = patinstart;
 
+	dont_queue_signals();
+
 	if (patmatch((Upat)progstr)) {
 	    /*
 	     * we were lazy and didn't save the globflags if an exclusion
@@ -2406,6 +2410,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen,
 	} else
 	    ret = 0;
 
+	restore_queue_signals(q);
+
 	if (tryalloced)
 	    zfree(tryalloced, unmetalen + unmetalenp);
 
@@ -2485,7 +2491,7 @@ patmatch(Upat prog)
     zrange_t from, to, comp;
     patint_t nextch;
 
-    while  (scan) {
+    while  (scan && !errflag) {
 	next = PATNEXT(scan);
 
 	if (!globdots && P_NOTDOT(scan) && patinput == patinstart &&


           reply	other threads:[~2014-03-19  1:23 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <140318144230.ZM15739@torch.brasslantern.com>]

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=140318182320.ZM3488@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).