From: Herbert Xu <herbert@gondor.apana.org.au>
To: Eric Blake <eblake@redhat.com>
Cc: Oleg Bulatov <oleg@bulatov.me>, dash@vger.kernel.org
Subject: Re: Line continuation and variables
Date: Mon, 29 Sep 2014 22:57:27 +0800 [thread overview]
Message-ID: <20140929145727.GA3723@gondor.apana.org.au> (raw)
In-Reply-To: <20140929145507.GA3670@gondor.apana.org.au>
On Mon, Sep 29, 2014 at 10:55:07PM +0800, Herbert Xu wrote:
>
> I agree. The following patch should fix this:
>
> commit ef91d3d6a4c39421fd3a391e02cd82f9f3aee4a8
> Author: Herbert Xu <herbert@gondor.apana.org.au>
> Date: Mon Sep 29 22:52:41 2014 +0800
>
> [PARSER] Handle backslash newlines properly after dollar sign
Here is a small clean-up on top of it:
commit 6df87cf1d4b7c0c490ab1803b863de10579df92e
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date: Mon Sep 29 22:53:53 2014 +0800
[PARSER] Add nlprompt/nlnoprompt helpers
This patch adds the nlprompt/nlnoprompt helpers to isolate code
dealing with newlines and prompting.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/ChangeLog b/ChangeLog
index 398bd15..f161a13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
* Kill pgetc_macro.
* Handle backslash newlines properly after dollar sign.
+ * Add nlprompt/nlnoprompt helpers.
2014-09-28 Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/src/parser.c b/src/parser.c
index 2b07437..f6c43be 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -743,6 +743,19 @@ out:
return (t);
}
+static void nlprompt(void)
+{
+ plinno++;
+ if (doprompt)
+ setprompt(2);
+}
+
+static void nlnoprompt(void)
+{
+ plinno++;
+ needprompt = doprompt;
+}
+
/*
* Read the next input token.
@@ -786,16 +799,13 @@ xxreadtoken(void)
continue;
case '\\':
if (pgetc() == '\n') {
- plinno++;
- if (doprompt)
- setprompt(2);
+ nlprompt();
continue;
}
pungetc();
goto breakloop;
case '\n':
- plinno++;
- needprompt = doprompt;
+ nlnoprompt();
RETURN(TNL);
case PEOF:
RETURN(TEOF);
@@ -837,9 +847,7 @@ static int pgetc_eatbnl(void)
break;
}
- plinno++;
- if (doprompt)
- setprompt(2);
+ nlprompt();
}
return c;
@@ -913,9 +921,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
if (syntax == BASESYNTAX)
goto endword; /* exit outer loop */
USTPUTC(c, out);
- plinno++;
- if (doprompt)
- setprompt(2);
+ nlprompt();
c = pgetc();
goto loop; /* continue outer loop */
case CWORD:
@@ -934,9 +940,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
USTPUTC('\\', out);
pungetc();
} else if (c == '\n') {
- plinno++;
- if (doprompt)
- setprompt(2);
+ nlprompt();
} else {
if (
dblquote &&
@@ -1092,8 +1096,7 @@ checkend: {
if (c == '\n' || c == PEOF) {
c = PEOF;
- plinno++;
- needprompt = doprompt;
+ nlnoprompt();
} else {
int len;
@@ -1342,9 +1345,7 @@ parsebackq: {
case '\\':
if ((pc = pgetc()) == '\n') {
- plinno++;
- if (doprompt)
- setprompt(2);
+ nlprompt();
/*
* If eating a newline, avoid putting
* the newline into the new character
@@ -1366,8 +1367,7 @@ parsebackq: {
synerror("EOF in backquote substitution");
case '\n':
- plinno++;
- needprompt = doprompt;
+ nlnoprompt();
break;
default:
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2014-09-29 14:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 12:15 Line continuation and variables Oleg Bulatov
2014-08-26 12:34 ` Eric Blake
2014-09-29 14:55 ` Herbert Xu
2014-09-29 14:57 ` Herbert Xu [this message]
2014-10-29 21:52 ` Jilles Tjoelker
2014-10-30 2:10 ` Herbert Xu
2015-01-05 12:00 ` [0/4] input: Allow two consecutive calls to pungetc Herbert Xu
2015-01-05 12:01 ` [PATCH 1/4] input: Make preadbuffer static Herbert Xu
2015-01-05 12:01 ` [PATCH 2/4] input: Remove HETIO Herbert Xu
2015-01-05 12:01 ` [PATCH 3/4] input: Move all input state into parsefile Herbert Xu
2015-01-05 12:01 ` [PATCH 4/4] input: Allow two consecutive calls to pungetc Herbert Xu
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=20140929145727.GA3723@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=dash@vger.kernel.org \
--cc=eblake@redhat.com \
--cc=oleg@bulatov.me \
/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.
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).