From 5858e79f4d942ab13414f5efaf6f280bac690060 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 13 Dec 2010 11:20:46 +0000 Subject: 28526: remove bogus newline with stripped comment zplitting --- ChangeLog | 8 +++++++- Src/lex.c | 10 +++++++++- Test/D04parameter.ztst | 6 ++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 492ee37b4..05179c468 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-13 Peter Stephenson + + * 28526: Src/lex.c, Test/D04parameter.ztst: zplitting + 'line # with comment' when stripping comments shouldn't generate + a newline at the end (unless there is one). + 2010-12-12 Peter Stephenson * 28510: Doc/Zsh/expn.yo, Src/hist.c, Src/lex.c, Src/subst.c, @@ -13936,5 +13942,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5147 $ +* $Revision: 1.5148 $ ***************************************************** diff --git a/Src/lex.c b/Src/lex.c index 44cfa17ca..20511f54e 100644 --- a/Src/lex.c +++ b/Src/lex.c @@ -800,7 +800,15 @@ gettok(void) hwbegin(0); hwaddc('\n'); addtoline('\n'); - peek = NEWLIN; + /* + * If splitting a line and removing comments, + * we don't want a newline token since it's + * treated specially. + */ + if (zleparse == 3 && lexstop) + peek = ENDINPUT; + else + peek = NEWLIN; } } return peek; diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index e2772afe5..8791f570a 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -456,6 +456,12 @@ >another >one + line='with comment # at the end' + print -l ${(z+C+)line} +0:Test we don't get an additional newline token +>with +>comment + psvar=(dog) setopt promptsubst foo='It shouldn'\''t $(happen) to a %1v.' -- cgit 1.4.1