diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-05 18:31:19 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-05 18:31:19 +0100 |
commit | 0d7e46b1de8f11ccff9a5efa5d6d6ea6f5bacabf (patch) | |
tree | bcabeba170606fade38d9fc4a1351b1e5b45ce2a /miscutils/bc.c | |
parent | 0064679915169dedca66a4365af7d9be7acc8153 (diff) | |
download | busybox-w32-0d7e46b1de8f11ccff9a5efa5d6d6ea6f5bacabf.tar.gz busybox-w32-0d7e46b1de8f11ccff9a5efa5d6d6ea6f5bacabf.tar.bz2 busybox-w32-0d7e46b1de8f11ccff9a5efa5d6d6ea6f5bacabf.zip |
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 '')
-rw-r--r-- | miscutils/bc.c | 12 |
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) | |||
2951 | // buf starts with keyword bc_lex_kws[i] | 2951 | // buf starts with keyword bc_lex_kws[i] |
2952 | l->t.t = BC_LEX_KEY_1st_keyword + i; | 2952 | l->t.t = BC_LEX_KEY_1st_keyword + i; |
2953 | if (!((1 << i) & POSIX_KWORD_MASK)) { | 2953 | if (!((1 << i) & POSIX_KWORD_MASK)) { |
2954 | s = bc_posix_error_fmt("%sthe following keyword: '%.8s'", "POSIX does not allow ", bc_lex_kws[i].name8); | 2954 | s = bc_posix_error_fmt("%sthe '%.8s' keyword", "POSIX does not allow ", bc_lex_kws[i].name8); |
2955 | if (s) return s; | 2955 | if (s) return s; |
2956 | } | 2956 | } |
2957 | 2957 | ||
@@ -2963,8 +2963,14 @@ static BcStatus bc_lex_identifier(BcLex *l) | |||
2963 | s = bc_lex_name(l); | 2963 | s = bc_lex_name(l); |
2964 | if (s) return s; | 2964 | if (s) return s; |
2965 | 2965 | ||
2966 | if (l->t.v.len > 2) | 2966 | if (l->t.v.len > 2) { |
2967 | s = bc_posix_error_fmt("POSIX only allows one character names; the following is bad: '%s'", buf); | 2967 | // Prevent this: |
2968 | // >>> qwe=1 | ||
2969 | // bc: POSIX only allows one character names; the following is bad: 'qwe=1 | ||
2970 | // ' | ||
2971 | unsigned len = strchrnul(buf, '\n') - buf; | ||
2972 | s = bc_posix_error_fmt("POSIX only allows one character names; the following is bad: '%.*s'", len, buf); | ||
2973 | } | ||
2968 | 2974 | ||
2969 | return s; | 2975 | return s; |
2970 | } | 2976 | } |