aboutsummaryrefslogtreecommitdiff
path: root/testsuite
AgeCommit message (Collapse)Author
2020-04-30grep: add proper support for pattern_listSören Tempel
From POSIX.1-2008: The pattern_list's value shall consist of one or more patterns separated by <newline> characters; As such, given patterns need to be split at newline characters. Without doing so, busybox grep will interpret the newline as part of the pattern which is not in accordance with POSIX. See also: https://bugs.busybox.net/show_bug.cgi?id=12721 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-04-29grep: Fix -f FILE when FILE is empty and -x providedGray Wolf
Grep currently special-cased empty pattern file to be the same as pattern file with one empty line (empty pattern). That does mirror how GNU grep behaves, except when -x is provided. In that case .* pattern needs to be used instead. Signed-off-by: Gray Wolf <wolf@wolfsden.cz> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-04-29xargs: restore correct behaviour of -n optionRon Yorston
Since commit 1ff7002b1 (xargs: fix handling of quoted arguments, closes 11441) the -n option hasn't worked properly: $ echo 1 2 3 | xargs -n 1 echo 1 2 3 $ Because state is now remembered between calls to process_stdin() it's necessary to update the state before any premature return. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-02-02awk: fix more "length" cases, closes 12486Denys Vlasenko
function old new delta next_token 808 831 +23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-01-29xargs: fix handling of quoted arguments, closes 11441Ron Yorston
As reported in bug 11441 when presented with a large number of quoted arguments xargs can return 'argument line too long': seq 10000 29999 | sed -e 's/^/"/' -e 's/$/"/' | busybox xargs echo This happens because the variant of process_stdin() which handles quoted arguments doesn't preserve state between calls. If the allowed number of characters is exceeded part way through a quoted argument the next call to process_stdin() incorrectly treats the terminating quote as a starting quote, thus quoting all of the argument separators. function old new delta process_stdin 274 303 +29 xargs_main 731 745 +14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 43/0) Total: 43 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-11-23bc: fix comparison bug, closes 12336Denys Vlasenko
function old new delta bc_num_cmp 249 259 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-09-05dc: Parse error & fix out of bounds read in xc_program_printStringBrian Foley
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>
2019-09-05dc: Fix segfault when executing strings generated using asciifyBrian Foley
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>
2019-09-05dc: execute shouldn't pop if stack head is not a stringBrian Foley
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>
2019-06-08expand,unexpand: drop broken test, add FIXME commentDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-08awk: fix testsuiteDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-26testsuite: fix bunzip2.tests expectationsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-05-13sed: fix /regex/,+N match triggering only once, closes 11871Denys Vlasenko
function old new delta process_files 2235 2246 +11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-04-19dc.tests: fix two test case to also depend on DC_BIGChen Qi
Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-29grep: fix -x -v with certain pattern ordersAri Sundholm
We found out that busybox -x -v is a bit broken: ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -e 'aa.*' -e '.*bb.*' aa bb cc ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -v -e 'aa.*' -e '.*bb.*' ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -e '.*aa.*' -e 'bb.*' aa bb cc ari@ari-thinkpad:~/busybox$ echo ' aa bb cc' | ./busybox grep -x -v -e '.*aa.*' -e 'bb.*' aa bb cc Last one is wrong. This patch fixes the issue by making sure that the variable 'found' never makes a transition from 1 to 0, as this would mean that grep previously found a match on this input line. Signed-off-by: Ari Sundholm <ari@tuxera.com> Signed-off-by: Niko Vähäsarja <niko@tuxera.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-25bc: implement pass-by-reference code from upstreamDenys Vlasenko
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>
2019-01-21awk: Fix overly permissive func arg list parsingBrian Foley
It allows things like 'func f(a b)' and 'func f(a,)' which GNU awk forbids. function old new delta parse_program 327 367 +40 chain_expr 40 67 +27 parse_expr 891 915 +24 EMSG_TOO_FEW_ARGS 30 18 -12 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 91/-12) Total: 79 bytes Signed-off-by: Brian Foley <bpfoley@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-21awk: Syntax error if delete isn't given an arg.Brian Foley
Unlike exit and return, delete strictly requires an arg, and derefs a null pointer if executed without one. Signed-off-by: Brian Foley <bpfoley@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-21awk: Guard pointer chasing when parsing ternary expressions.Brian Foley
Avoids an uninit pointer deref for some malformed ternary exprs. Add a test that would crash in busybox before this fix. Signed-off-by: Brian Foley <bpfoley@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-14start-stop-daemon: fix "both -x and -a" case: -a does override argv[0]Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-14start-stop-daemon: create pidfile before parent exits, closes 8596Denys Vlasenko
This removes DAEMON_DOUBLE_FORK flag from bb_daemonize_or_rexec(), as SSD was the only user. Also includes fix for -S: now works without -a and -x, does not print pids (compat with "start-stop-daemon (OpenRC) 0.34.11 (Gentoo Linux)"). function old new delta start_stop_daemon_main 1018 1084 +66 add_interface 99 103 +4 fail_hunk 139 136 -3 bb_daemonize_or_rexec 205 183 -22 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 70/-25) Total: 45 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-04bc: support void functions (GNU compat)Denys Vlasenko
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>
2019-01-04dc: fit returning of stringDenys Vlasenko
function old new delta zxc_program_exec 4087 4098 +11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-04dc: fix '?'Denys Vlasenko
function old new delta zdc_parse_expr 470 479 +9 zxc_vm_process 839 814 -25 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 9/-25) Total: -16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-03bc: fix "...; return}" to work, disallow "return ()"Denys Vlasenko
function old new delta zbc_parse_expr 24 1865 +1841 zbc_parse_stmt_possibly_auto 1425 1413 -12 bc_parse_expr_empty_ok 1843 - -1843 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/1 up/down: 1841/-1855) Total: -14 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-02bc: generate large bc tests on the fly, -5 mbytes in the git treeDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-02bc: speed up string printing, fix print ""Denys Vlasenko
function old new delta static.esc - 9 +9 zxc_program_print 681 683 +2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 11/0) Total: 11 bytes text data bss dec hex filename 979144 485 7296 986925 f0f2d busybox_old 979062 485 7296 986843 f0edb busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-01bc: upstream fixesDenys Vlasenko
function old new delta bc_parse_expr_empty_ok 1764 1843 +79 bc_error_at - 62 +62 bc_parse_inst_isLeaf - 30 +30 zbc_func_insert 100 120 +20 bc_error_bad_function_definition - 10 +10 bc_error_bad_assignment - 10 +10 zxc_lex_next 1608 1614 +6 ok_in_expr 30 - -30 zxc_vm_process 874 839 -35 ------------------------------------------------------------------------------ (add/remove: 4/1 grow/shrink: 3/1 up/down: 217/-65) Total: 152 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-31bc: support ibase up to 36 (GNU compat)Denys Vlasenko
function old new delta zxc_program_num 995 1018 +23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-29bc: more fixes for unusual input basesDenys Vlasenko
function old new delta zxc_program_num 990 1020 +30 zxc_lex_number 172 202 +30 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 60/0) Total: 60 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-29bc: fix handling of "digits" above 9Denys Vlasenko
function old new delta zxc_lex_next 1573 1608 +35 xc_parse_pushIndex 58 56 -2 xc_program_index 71 63 -8 zxc_program_num 1022 990 -32 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 35/-42) Total: -7 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28bc: rename config optionsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-26bc: prepare for char-by-char input handlingDenys Vlasenko
function old new delta peek_inbuf - 292 +292 parse_lex_by_checking_eq_sign - 26 +26 eat_inbuf - 22 +22 zbc_vm_execute_FILE 52 61 +9 bc_lex_lineComment 29 30 +1 zbc_lex_number 174 172 -2 bc_vm_run 104 99 -5 zbc_num_divmod 156 150 -6 bc_lex_file 24 - -24 bc_lex_assign 26 - -26 zbc_lex_next 1982 1587 -395 ------------------------------------------------------------------------------ (add/remove: 3/2 grow/shrink: 2/4 up/down: 350/-458) Total: -108 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-25bc: fix interactive handling of comments in strings and quotes in commentsDenys Vlasenko
function old new delta zbc_lex_next 1965 1979 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-25dc: add two testsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-25bc: allow {break} and {continue} (allow RBRACE to terminate them)Denys Vlasenko
function old new delta zbc_parse_stmt_possibly_auto 1599 1560 -39 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-22dc: unbreak interactive mode - was trying to get next tokens instead of ↵Denys Vlasenko
executing function old new delta zbc_program_read - 268 +268 zdc_program_printStream - 146 +146 zbc_program_exec 4046 4182 +136 zdc_program_execStr 472 512 +40 zdc_parse_exprs_until_eof - 26 +26 zbc_vm_process 740 765 +25 zbc_lex_next 2225 2240 +15 zdc_parse_expr 569 535 -34 zbc_program_pushArray 147 - -147 zdc_program_asciify 370 - -370 ------------------------------------------------------------------------------ (add/remove: 3/2 grow/shrink: 4/1 up/down: 656/-551) Total: 105 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-22bc: unbreak read(), remove checks for nested read()Denys Vlasenko
function old new delta zbc_parse_pushSTR - 65 +65 common_parse_expr - 32 +32 bc_error_nested_read_call 10 - -10 bc_parse_expr_empty_ok 1977 1963 -14 zdc_parse_expr 635 615 -20 zcommon_parse_expr 32 - -32 zbc_program_exec 4064 4023 -41 bc_parse_pushSTR 65 - -65 ------------------------------------------------------------------------------ (add/remove: 2/3 grow/shrink: 0/3 up/down: 97/-182) Total: -85 bytes text data bss dec hex filename 981661 485 7296 989442 f1902 busybox_old 981540 485 7296 989321 f1889 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-21bc: fix for() to not leave data on stackDenys Vlasenko
function old new delta zbc_parse_stmt_possibly_auto 1665 1697 +32 zbc_vm_process 672 701 +29 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 61/0) Total: 61 bytes text data bss dec hex filename 981656 485 7296 989437 f18fd busybox_old 981748 485 7296 989529 f1959 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-21bc: for(;;) fix from upstreamDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-20bc: fix keyword matching to not think "ifz" is the "if" keywordDenys Vlasenko
function old new delta zbc_lex_next 2224 2225 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-18bc: fix "echo -n '#foo' | bc" not eating last 'o'Denys Vlasenko
function old new delta zdc_parse_expr 656 653 -3 bc_lex_lineComment 39 36 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6) Total: -6 bytes text data bss dec hex filename 981424 485 7296 989205 f1815 busybox_old 981418 485 7296 989199 f180f busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-17bc: remove "error after expression parsing" checkDenys Vlasenko
It is misplaced: caller knows better what can or cannot follow the expression. Sometimes even caller's caller: "if (1) return a+b else..." - parser of "return" does not know that "else" after it is valid, parser of stmt does not know it either, - only parser of "if" knows it! The removed code balked on e.g. "{ print 1 }" statement. This does not break any valid programs, but starts accepting some invalid ones, e.g. "print 1 print 2" would work. function old new delta zcommon_parse_expr 40 32 -8 zbc_parse_name 509 494 -15 zbc_parse_stmt_possibly_auto 1678 1638 -40 bc_parse_expr_empty_ok 2025 1977 -48 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-111) Total: -111 bytes text data bss dec hex filename 981599 485 7296 989380 f18c4 busybox_old 981488 485 7296 989269 f1855 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-16bc: store only index in p->exits, it's the only thing used thereDenys Vlasenko
function old new delta zbc_parse_stmt_possibly_auto 1967 1964 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3) Total: -3 bytes text data bss dec hex filename 981937 485 7296 989718 f1a16 busybox_old 981934 485 7296 989715 f1a13 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-16bc: remove redundant JUMP generation when parsing 'while'Denys Vlasenko
function old new delta zbc_parse_stmt_possibly_auto 2065 2025 -40 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-40) Total: -40 bytes text data bss dec hex filename 982035 485 7296 989816 f1a78 busybox_old 981995 485 7296 989776 f1a50 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-16bc: simplify use of "ip" in loop parsing functionsDenys Vlasenko
function old new delta zbc_parse_stmt_possibly_auto 2106 2065 -41 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-41) Total: -41 bytes text data bss dec hex filename 982076 485 7296 989857 f1aa1 busybox_old 982035 485 7296 989816 f1a78 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-16bc: fix "print 1,2,3" parsingDenys Vlasenko
function old new delta zbc_parse_stmt_possibly_auto 2245 2180 -65 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-65) Total: -65 bytes text data bss dec hex filename 982237 485 7296 990018 f1b42 busybox_old 982152 485 7296 989933 f1aed busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-16bc: fold zbc_parse_else() into its only callerDenys Vlasenko
While at it, allow newline between "else" and its body Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-16bc: fixes for multi-line if/while/forDenys Vlasenko
function old new delta zbc_vm_process 561 589 +28 zbc_lex_next_and_skip_NLINE - 22 +22 zbc_parse_stmt_possibly_auto 2232 2253 +21 zbc_lex_skip_if_at_NLINE - 14 +14 zbc_lex_number 192 200 +8 zbc_num_divmod 150 156 +6 bc_vm_run 134 139 +5 bc_vm_init 757 760 +3 bc_num_printNewline 51 54 +3 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 7/0 up/down: 110/0) Total: 110 bytes text data bss dec hex filename 982138 485 7296 989919 f1adf busybox_old 982275 485 7296 990056 f1b68 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-16bc: fix handling of 'return' not in functions, and 'define f()<newline>{...}'Denys Vlasenko
function old new delta zbc_vm_process 561 597 +36 zbc_parse_stmt_possibly_auto 2232 2253 +21 zbc_lex_number 192 200 +8 zbc_num_divmod 150 156 +6 bc_vm_run 134 139 +5 bc_vm_init 757 760 +3 bc_num_printNewline 51 54 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 7/0 up/down: 82/0) Total: 82 bytes text data bss dec hex filename 982138 485 7296 989919 f1adf busybox_old 982247 485 7296 990028 f1b4c busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>