Denys Vlasenko
07a95cfcab
ash: disable check for "good" function name, bash does not check this
...
function old new delta
.rodata 105304 105261 -43
parse_command 1696 1633 -63
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-106) Total: -106 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-04 14:38:25 +02:00
Denys Vlasenko
e5692e2342
hush: quote values in "readonly" output
...
function old new delta
builtin_readonly 61 107 +46
builtin_export 140 145 +5
.rodata 105321 105304 -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 51/-17) Total: 34 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-03 14:30:59 +02:00
Denys Vlasenko
cc9543fed1
shell/math: avoid $((3**999999999999999999)) to take years
...
function old new delta
arith_apply 991 1030 +39
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-02 19:32:12 +02:00
Denys Vlasenko
045924ed7d
shell/math: do not accept $((36#@))
...
function old new delta
parse_with_base 170 174 +4
arith_apply 996 991 -5
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-5) Total: -1 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-07-02 17:58:20 +02:00
Denys Vlasenko
38f769ab4e
shell/math: code shrink
...
function old new delta
arith_apply 999 996 -3
evaluate_string 1295 1291 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-7) Total: -7 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-30 19:16:41 +02:00
Denys Vlasenko
6a0ba67382
shell/math: code shrink
...
function old new delta
arith_apply 1023 996 -27
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-29 11:01:50 +02:00
Denys Vlasenko
800207b90a
shell/math: code shrink
...
function old new delta
arith_apply 1015 1023 +8
evaluate_string 1309 1295 -14
.rodata 105344 105321 -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 8/-37) Total: -29 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-28 14:18:35 +02:00
Denys Vlasenko
e619a25a55
shell/math: improve comments
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-26 11:08:40 +02:00
Denys Vlasenko
5d8f8570c0
shell/math: rename TOK_NUM to TOK_VALUE, improve comments
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-26 10:02:54 +02:00
Denys Vlasenko
c1c267fd36
shell/math: bash-compatible handling of too large numbers
...
function old new delta
parse_with_base - 170 +170
evaluate_string 1477 1309 -168
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 170/-168) Total: 2 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-25 17:42:05 +02:00
Denys Vlasenko
019dd31150
shell/math: disable debug again
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-19 10:23:58 +02:00
Denys Vlasenko
db0e886735
shell/math: $((1?)) has one-too-small opstack, fix this
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-19 10:22:15 +02:00
Denys Vlasenko
a165098922
shell/math: fix comments about jammed-together num+num corner cases
...
function old new delta
evaluate_string 1478 1470 -8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-19 09:44:04 +02:00
Denys Vlasenko
79b90cbece
shell/math: add note on ERANGE
...
function old new delta
evaluate_string 1488 1478 -10
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 20:15:35 +02:00
Denys Vlasenko
10cce8ae35
shell/math: explain why we use separate &end
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 19:30:22 +02:00
Denys Vlasenko
7701b526a7
shell/math: code shrink
...
function old new delta
evaluate_string 1498 1491 -7
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 19:20:10 +02:00
Denys Vlasenko
8309c9159f
shell/math: eliminate redundant endofname()
...
function old new delta
evaluate_string 1486 1498 +12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 19:03:05 +02:00
Denys Vlasenko
b61fd8ec5a
shell: typo fix in tests
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 18:49:00 +02:00
Denys Vlasenko
2d06c83b87
shell/math: code shrink
...
function old new delta
evaluate_string 1489 1486 -3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 18:31:55 +02:00
Denys Vlasenko
c72c5552ed
shell/math: decrease stack usage by not allocating copies of variable names
...
We risk exhaust stack with alloca() with old code.
function old new delta
arith_apply 990 1023 +33
evaluate_string 1467 1494 +27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 60/0) Total: 60 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 18:12:14 +02:00
Denys Vlasenko
182e5a4d00
shell/math: decrease stack usage
...
function old new delta
evaluate_string 1412 1467 +55
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-18 18:12:04 +02:00
Denys Vlasenko
96769486e2
shell: move varcmp() to shell_common.h and use it in hush
...
function old new delta
unset_local_var - 112 +112
findvar 31 35 +4
set_vars_and_save_old 144 141 -3
helper_export_local 235 230 -5
set_local_var 425 416 -9
handle_changed_special_names 38 27 -11
builtin_unset 154 141 -13
builtin_getopts 404 391 -13
get_local_var_value 281 260 -21
get_ptr_to_local_var 71 45 -26
unset_local_var_len 139 - -139
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/8 up/down: 116/-240) Total: -124 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 21:13:13 +02:00
Denys Vlasenko
d0441222db
ash: code shrink
...
function old new delta
setvar 166 164 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 20:45:02 +02:00
Denys Vlasenko
2ca9c45953
shell/read: do not allow empty variable name
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 19:52:20 +02:00
Denys Vlasenko
822590f5e2
shell/math: eliminate some redundant stores on return code path
...
function old new delta
evaluate_string 1432 1412 -20
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 19:21:28 +02:00
Denys Vlasenko
19a74a54de
shell/math: change ?: nesting code to not have 63 level nesting limitation
...
function old new delta
evaluate_string 1406 1432 +26
arith 36 29 -7
arith_apply 998 990 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 26/-15) Total: 11 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 11:03:02 +02:00
Denys Vlasenko
6221832bc1
shell/math.h: update comments, rearrange struct members for smaller code
...
function old new delta
arith_apply 1000 998 -2
evaluate_string 1414 1406 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-10) Total: -10 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 10:40:29 +02:00
Denys Vlasenko
d6f98f214b
shell/math: code shrink
...
function old new delta
evaluate_string 1432 1414 -18
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-17 00:28:49 +02:00
Denys Vlasenko
550696d492
shell/math: tweka comments
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-16 20:47:43 +02:00
Denys Vlasenko
e127985839
shell/math: fix ?: to not evaluate not-taken branches
...
This fixes ash-arith-arith-ternary1/2.tests
function old new delta
evaluate_string 1271 1432 +161
arith_apply 968 1000 +32
arith 22 36 +14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 207/0) Total: 207 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-16 19:51:01 +02:00
Denys Vlasenko
f8263528cd
shell/math: simplify handling of unary plus
...
function old new delta
evaluate_string 1257 1271 +14
arith_apply 977 968 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-9) Total: 5 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-15 17:16:46 +02:00
Denys Vlasenko
38f423cc9c
shell/math: explain the logic, small tweak to make code smaller
...
function old new delta
evaluate_string 1258 1257 -1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-15 16:46:31 +02:00
Denys Vlasenko
ea6dcbe283
shell/math: fix order of expansion of variables to numbers
...
This fixes arith-assign-in-varexp1.tests
function old new delta
evaluate_string 1132 1258 +126
arith_lookup_val 143 - -143
arith_apply 1132 977 -155
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 126/-298) Total: -172 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-15 13:56:12 +02:00
Denys Vlasenko
22cb0d573a
shell: document another arithmetic discrepancy with bash
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-15 12:44:43 +02:00
Denys Vlasenko
648f506949
libbb: code shrink: introduce and use [_]exit_FAILURE()
...
function old new delta
exit_FAILURE - 7 +7
_exit_FAILURE - 7 +7
run 198 199 +1
restore_state_and_exit 114 115 +1
xbsd_write_bootstrap 399 397 -2
vfork_compressor 209 207 -2
sig_handler 12 10 -2
serial_ctl 154 152 -2
parse_args 1169 1167 -2
onintr 21 19 -2
make_new_session 493 491 -2
login_main 988 986 -2
gotsig 35 33 -2
do_iplink 1315 1313 -2
addgroup_main 397 395 -2
inetd_main 1911 1908 -3
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/12 up/down: 16/-25) Total: -9 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-15 11:55:56 +02:00
Denys Vlasenko
61a4959251
shell/math: remove special code to handle a?b?c:d:e, it works without it now
...
The "hack" to virtually parenthesize ? EXPR : made this unnecessary.
The expression is effectively a?(b?(c):d):e and thus b?c:d is evaluated
before continuing with the second :
function old new delta
evaluate_string 1148 1132 -16
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-15 11:22:13 +02:00
Denys Vlasenko
5f56a03882
shell/math: fix parsing of ?: and explain why it's parsed that way
...
This fixes arith-precedence1.tests.
This breaks arith-ternary2.tests again (we now evaluate variables
on not-taken branches). We need a better logic here anyway:
not only bare variables should not evaluate when not-taken:
1 ? eval_me : do_not_eval
but any (arbitrarily complex) expressions shouldn't
evaluate as well!
1 ? var_is_set=1 : ((var_is_not_set=2,var2*=4))
function old new delta
evaluate_string 1097 1148 +51
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-15 10:14:43 +02:00
Denys Vlasenko
3829d8b675
shell/math: simpler insertion of "fake" last RPAREN
...
Skip one pass through token table, since we know the result.
function old new delta
evaluate_string 1095 1097 +2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-15 09:19:48 +02:00
Denys Vlasenko
2ff01bb699
shell: sync ash/hush test scripts
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-14 15:19:02 +02:00
Denys Vlasenko
66139330fc
shell/math: trivial code shrink
...
function old new delta
arith_apply 1143 1132 -11
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-14 13:59:11 +02:00
Denys Vlasenko
3df885abe3
shell/math: fix the order of variable resolution in binops
...
function old new delta
arith_apply 1134 1143 +9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-14 11:33:59 +02:00
Denys Vlasenko
5febdb1223
shell/math: remove now-unused second_val
...
function old new delta
arith_apply 1137 1134 -3
evaluate_string 1101 1095 -6
arith_lookup_val 150 143 -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-16) Total: -16 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-14 11:10:45 +02:00
Denys Vlasenko
46dccd2ec0
shell/math: fix nested ?: and do not parse variables in not-taken branch
...
Fixes arith-ternary1.tests and arith-ternary_nested.tests
function old new delta
evaluate_string 1043 1101 +58
arith_apply 1087 1137 +50
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 108/0) Total: 108 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-14 11:07:30 +02:00
Denys Vlasenko
a02450ff0b
shell/math: remove a redundant check
...
function old new delta
arith_apply 1134 1087 -47
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-14 01:05:40 +02:00
Denys Vlasenko
8acbf31708
shell/math: document ternary ?: op's weirdness, add code comments
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-14 00:41:18 +02:00
Denys Vlasenko
373f64eef3
syslogd: daemonize _after_ init (so that init errors are visible, if they occur)
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-13 16:25:13 +02:00
Denys Vlasenko
02378ce20c
syslogd: decrease stack usage, ~50 bytes
...
function old new delta
syslogd_init - 1007 +1007
syslogd_main 1619 636 -983
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 1007/-983) Total: 24 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-13 16:24:56 +02:00
Denys Vlasenko
c1d7507a4d
shell/math: fix one name check, other minor cleanups
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-13 16:15:18 +02:00
Denys Vlasenko
8ccb3f7b13
shell: add a few yet-failing arithmentic tests
...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-13 15:21:22 +02:00
Denys Vlasenko
a4f30f3c70
shell/math: reduce stack usage
...
function old new delta
arith_apply 1123 1134 +11
arith_lookup_val 140 145 +5
evaluate_string 1053 1047 -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 16/-6) Total: 10 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-06-13 13:55:13 +02:00