zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Crash when capturing command output in completion
Date: Fri, 16 Jan 2015 20:05:27 +0000	[thread overview]
Message-ID: <20150116200527.5bc0f308@ntlworld.com> (raw)
In-Reply-To: <CAH+w=7b_PPWUh23CPnNRnU9m2qc41A+nRQFrNekWXmehA_0gwg@mail.gmail.com>

On Fri, 16 Jan 2015 11:16:28 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> However, Ray's history recall problem DOES happen to me on MacOS ... start
> from zsh -f and setopt histreduceblanks to see it.

That explains that...  You'd also have seen it when trying to extract
words from the history.

I wonder how many oddities are left...

diff --git a/Src/hist.c b/Src/hist.c
index 1c5d045..c77b5dd 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -134,6 +134,8 @@ mod_export int hist_skip_flags;
 /* Bits of histactive variable */
 #define HA_ACTIVE	(1<<0)	/* History mechanism is active */
 #define HA_NOINC	(1<<1)	/* Don't store, curhist not incremented */
+#define HA_INWORD       (1<<2)  /* We're inside a word, don't add
+				   start and end markers */
 
 /* Array of word beginnings and endings in current history line. */
 
@@ -299,6 +301,22 @@ hist_context_restore(const struct hist_stack *hs, int toplevel)
     cmdsp = hs->csp;
 }
 
+/*
+ * Mark that the current level of history is or is not
+ * within a word, whatever turns up.  This is used for nested
+ * parsing of substitutions.
+ */
+
+/**/
+void
+hist_in_word(int yesno)
+{
+    if (yesno)
+	histactive |= HA_INWORD;
+    else
+	histactive &= ~HA_INWORD;
+}
+
 /* restore history context */
 
 /* add a character to the current history word */
@@ -1496,7 +1514,7 @@ int hwgetword = -1;
 void
 ihwbegin(int offset)
 {
-    if (stophist == 2)
+    if (stophist == 2 || (histactive & HA_INWORD))
 	return;
     if (chwordpos%2)
 	chwordpos--;	/* make sure we're on a word start, not end */
@@ -1516,7 +1534,7 @@ ihwbegin(int offset)
 void
 ihwend(void)
 {
-    if (stophist == 2)
+    if (stophist == 2 || (histactive & HA_INWORD))
 	return;
     if (chwordpos%2 && chline) {
 	/* end of word reached and we've already begun a word */
diff --git a/Src/lex.c b/Src/lex.c
index 96da1cb..6d45c70 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1922,6 +1922,7 @@ skipcomm(void)
 	new_lexbuf = lexbuf;
 
 	zcontext_save_partial(ZCONTEXT_LEX|ZCONTEXT_PARSE);
+	hist_in_word(1);
     } else {
 	/*
 	 * Set up for nested command subsitution, however
@@ -1992,6 +1993,7 @@ skipcomm(void)
 	tokstr = new_tokstr;
 	lexbuf = new_lexbuf;
 	lexstop = new_lexstop;
+	hist_in_word(0);
     }
 
     if (!lexstop)

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2015-01-16 20:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-15 19:34 Vin Shelton
2015-01-15 21:53 ` Bart Schaefer
2015-01-15 23:53   ` Vin Shelton
2015-01-16  0:27     ` Bart Schaefer
2015-01-16  3:11       ` Vin Shelton
2015-01-16  3:17         ` Vin Shelton
2015-01-16  4:43           ` Bart Schaefer
2015-01-16  5:20             ` Bart Schaefer
2015-01-16  9:44               ` Peter Stephenson
2015-01-16 12:57                 ` Peter Stephenson
2015-01-16 16:18                   ` Bart Schaefer
2015-01-16 16:25                     ` Bart Schaefer
2015-01-16 18:04                     ` Peter Stephenson
2015-01-16 18:58                       ` Bart Schaefer
2015-01-16 19:16                         ` Bart Schaefer
2015-01-16 20:05                           ` Peter Stephenson [this message]
2015-01-16 19:19                         ` Ray Andrews
2015-01-16  6:43             ` Ray Andrews
2015-01-16  7:49               ` Bart Schaefer
2015-01-16 16:21                 ` Ray Andrews
2015-01-16 16:34                   ` Bart Schaefer

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=20150116200527.5bc0f308@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).