aboutsummaryrefslogtreecommitdiff
path: root/miscutils/bc.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* build system: avoid full rebuild when EXTRAVERSION changesRon Yorston2024-02-161-0/+3
| | | | | | | | | | The last two commits allow EXTRAVERSION to track the current state of a git repository. The build system was unable to determine which files were affected by changes to EXTRAVERSION and caused a full rebuild when it changed. Alter how the version information is passed to the code so only a handful of files need to be rebuilt when it changes.
* Merge branch 'busybox' into mergeRon Yorston2023-07-131-2/+2
|\
| * Update applet size estimatesDenys Vlasenko2023-07-101-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2022-10-121-1/+3
|\|
| * *: style fixDenys Vlasenko2022-08-301-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * bc: hopefully fix bug 14956 (use-after-free)Denys Vlasenko2022-08-181-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge busybox into mergeRon Yorston2022-02-091-1/+1
|\| | | | | | | | | | | | | | | Fix conflicts in reset and ash. Redefine the new safe_read_key() as a reference to read_key(). Disable SHA256_HWACCEL.
| * *: slap on a few ALIGN* where appropriateDenys Vlasenko2022-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map" function old new delta .rodata 108586 108460 -126 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-126) Total: -126 bytes text data bss dec hex filename 970412 4219 1848 976479 ee65f busybox_old 970286 4219 1848 976353 ee5e1 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-10-131-1/+1
|\|
| * *: add NOINLINEs where code noticeably shrinksDenys Vlasenko2021-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta display 85 1463 +1378 -73 bytes select_and_cluster - 1088 +1088 -139 bytes parse_reply - 979 +979 -109 bytes zbc_num_sqrt - 632 +632 -191 bytes show_bridge_port - 585 +585 -56 bytes sp_256_proj_point_add_8 - 576 +576 -45 bytes encode_then_append_var_plusminus - 554 +554 -118 bytes read_mode_db - 537 +537 -47 bytes fbset_main 1331 747 -584 sp_256_ecc_mulmod_8 1157 536 -621 brctl_main 2189 1548 -641 expand_one_var 2544 1872 -672 zxc_vm_process 6412 5589 -823 send_queries 1813 725 -1088 recv_and_process_peer_pkt 2245 1018 -1227 bb_dump_dump 1531 80 -1451 ------------------------------------------------------------------------------ (add/remove: 7/0 grow/shrink: 1/8 up/down: 6329/-7107) Total: -778 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-06-281-31/+44
|\|
| * *: more --help tweaksDenys Vlasenko2021-06-151-1/+1
| | | | | | | | | | | | | | function old new delta packed_usage 33552 33541 -11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * bc: tweak overflow detection in a^bDenys Vlasenko2021-06-121-5/+8
| | | | | | | | | | | | | | function old new delta zbc_num_p 506 510 +4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * bc: code shrink: combine init() and copy() where we canDenys Vlasenko2021-06-121-21/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta bc_num_init_and_copy - 27 +27 zxc_program_popResultAndCopyToVar 495 483 -12 zxc_num_printNum 518 506 -12 zbc_num_p 518 506 -12 zxc_program_assign 357 341 -16 zbc_num_m 298 267 -31 zxc_vm_process 6498 6412 -86 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/6 up/down: 27/-169) Total: -142 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * bc: fix for mul overflow in scale calculation in a^bDenys Vlasenko2021-06-121-8/+23
| | | | | | | | | | | | | | function old new delta zbc_num_p 516 518 +2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-05-141-2/+2
|\|
| * *: --help text tweaksDenys Vlasenko2021-04-141-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2021-03-011-6/+58
|\|
| * bc: typo fix in commentDenys Vlasenko2021-02-261-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * dc: more docs in --helpDenys Vlasenko2021-02-261-13/+14
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * dc: document what non-GNU commands doDenys Vlasenko2021-02-261-5/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * bc/dc: fix length(0) and length(0.000nnn) resultDenys Vlasenko2021-02-261-4/+13
| | | | | | | | | | | | | | function old new delta zxc_vm_process 6464 6498 +34 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * dc: correct --help textDenys Vlasenko2021-02-261-2/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | before: Tiny RPN calculator. Operations: +, -, *, /, %, ~, ^, |, p - print top of the stack without popping f - print entire stack k - pop the value and set the precision i - pop the value and set input radix o - pop the value and set output radix After: Tiny RPN calculator. Operations: Arithmetic: + - * / % ^ ~ - divide with remainder | - modular exponentiation v - square root p - print top of the stack without popping f - print entire stack k - pop the value and set precision i - pop the value and set input radix o - pop the value and set output radix function old new delta packed_usage 33519 33565 +46 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | bc: handle ^C in interactive modeRon Yorston2021-02-141-0/+13
| |
* | bc: fix to build on WIN32 and enable in default configurationsRon Yorston2021-02-131-0/+2
|/
* libbb: introduce and use fputs_stdoutRon Yorston2021-02-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta fputs_stdout - 12 +12 zxc_vm_process 7237 7230 -7 yes_main 85 78 -7 write_block 380 373 -7 wrapf 305 298 -7 strings_main 437 430 -7 show_bridge 353 346 -7 rev_main 384 377 -7 put_prompt_custom 58 51 -7 put_cur_glyph_and_inc_cursor 168 161 -7 print_numbered_lines 152 145 -7 print_named_ascii 130 123 -7 print_name 135 128 -7 print_login_issue 386 379 -7 print_ascii 208 201 -7 powertop_main 1249 1242 -7 od_main 1789 1782 -7 logread_main 518 511 -7 head_main 804 797 -7 display_process_list 1319 1312 -7 cut_main 1002 995 -7 bb_dump_dump 1550 1543 -7 bb_ask_noecho 393 386 -7 baseNUM_main 702 695 -7 expand_main 755 745 -10 dumpleases_main 497 487 -10 write1 12 - -12 putcsi 37 23 -14 print_login_prompt 55 41 -14 paste_main 525 511 -14 cat_main 440 426 -14 print_it 245 230 -15 print_addrinfo 1188 1171 -17 print_rule 770 750 -20 print_linkinfo 842 822 -20 httpd_main 791 771 -20 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341) Total: -329 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: code shrinkDenys Vlasenko2021-01-061-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: ^C on input line exits (unlike ^C during calculations, which does not)Denys Vlasenko2021-01-041-10/+10
| | | | | | | function old new delta xc_read_line 353 344 -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc,dc: make BC_LINE_LENGTH/DC_LINE_LENGTH more compatible with GNUDenys Vlasenko2020-12-291-15/+23
| | | | | | | function old new delta xc_vm_init 640 682 +42 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: placate gcc (it thinks 's' can be uninitialized here)Denys Vlasenko2020-12-291-8/+10
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: do not allocate line editing state until neededDenys Vlasenko2020-12-211-19/+18
| | | | | | | | | | | function old new delta xc_read_line 324 353 +29 free_line_input_t 34 39 +5 xc_vm_init 656 640 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 34/-16) Total: 18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* decrease padding: gcc-9.3.1 slaps 32-byte alignment on arrays willy-nillyDenys Vlasenko2020-11-301-1/+1
| | | | | | | | text data bss dec hex filename 1021236 559 5052 1026847 fab1f busybox_old 1021120 559 5052 1026731 faaab busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: placate a "defined but not used" warningDenys Vlasenko2020-06-241-0/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: fix comparison bug, closes 12336Denys Vlasenko2019-11-231-1/+4
| | | | | | | function old new delta bc_num_cmp 249 259 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: Add 'U' suffix in UINT_MAX preprocessor checkKang-Che Sung2019-09-121-2/+2
| | | | | | | | Without the 'U' unsigned suffix, gcc will throw a "integer constant is so large that it is unsigned" warning. Signed-off-by: Kang-Che Sung <explorer09@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* dc: Parse error & fix out of bounds read in xc_program_printStringBrian Foley2019-09-051-2/+4
| | | | | | | | function old new delta xc_program_print 712 735 +23 Signed-off-by: Brian Foley <bpfoley@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* dc: Fix segfault when executing strings generated using asciifyBrian Foley2019-09-051-2/+8
| | | | | | | | function old new delta zxc_vm_process 6884 6891 +7 Signed-off-by: Brian Foley <bpfoley@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* dc: execute shouldn't pop if stack head is not a stringBrian Foley2019-09-051-1/+2
| | | | | | | | | | | | | | This matches the behaviour of both GNU dc (as specified in its man page), and BSD dc (where stack_popstring() pops only if the head is a string.) Add a couple of tests to verify this behavior. function old new delta zxc_vm_process 6882 6884 +2 Signed-off-by: Brian Foley <bpfoley@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne2019-07-021-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: placate compiler warningsDenys Vlasenko2019-06-081-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: implement pass-by-reference code from upstreamDenys Vlasenko2019-01-251-86/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta zxc_program_popResultAndCopyToVar 298 493 +195 bc_vec_pushIndex - 75 +75 zxc_vm_process 859 928 +69 xc_program_dereference - 66 +66 bc_vec_npush - 65 +65 zbc_num_s 239 249 +10 zxc_program_num 1024 1032 +8 zbc_num_divmod 150 156 +6 xc_program_search 143 146 +3 zxc_program_assign 392 389 -3 zdc_program_execStr 520 517 -3 xc_program_pushVar 198 195 -3 zxc_program_exec 4101 4092 -9 zbc_program_call 318 308 -10 zbc_func_insert 120 104 -16 zbc_parse_stmt_possibly_auto 1460 1439 -21 bc_vec_push 53 12 -41 xc_parse_pushIndex 61 18 -43 ------------------------------------------------------------------------------ (add/remove: 3/0 grow/shrink: 6/9 up/down: 497/-149) Total: 348 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: code shrinkDenys Vlasenko2019-01-091-14/+14
| | | | | | | | | | | | | | | | | function old new delta xc_parse_pushInst_and_Index - 16 +16 zbc_parse_expr 1818 1816 -2 xc_parse_pushIndex 65 61 -4 zbc_parse_pushSTR 63 58 -5 zbc_parse_name 448 442 -6 xc_parse_pushNUM 74 67 -7 zdc_parse_expr 479 470 -9 bc_parse_pushJUMP_ZERO 21 12 -9 bc_parse_pushJUMP 21 12 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/8 up/down: 16/-51) Total: -35 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: remove "empty expression" check/message, parsing fails in these cases anywayDenys Vlasenko2019-01-081-3/+4
| | | | | | | function old new delta zbc_parse_expr 1848 1818 -30 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: zbc_parse_expr_empty_ok() is unused except by zbc_parse_expr(), fold it inDenys Vlasenko2019-01-081-36/+25
| | | | | | | function old new delta zbc_parse_expr 1865 1848 -17 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: disallow invalid syntax like "{ print 1 print 2 }"Denys Vlasenko2019-01-081-15/+21
| | | | | | | | | | | | | | | | | statement parsing must NOT eat the terminator: caller needs to know what it was, to correctly decide whether it is a valid one. function old new delta zxc_program_read - 234 +234 zdc_program_printStream - 144 +144 zbc_parse_stmt_possibly_auto 1413 1460 +47 zxc_vm_process 869 859 -10 zxc_program_exec 4116 4101 -15 zdc_program_asciify 368 - -368 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 1/2 up/down: 425/-393) Total: 32 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* sleep: support "inf"Denys Vlasenko2019-01-071-1/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: shorten "limits" outputDenys Vlasenko2019-01-041-4/+1
| | | | | | | | text data bss dec hex filename 979016 485 7296 986797 f0ead busybox_old 978959 485 7296 986740 f0e74 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: formatting changes, added a FIXME comment, no logic changesDenys Vlasenko2019-01-041-5/+8
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* bc: support void functions (GNU compat)Denys Vlasenko2019-01-041-19/+56
| | | | | | | | | | | | | | | | function old new delta xc_program_print - 689 +689 zxc_vm_process 814 869 +55 zxc_program_exec 4098 4116 +18 zxc_program_assign 385 392 +7 bc_result_free 43 46 +3 zxc_program_binOpPrep 243 245 +2 zdc_program_execStr 518 520 +2 zxc_program_print 683 - -683 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 6/0 up/down: 776/-683) Total: 93 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* dc: fit returning of stringDenys Vlasenko2019-01-041-5/+13
| | | | | | | function old new delta zxc_program_exec 4087 4098 +11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>