aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-05 18:31:19 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-05 18:31:19 +0100
commit0d7e46b1de8f11ccff9a5efa5d6d6ea6f5bacabf (patch)
treebcabeba170606fade38d9fc4a1351b1e5b45ce2a /miscutils
parent0064679915169dedca66a4365af7d9be7acc8153 (diff)
downloadbusybox-0d7e46b1de8f11ccff9a5efa5d6d6ea6f5bacabf.tar.gz
bc: tweak error messages
function old new delta bc_lex_token 1285 1299 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index ff44293ab..a78446d04 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -2951,7 +2951,7 @@ static BcStatus bc_lex_identifier(BcLex *l)
// buf starts with keyword bc_lex_kws[i]
l->t.t = BC_LEX_KEY_1st_keyword + i;
if (!((1 << i) & POSIX_KWORD_MASK)) {
- s = bc_posix_error_fmt("%sthe following keyword: '%.8s'", "POSIX does not allow ", bc_lex_kws[i].name8);
+ s = bc_posix_error_fmt("%sthe '%.8s' keyword", "POSIX does not allow ", bc_lex_kws[i].name8);
if (s) return s;
}
@@ -2963,8 +2963,14 @@ static BcStatus bc_lex_identifier(BcLex *l)
s = bc_lex_name(l);
if (s) return s;
- if (l->t.v.len > 2)
- s = bc_posix_error_fmt("POSIX only allows one character names; the following is bad: '%s'", buf);
+ if (l->t.v.len > 2) {
+ // Prevent this:
+ // >>> qwe=1
+ // bc: POSIX only allows one character names; the following is bad: 'qwe=1
+ // '
+ unsigned len = strchrnul(buf, '\n') - buf;
+ s = bc_posix_error_fmt("POSIX only allows one character names; the following is bad: '%.*s'", len, buf);
+ }
return s;
}