zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: splitting of case in history
@ 2011-05-27 19:53 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2011-05-27 19:53 UTC (permalink / raw)
  To: Zsh hackers list

With HIST_LEX_WORDS, if the history contains

case a in\
(a) foo=4\
;;\
esac

then word splitting gets confused because the newline before the ";;" gets
turned into a ";" that matches the first ";" of the pair.

Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.110
diff -p -u -r1.110 hist.c
--- Src/hist.c	19 May 2011 16:10:48 -0000	1.110
+++ Src/hist.c	27 May 2011 19:50:32 -0000
@@ -2406,6 +2406,13 @@ readhistfile(char *fn, int err, int read
 			    uselex = 0;
 			    break;
 			}
+		    } else if (!strcmp(word, ";") && strpfx(";;", pt)) {
+			/*
+			 * Don't get confused between a semicolon that's
+			 * probably really a newline and a double
+			 * semicolon that's terminating a case.
+			 */
+			continue;
 		    }
 		    words[nwordpos++] = pt - start;
 		    pt += strlen(word);

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-27 20:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27 19:53 PATCH: splitting of case in history Peter Stephenson

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).