aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-03 00:51:25 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-05 15:43:35 +0100
commit01cabafd05410548bd7f539fb09dc3a8a9f48e08 (patch)
treea88277105f380c61bdc3a0e1c6ac3dc8adac7e4b
parentb8860a8892f077091177170fe483d545d33789a6 (diff)
downloadbusybox-w32-01cabafd05410548bd7f539fb09dc3a8a9f48e08.tar.gz
busybox-w32-01cabafd05410548bd7f539fb09dc3a8a9f48e08.tar.bz2
busybox-w32-01cabafd05410548bd7f539fb09dc3a8a9f48e08.zip
bc": drop unused error codes and strings
function old new delta bc_err_msgs 216 192 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-24) Total: -24 bytes text data bss dec hex filename 988122 485 7296 995903 f323f busybox_old 987936 485 7296 995717 f3185 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c155
1 files changed, 73 insertions, 82 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index a8b170f0c..ee6cc47ce 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -168,13 +168,12 @@
168#include "libbb.h" 168#include "libbb.h"
169 169
170typedef enum BcStatus { 170typedef enum BcStatus {
171
172 BC_STATUS_SUCCESS, 171 BC_STATUS_SUCCESS,
173 172
174 BC_STATUS_ALLOC_ERR, 173// BC_STATUS_ALLOC_ERR,
175 BC_STATUS_INPUT_EOF, 174 BC_STATUS_INPUT_EOF,
176 BC_STATUS_BIN_FILE, 175 BC_STATUS_BIN_FILE,
177 BC_STATUS_PATH_IS_DIR, 176// BC_STATUS_PATH_IS_DIR,
178 177
179 BC_STATUS_LEX_BAD_CHAR, 178 BC_STATUS_LEX_BAD_CHAR,
180 BC_STATUS_LEX_NO_STRING_END, 179 BC_STATUS_LEX_NO_STRING_END,
@@ -183,7 +182,6 @@ typedef enum BcStatus {
183#if ENABLE_DC 182#if ENABLE_DC
184 BC_STATUS_LEX_EXTENDED_REG, 183 BC_STATUS_LEX_EXTENDED_REG,
185#endif 184#endif
186
187 BC_STATUS_PARSE_BAD_TOKEN, 185 BC_STATUS_PARSE_BAD_TOKEN,
188 BC_STATUS_PARSE_BAD_EXP, 186 BC_STATUS_PARSE_BAD_EXP,
189 BC_STATUS_PARSE_EMPTY_EXP, 187 BC_STATUS_PARSE_EMPTY_EXP,
@@ -200,7 +198,7 @@ typedef enum BcStatus {
200 BC_STATUS_MATH_DIVIDE_BY_ZERO, 198 BC_STATUS_MATH_DIVIDE_BY_ZERO,
201 BC_STATUS_MATH_BAD_STRING, 199 BC_STATUS_MATH_BAD_STRING,
202 200
203 BC_STATUS_EXEC_FILE_ERR, 201// BC_STATUS_EXEC_FILE_ERR,
204 BC_STATUS_EXEC_MISMATCHED_PARAMS, 202 BC_STATUS_EXEC_MISMATCHED_PARAMS,
205 BC_STATUS_EXEC_UNDEFINED_FUNC, 203 BC_STATUS_EXEC_UNDEFINED_FUNC,
206 BC_STATUS_EXEC_FILE_NOT_EXECUTABLE, 204 BC_STATUS_EXEC_FILE_NOT_EXECUTABLE,
@@ -209,17 +207,16 @@ typedef enum BcStatus {
209 BC_STATUS_EXEC_STRING_LEN, 207 BC_STATUS_EXEC_STRING_LEN,
210 BC_STATUS_EXEC_ARRAY_LEN, 208 BC_STATUS_EXEC_ARRAY_LEN,
211 BC_STATUS_EXEC_BAD_IBASE, 209 BC_STATUS_EXEC_BAD_IBASE,
212 BC_STATUS_EXEC_BAD_SCALE, 210// BC_STATUS_EXEC_BAD_SCALE,
213 BC_STATUS_EXEC_BAD_READ_EXPR, 211 BC_STATUS_EXEC_BAD_READ_EXPR,
214 BC_STATUS_EXEC_REC_READ, 212 BC_STATUS_EXEC_REC_READ,
215 BC_STATUS_EXEC_BAD_TYPE, 213 BC_STATUS_EXEC_BAD_TYPE,
216 BC_STATUS_EXEC_BAD_OBASE, 214// BC_STATUS_EXEC_BAD_OBASE,
217 BC_STATUS_EXEC_SIGNAL, 215 BC_STATUS_EXEC_SIGNAL,
218 BC_STATUS_EXEC_STACK, 216 BC_STATUS_EXEC_STACK,
219 217
220 BC_STATUS_VEC_OUT_OF_BOUNDS, 218// BC_STATUS_VEC_OUT_OF_BOUNDS,
221 BC_STATUS_VEC_ITEM_EXISTS, 219 BC_STATUS_VEC_ITEM_EXISTS,
222
223#if ENABLE_BC 220#if ENABLE_BC
224 BC_STATUS_POSIX_NAME_LEN, 221 BC_STATUS_POSIX_NAME_LEN,
225 BC_STATUS_POSIX_COMMENT, 222 BC_STATUS_POSIX_COMMENT,
@@ -234,13 +231,77 @@ typedef enum BcStatus {
234 BC_STATUS_POSIX_FOR3, 231 BC_STATUS_POSIX_FOR3,
235 BC_STATUS_POSIX_BRACE, 232 BC_STATUS_POSIX_BRACE,
236#endif 233#endif
237
238 BC_STATUS_QUIT, 234 BC_STATUS_QUIT,
239 BC_STATUS_LIMITS, 235 BC_STATUS_LIMITS,
240 236
241 BC_STATUS_INVALID_OPTION, 237// BC_STATUS_INVALID_OPTION,
242
243} BcStatus; 238} BcStatus;
239// Keep enum above and messages below in sync!
240static const char *const bc_err_msgs[] = {
241 NULL,
242// "memory allocation error",
243 "I/O error",
244 "file is not text:",
245// "path is a directory:",
246
247 "bad character",
248 "string end could not be found",
249 "comment end could not be found",
250 "end of file",
251#if ENABLE_DC
252 "extended register",
253#endif
254 "bad token",
255 "bad expression",
256 "empty expression",
257 "bad print statement",
258 "bad function definition",
259 "bad assignment: left side must be scale, ibase, "
260 "obase, last, var, or array element",
261 "no auto variable found",
262 "function parameter or auto var has the same name as another",
263 "block end could not be found",
264
265 "negative number",
266 "non integer number",
267 "overflow",
268 "divide by zero",
269 "bad number string",
270
271// "could not open file:",
272 "mismatched parameters", // wrong number of them, to be exact
273 "undefined function",
274 "file is not executable:",
275 "number too long: must be [1, BC_NUM_MAX]",
276 "name too long: must be [1, BC_NAME_MAX]",
277 "string too long: must be [1, BC_STRING_MAX]",
278 "array too long; must be [1, BC_DIM_MAX]",
279 "bad ibase; must be [2, 16]",
280// "bad scale; must be [0, BC_SCALE_MAX]",
281 "bad read() expression",
282 "read() call inside of a read() call",
283 "variable is wrong type",
284// "bad obase; must be [2, BC_BASE_MAX]",
285 "signal caught and not handled",
286 "stack has too few elements",
287
288// "index is out of bounds",
289 "item already exists",
290#if ENABLE_BC
291 "POSIX only allows one character names; the following is bad:",
292 "POSIX does not allow '#' script comments",
293 "POSIX does not allow the following keyword:",
294 "POSIX does not allow a period ('.') as a shortcut for the last result",
295 "POSIX requires parentheses around return expressions",
296 "POSIX does not allow boolean operators; the following is bad:",
297 "POSIX does not allow comparison operators outside if or loops",
298 "POSIX requires exactly one comparison operator per condition",
299 "POSIX does not allow an empty init expression in a for loop",
300 "POSIX does not allow an empty condition expression in a for loop",
301 "POSIX does not allow an empty update expression in a for loop",
302 "POSIX requires the left brace be on the same line as the function header",
303#endif
304};
244 305
245#define BC_VEC_INVALID_IDX ((size_t) -1) 306#define BC_VEC_INVALID_IDX ((size_t) -1)
246#define BC_VEC_START_CAP (1 << 5) 307#define BC_VEC_START_CAP (1 << 5)
@@ -838,76 +899,6 @@ static const char bc_err_fmt[] = "\nerror: %s\n";
838static const char bc_warn_fmt[] = "\nwarning: %s\n"; 899static const char bc_warn_fmt[] = "\nwarning: %s\n";
839static const char bc_err_line[] = ":%zu\n\n"; 900static const char bc_err_line[] = ":%zu\n\n";
840 901
841static const char *bc_err_msgs[] = {
842
843 NULL,
844 "memory allocation error",
845 "I/O error",
846 "file is not text:",
847 "path is a directory:",
848
849 "bad character",
850 "string end could not be found",
851 "comment end could not be found",
852 "end of file",
853#if ENABLE_DC
854 "extended register",
855#endif
856
857 "bad token",
858 "bad expression",
859 "empty expression",
860 "bad print statement",
861 "bad function definition",
862 "bad assignment: left side must be scale, ibase, "
863 "obase, last, var, or array element",
864 "no auto variable found",
865 "function parameter or auto var has the same name as another",
866 "block end could not be found",
867
868 "negative number",
869 "non integer number",
870 "overflow",
871 "divide by zero",
872 "bad number string",
873
874 "could not open file:",
875 "mismatched parameters",
876 "undefined function",
877 "file is not executable:",
878 "number too long: must be [1, BC_NUM_MAX]",
879 "name too long: must be [1, BC_NAME_MAX]",
880 "string too long: must be [1, BC_STRING_MAX]",
881 "array too long; must be [1, BC_DIM_MAX]",
882 "bad ibase; must be [2, 16]",
883 "bad scale; must be [0, BC_SCALE_MAX]",
884 "bad read() expression",
885 "read() call inside of a read() call",
886 "variable is wrong type",
887 "bad obase; must be [2, BC_BASE_MAX]",
888 "signal caught and not handled",
889 "stack has too few elements",
890
891 "index is out of bounds",
892 "item already exists",
893
894#if ENABLE_BC
895 "POSIX only allows one character names; the following is bad:",
896 "POSIX does not allow '#' script comments",
897 "POSIX does not allow the following keyword:",
898 "POSIX does not allow a period ('.') as a shortcut for the last result",
899 "POSIX requires parentheses around return expressions",
900 "POSIX does not allow boolean operators; the following is bad:",
901 "POSIX does not allow comparison operators outside if or loops",
902 "POSIX requires exactly one comparison operator per condition",
903 "POSIX does not allow an empty init expression in a for loop",
904 "POSIX does not allow an empty condition expression in a for loop",
905 "POSIX does not allow an empty update expression in a for loop",
906 "POSIX requires the left brace be on the same line as the function header",
907#endif
908
909};
910
911#if ENABLE_BC 902#if ENABLE_BC
912static const BcLexKeyword bc_lex_kws[20] = { 903static const BcLexKeyword bc_lex_kws[20] = {
913 BC_LEX_KW_ENTRY("auto", 4, true), 904 BC_LEX_KW_ENTRY("auto", 4, true),