diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-06 11:43:17 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-06 11:43:17 +0100 |
| commit | 23c2e9fcf9a61da814aee986b30efd9c531fb94d (patch) | |
| tree | ff38463dacfc873d56252a7bbd0ed245969bf755 /miscutils | |
| parent | 9ca9ef2d5b4eea4ee79784b226c556ab8b0818de (diff) | |
| download | busybox-w32-23c2e9fcf9a61da814aee986b30efd9c531fb94d.tar.gz busybox-w32-23c2e9fcf9a61da814aee986b30efd9c531fb94d.tar.bz2 busybox-w32-23c2e9fcf9a61da814aee986b30efd9c531fb94d.zip | |
bc: unbreak "BC only" and "DC only" configs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/bc.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 26044afbc..ad6831683 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
| @@ -974,6 +974,7 @@ static NOINLINE int bc_error_fmt(const char *fmt, ...) | |||
| 974 | return BC_STATUS_FAILURE; | 974 | return BC_STATUS_FAILURE; |
| 975 | } | 975 | } |
| 976 | 976 | ||
| 977 | #if ENABLE_BC | ||
| 977 | static NOINLINE int bc_posix_error_fmt(const char *fmt, ...) | 978 | static NOINLINE int bc_posix_error_fmt(const char *fmt, ...) |
| 978 | { | 979 | { |
| 979 | va_list p; | 980 | va_list p; |
| @@ -993,6 +994,7 @@ static NOINLINE int bc_posix_error_fmt(const char *fmt, ...) | |||
| 993 | exit(1); | 994 | exit(1); |
| 994 | return BC_STATUS_FAILURE; | 995 | return BC_STATUS_FAILURE; |
| 995 | } | 996 | } |
| 997 | #endif | ||
| 996 | 998 | ||
| 997 | // We use error functions with "return bc_error(FMT[, PARAMS])" idiom. | 999 | // We use error functions with "return bc_error(FMT[, PARAMS])" idiom. |
| 998 | // This idiom begs for tail-call optimization, but for it to work, | 1000 | // This idiom begs for tail-call optimization, but for it to work, |
| @@ -1003,6 +1005,7 @@ static int bc_error(const char *msg) | |||
| 1003 | { | 1005 | { |
| 1004 | return bc_error_fmt("%s", msg); | 1006 | return bc_error_fmt("%s", msg); |
| 1005 | } | 1007 | } |
| 1008 | #if ENABLE_BC | ||
| 1006 | static int bc_POSIX_requires(const char *msg) | 1009 | static int bc_POSIX_requires(const char *msg) |
| 1007 | { | 1010 | { |
| 1008 | return bc_posix_error_fmt("POSIX requires %s", msg); | 1011 | return bc_posix_error_fmt("POSIX requires %s", msg); |
| @@ -1019,6 +1022,7 @@ static int bc_POSIX_does_not_allow_empty_X_expression_in_for(const char *msg) | |||
| 1019 | { | 1022 | { |
| 1020 | return bc_posix_error_fmt("%san empty %s expression in a for loop", "POSIX does not allow ", msg); | 1023 | return bc_posix_error_fmt("%san empty %s expression in a for loop", "POSIX does not allow ", msg); |
| 1021 | } | 1024 | } |
| 1025 | #endif | ||
| 1022 | static int bc_error_bad_character(char c) | 1026 | static int bc_error_bad_character(char c) |
| 1023 | { | 1027 | { |
| 1024 | return bc_error_fmt("bad character '%c'", c); | 1028 | return bc_error_fmt("bad character '%c'", c); |
| @@ -1210,12 +1214,14 @@ static int bc_map_insert(BcVec *v, const void *ptr, size_t *i) | |||
| 1210 | return 1; // "was inserted" | 1214 | return 1; // "was inserted" |
| 1211 | } | 1215 | } |
| 1212 | 1216 | ||
| 1217 | #if ENABLE_BC | ||
| 1213 | static size_t bc_map_index(const BcVec *v, const void *ptr) | 1218 | static size_t bc_map_index(const BcVec *v, const void *ptr) |
| 1214 | { | 1219 | { |
| 1215 | size_t i = bc_map_find(v, ptr); | 1220 | size_t i = bc_map_find(v, ptr); |
| 1216 | if (i >= v->len) return BC_VEC_INVALID_IDX; | 1221 | if (i >= v->len) return BC_VEC_INVALID_IDX; |
| 1217 | return bc_id_cmp(ptr, bc_vec_item(v, i)) ? BC_VEC_INVALID_IDX : i; | 1222 | return bc_id_cmp(ptr, bc_vec_item(v, i)) ? BC_VEC_INVALID_IDX : i; |
| 1218 | } | 1223 | } |
| 1224 | #endif | ||
| 1219 | 1225 | ||
| 1220 | static int push_input_byte(BcVec *vec, char c) | 1226 | static int push_input_byte(BcVec *vec, char c) |
| 1221 | { | 1227 | { |
| @@ -2673,6 +2679,7 @@ err: | |||
| 2673 | } | 2679 | } |
| 2674 | #endif // ENABLE_DC | 2680 | #endif // ENABLE_DC |
| 2675 | 2681 | ||
| 2682 | #if ENABLE_BC | ||
| 2676 | static BcStatus bc_func_insert(BcFunc *f, char *name, bool var) | 2683 | static BcStatus bc_func_insert(BcFunc *f, char *name, bool var) |
| 2677 | { | 2684 | { |
| 2678 | BcId a; | 2685 | BcId a; |
| @@ -2690,6 +2697,7 @@ static BcStatus bc_func_insert(BcFunc *f, char *name, bool var) | |||
| 2690 | 2697 | ||
| 2691 | return BC_STATUS_SUCCESS; | 2698 | return BC_STATUS_SUCCESS; |
| 2692 | } | 2699 | } |
| 2700 | #endif | ||
| 2693 | 2701 | ||
| 2694 | static void bc_func_init(BcFunc *f) | 2702 | static void bc_func_init(BcFunc *f) |
| 2695 | { | 2703 | { |
| @@ -5227,18 +5235,18 @@ static void dc_parse_init(BcParse *p, size_t func) | |||
| 5227 | static void common_parse_init(BcParse *p, size_t func) | 5235 | static void common_parse_init(BcParse *p, size_t func) |
| 5228 | { | 5236 | { |
| 5229 | if (IS_BC) { | 5237 | if (IS_BC) { |
| 5230 | bc_parse_init(p, func); | 5238 | IF_BC(bc_parse_init(p, func);) |
| 5231 | } else { | 5239 | } else { |
| 5232 | dc_parse_init(p, func); | 5240 | IF_DC(dc_parse_init(p, func);) |
| 5233 | } | 5241 | } |
| 5234 | } | 5242 | } |
| 5235 | 5243 | ||
| 5236 | static BcStatus common_parse_expr(BcParse *p, uint8_t flags) | 5244 | static BcStatus common_parse_expr(BcParse *p, uint8_t flags) |
| 5237 | { | 5245 | { |
| 5238 | if (IS_BC) { | 5246 | if (IS_BC) { |
| 5239 | return bc_parse_expression(p, flags); | 5247 | IF_BC(return bc_parse_expression(p, flags);) |
| 5240 | } else { | 5248 | } else { |
| 5241 | return dc_parse_expr(p, flags); | 5249 | IF_DC(return dc_parse_expr(p, flags);) |
| 5242 | } | 5250 | } |
| 5243 | } | 5251 | } |
| 5244 | 5252 | ||
| @@ -7427,12 +7435,12 @@ static void bc_vm_init(void) | |||
| 7427 | { | 7435 | { |
| 7428 | bc_vec_init(&G.files, sizeof(char *), NULL); | 7436 | bc_vec_init(&G.files, sizeof(char *), NULL); |
| 7429 | if (IS_BC) | 7437 | if (IS_BC) |
| 7430 | bc_vm_envArgs(); | 7438 | IF_BC(bc_vm_envArgs();) |
| 7431 | bc_program_init(); | 7439 | bc_program_init(); |
| 7432 | if (IS_BC) { | 7440 | if (IS_BC) { |
| 7433 | bc_parse_init(&G.prs, BC_PROG_MAIN); | 7441 | IF_BC(bc_parse_init(&G.prs, BC_PROG_MAIN);) |
| 7434 | } else { | 7442 | } else { |
| 7435 | dc_parse_init(&G.prs, BC_PROG_MAIN); | 7443 | IF_DC(dc_parse_init(&G.prs, BC_PROG_MAIN);) |
| 7436 | } | 7444 | } |
| 7437 | } | 7445 | } |
| 7438 | 7446 | ||
