diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-11-12 09:52:26 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-11-12 14:45:04 +0100 |
commit | ad560a179799aec8a8deb900ad8b5d2baa753cb0 (patch) | |
tree | 2d08f58286e2198768f5438fef7ba060c0709833 /common/hush.c | |
parent | 8875a3967937911f7437fc614416eedc1050cbe3 (diff) | |
download | barebox-ad560a179799aec8a8deb900ad8b5d2baa753cb0.tar.gz barebox-ad560a179799aec8a8deb900ad8b5d2baa753cb0.tar.xz |
hush: refactor file_get()
Save indentation level by returning early.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/hush.c')
-rw-r--r-- | common/hush.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/common/hush.c b/common/hush.c index 7a077baac7..f0f2eda395 100644 --- a/common/hush.c +++ b/common/hush.c @@ -471,21 +471,23 @@ static int file_get(struct in_str *i) int ch; ch = 0; + /* If there is data waiting, eat it up */ - if (i->p && *i->p) { + if (i->p && *i->p) + return *i->p++; + + /* need to double check i->file because we might be doing something + * more complicated by now, like sourcing or substituting. */ + while (!i->p || strlen(i->p) == 0 ) + get_user_input(i); + + i->promptmode = 2; + + if (i->p && *i->p) ch = *i->p++; - } else { - /* need to double check i->file because we might be doing something - * more complicated by now, like sourcing or substituting. */ - while (!i->p || strlen(i->p) == 0 ) { - get_user_input(i); - } - i->promptmode = 2; - if (i->p && *i->p) { - ch = *i->p++; - } - debug("%s: got a %d\n", __func__, ch); - } + + debug("%s: got a %d\n", __func__, ch); + return ch; } |