mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 06/10] hush: rename __promptme to interrupt
Date: Tue, 12 Nov 2013 14:52:15 +0100	[thread overview]
Message-ID: <1384264339-15986-7-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1384264339-15986-1-git-send-email-s.hauer@pengutronix.de>

the name '__promptme' does not make clear what the variable means. rename
it to 'interrupt' which is set to true when the user has hit ctrl-c.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/hush.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/common/hush.c b/common/hush.c
index f0f2eda..95054b3 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -254,7 +254,7 @@ typedef struct {
  * available?  Where is it documented? */
 struct in_str {
 	const char *p;
-	int __promptme;
+	int interrupt;
 	int promptmode;
 	int (*get) (struct in_str *);
 	int (*peek) (struct in_str *);
@@ -422,8 +422,6 @@ static void get_user_input(struct in_str *i)
 	static char the_command[CONFIG_CBSIZE];
 	char *prompt;
 
-	i->__promptme = 1;
-
 	if (i->promptmode == 1)
 		prompt = getprompt();
 	else
@@ -431,7 +429,7 @@ static void get_user_input(struct in_str *i)
 
 	n = readline(prompt, console_buffer, CONFIG_CBSIZE);
 	if (n == -1 ) {
-		i->__promptme = 0;
+		i->interrupt = 1;
 		n = 0;
 	}
 
@@ -456,7 +454,7 @@ static void get_user_input(struct in_str *i)
 		}
 	}
 
-	if (i->__promptme == 0) {
+	if (i->interrupt) {
 		the_command[0] = '\n';
 		the_command[1] = '\0';
 	}
@@ -503,7 +501,7 @@ static void setup_file_in_str(struct in_str *i)
 {
 	i->peek = file_peek;
 	i->get = file_get;
-	i->__promptme = 1;
+	i->interrupt = 0;
 	i->promptmode = 1;
 	i->p = NULL;
 }
@@ -512,7 +510,7 @@ static void setup_string_in_str(struct in_str *i, const char *s)
 {
 	i->peek = static_peek;
 	i->get = static_get;
-	i->__promptme = 1;
+	i->interrupt = 0;
 	i->promptmode = 1;
 	i->p = s;
 }
@@ -1470,7 +1468,7 @@ static int parse_stream(o_string *dest, struct p_context *ctx,
 
 	while ((ch = b_getch(input)) != EOF) {
 		m = map[ch];
-		if (input->__promptme == 0)
+		if (input->interrupt)
 			return 1;
 		next = (ch == '\n') ? 0 : b_peek(input);
 
@@ -1528,7 +1526,7 @@ static int parse_stream(o_string *dest, struct p_context *ctx,
 			dest->nonnull = 1;
 			b_addchr(dest, '\'');
 			while (ch = b_getch(input), ch != EOF && ch != '\'') {
-				if (input->__promptme == 0)
+				if (input->interrupt)
 					return 1;
 				b_addchr(dest,ch);
 			}
@@ -1660,7 +1658,7 @@ static int parse_stream_outer(struct p_context *ctx, struct in_str *inp, int fla
 				free(ctx->stack);
 				b_reset(&temp);
 			}
-			if (inp->__promptme == 0)
+			if (inp->interrupt)
 				printf("<INTERRUPT>\n");
 			temp.nonnull = 0;
 			temp.quote = 0;
-- 
1.8.4.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-11-12 13:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12 13:52 hush patches Sascha Hauer
2013-11-12 13:52 ` [PATCH 01/10] hush: fix exit on syntax error behaviour Sascha Hauer
2013-11-12 13:52 ` [PATCH 02/10] hush: refactor readline call Sascha Hauer
2013-11-12 13:52 ` [PATCH 03/10] readline: remove unused variable Sascha Hauer
2013-11-12 13:52 ` [PATCH 04/10] hush: refactor get_user_input() Sascha Hauer
2013-11-12 13:52 ` [PATCH 05/10] hush: refactor file_get() Sascha Hauer
2013-11-12 13:52 ` Sascha Hauer [this message]
2013-11-12 13:52 ` [PATCH 07/10] consolidate syntax() and syntax_err() Sascha Hauer
2013-11-12 13:52 ` [PATCH 08/10] hush: Be more informative on syntax error Sascha Hauer
2013-11-12 13:52 ` [PATCH 09/10] hush: use standard ARRAY_SIZE Sascha Hauer
2013-11-12 13:52 ` [PATCH 10/10] hush: refactor reserved_word() Sascha Hauer

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=1384264339-15986-7-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox