summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* | busybox: bring help handling into line with upstreamRon Yorston2021-08-161-5/+5
| | | | | | | | | | Upstream has fixed a problem with 'busybox --help' so it's possible to remove another gratuitous divergence.
* | win32: code shrink uname(2)Ron Yorston2021-08-161-8/+4
| | | | | | | | | | | | | | If GetVersionEx() fails just assume the OS version numbers remain set to zero and print them as-is. Saves 48 bytes.
* | printf: improved error handlingRon Yorston2021-08-151-19/+23
| | | | | | | | | | | | | | | | | | | | | | | | The printf applet is NOFORK and is used to implement the printf command in ash. It should therefore be careful about handling memory allocation failures. If vasprintf() or realloc() fail the applet now carries on as best it can. This may result in some lost output but at least the shell will survive. Saves 32 bytes.
* | win32: implement utimes(2) using utimensat(2)Ron Yorston2021-08-151-38/+18
| | | | | | | | Saves 176 bytes.
* | win32: tidy up fetching of system directoryRon Yorston2021-08-141-14/+17
| | | | | | | | | | | | | | | | | | | | | | | | Add a new function, getsysdir(), to fetch and cache the system directory. This avoids the non-intuitive use of getpwuid() in get_system_drive(). The call to GetSystemDirectory() in get_proc_addr() can't be replaced because getsysdir() calls realpath() which requires a call to get_proc_addr(). No change in the size of the binary.
* | win32: code shrinkRon Yorston2021-08-141-14/+14
| | | | | | | | | | | | | | | | | | There doesn't seem to be any need to call OpenThreadToken() in file_owner(): OpenProcessToken() should suffice. Also, tidy up gethomedir() without any change in functionality. Saves 56 bytes.
* | win32: treat devices as character special filesRon Yorston2021-08-131-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit 15fcbd19c (win32: special case for devices files in stat(2)) added special treatment in stat(2) for device files. As a result of this change device files appeared to be regular files which broke the use of /dev/null with noclobber in the shell. Device files now appear as character special files (as they do on Unix). GitHub issue #225.
* | find_mount_point: code shrinkRon Yorston2021-08-121-8/+2
| | | | | | | | | | | | | | Use xrealloc_getcwd_or_warn() instead of a hand-rolled WIN32 equivalent. Saves 84 bytes.
* | win32: better handling of nested symlinksRon Yorston2021-08-123-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Our realpath(3) implementation uses xmalloc_follow_symlinks() to expand symlinks. This detects when symlinks are too deeply nested but didn't set errno, so anything calling realpath(3) was unable to say what had gone wrong. (For example, 'ls -L' or 'stat -L'.) Set errno to ELOOP. This then leads to the problem that Windows doesn't know about ELOOP so reports 'Unknown error'. Add a replacement for strerror(3) which returns a sensible message. Costs 96 bytes.
* | timeout: make child handle staticRon Yorston2021-08-111-1/+1
| |
* | nproc: code shrinkRon Yorston2021-08-101-24/+12
| | | | | | | | | | | | | | | | Avoid duplication of call to getopt(). Simplify WIN32 code. Saves 80 bytes.
* | win32: code shrink character class detectionRon Yorston2021-08-095-18/+83
| | | | | | | | | | | | | | Add a routine to detect the names of character classes. Use it in fnmatch(3) and regcomp(3), replacing local code in the former. Saves 216 bytes.
* | win32: fix fnmatch(3) handling of xdigitRon Yorston2021-08-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The glob pattern '[[:xdigit::]]*' didn't return the matches expected. It turns out the implementation (from glibc) fails to detect 'xdigit' as a valid character class. Changing the definition of CHAR_CLASS_MAX_LENGTH to 7 fixes the problem. This was never an issue in glibc because it uses a different definition. More modern versions of fnmatch(3) in glibc and gnulib also make CHAR_CLASS_MAX_LENGTH long enough. The code for fnmatch(3) was taken from glibc at commit 7814856974388a856a575fa45f88d502c8a1ab29. This was the last version before the code was rearraged to better support multibyte characters.
* | win32: tidy up time conversionsRon Yorston2021-08-091-7/+3
| | | | | | | | | | | | | | Remove filetime_to_time_t(): it's no longer used. Align style of time{spec,val}_to_filetime() to make it easier to compare what they do.
* | win32: code shrinkRon Yorston2021-08-083-12/+11
| | | | | | | | | | | | | | | | | | Save a few bytes: - When collecting entropy prefer functions we call elsewhere. - In uname(2) set 32-bit processor type to i686 and tweak it for i386.
* | win32: improved keycode detectionRon Yorston2021-08-061-42/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In read_keys(): - Identify all keys on the numeric pad used to enter character codes. Otherwise Alt-Left/Alt-Right on the numeric pad are treated as word movements in command line editing, preventing the entry of character codes containing 4 or 6. - Add modifier flag bits to the virtual keycodes we care about. This means, for example, that only the unmodified Up/Down arrow keys move through shell history, not Up/Down plus arbitrary modifiers.
* | win32: code shrink read_key()Ron Yorston2021-08-061-11/+5
| | | | | | | | No change in functionality. Saves 16 bytes.
* | split: improve performanceRon Yorston2021-08-051-1/+7
| | | | | | | | | | | | | | | | The default buffer size doesn't seem to work very well on Windows. Increasing the buffer to 16K speeds up the splitting of a 1GB file into 100MB chunks by a factor of two. GitHub issue #224.
* | win32: better detection of Alt key releaseRon Yorston2021-08-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 7874ca73b (win32: allow characters to be entered as ALTNNN) made it possible to enter characters using Alt and a character code on the numeric pad. This required detecting the release of the Alt key. Sometimes this caused a problem when using Alt+Tab to cycle between applications. If Alt was released before Tab the code passed a tab character to the application. Avoid such issues by looking specifically for the release of the Alt key.
* | ash: reset ANSI emulation at promptRon Yorston2021-08-011-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | It appears that MSYS2/Cygwin applications turn off virtual terminal processing. This caused literal ANSI escape sequences to be echoed in the shell, which assumed the console state it had applied would remain unchanged. Add a call to skip_ansi_emulation(TRUE) before issuing a shell prompt to ensure that the state is correct. GitHub issue #223.
* | win32: code shrink using is_prefixed_with()Ron Yorston2021-07-283-20/+27
| | | | | | | | | | | | | | Use is_prefixed_with() rather than strncmp() in a few places, and the case-insensitive analogues. Saves 96 bytes in 64-bit build, 192 bytes in 32-bit.
* | win32: code shrink has_exec_format()Ron Yorston2021-07-281-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the code to detect binaries: - use '|' rather than '+' to combine bytes; - fix the test that the PE header is within the buffer; - once we have the offset to the PE header make a pointer to it; - cosmetic changes. Saves 96 bytes.
* | win32: more efficient tests for executablesRon Yorston2021-07-262-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | file_is_executable() calls access(2) and stat(2); in this case our WIN32 implementation also calls stat(2). Avoid this unnecessary duplication by copying the required test from the WIN32 access(2). In find_executable() it's possible to avoid calling file_is_executable() if add_win32_extension() returns TRUE as the latter will already have verified that the file is executable. Replace a call to file_is_executable() in the tab completion code with the equivalent tests, avoiding (up to) two calls to stat(2). These changes don't affect the size of the binary and should be faster.
* | Update READMEFRP-4264-gc79f13025Ron Yorston2021-07-251-2/+4
| |
* | win32: special case for devices files in stat(2)Ron Yorston2021-07-251-5/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The diff applet calls stat(2) on the files it's asked to process. This includes /dev/null when the -N flag is used and /dev/fd/* files when process substitution is used. Treat device files as a special case in get_file_attr(), returning a fake set of attributes with FILE_ATTRIBUTE_DEVICE set. This value is unused elsewhere in busybox-w32. Ensure it's unset in other cases. When FILE_ATTRIBUTE_DEVICE is set: - adjust some permissions; - avoid calling has_exec_format() as this opens/closes the file which breaks process substitution. These changes improve the behaviour of diff but they also have other effects. For example, the stat and ls applets now report details of device files. There may be unintended consequences.
* | Update default configurationRon Yorston2021-07-242-4/+4
| | | | | | | | | | Disable ASH_OPTIMIZE_FOR_SIZE to pick up the ${v//pattern/repl} speed up.
* | Merge branch 'busybox' into mergeRon Yorston2021-07-243-100/+201
|\|
| * ash: speed up ${v//pattern/repl} if !ASH_OPTIMIZE_FOR_SIZEDenys Vlasenko2021-07-221-3/+27
| | | | | | | | | | | | | | | | | | | | function old new delta subevalvar 1353 1447 +94 .rodata 104179 104184 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 99/0) Total: 99 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cut: add toybox-compatible options -O OUTSEP, -D, -F LISTRob Landley2021-07-202-97/+174
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta cut_main 884 1201 +317 packed_usage 33823 33885 +62 .rodata 104186 104179 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 379/-7) Total: 372 bytes Signed-off-by: Rob Landley <rob@landley.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | tar: use external program for lzma/xz compressionRon Yorston2021-07-221-3/+9
| | | | | | | | | | | | | | | | | | The lzma and xz applets don't support compression. Any attempt to generate a tar file using these compressors should try to use an external program. (Which probably won't work on a typical Windows system, but hey, at least we made the effort.) See GitHub issue #222.
* | mingw: update select(2) to latest gnulib versionRon Yorston2021-07-171-18/+36
| |
* | Update default configurationRon Yorston2021-07-172-4/+4
| |
* | Merge branch 'busybox' into mergeRon Yorston2021-07-174-186/+358
|\|
| * awk: whitespace and debugging tweaksDenys Vlasenko2021-07-141-67/+66
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: remove redundant assignmentDenys Vlasenko2021-07-141-1/+0
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: disallow break/continue outside of loopsDenys Vlasenko2021-07-142-9/+6
| | | | | | | | | | | | | | | | | | | | function old new delta .rodata 104139 104186 +47 chain_group 610 633 +23 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 70/0) Total: 70 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: tighten parsing - disallow extra semicolonsDenys Vlasenko2021-07-141-16/+24
| | | | | | | | | | | | | | | | | | '; BEGIN {...}' and 'BEGIN {...} ;; {...}' are not accepted by gawk function old new delta parse_program 332 353 +21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: fix regex search compilation errorRon Yorston2021-07-131-1/+1
| | | | | | | | | | | | | | Building with FEATURE_VI_REGEX_SEARCH enabled fails. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
| * vi: somewhat more readable code, no logic changesDenys Vlasenko2021-07-131-8/+9
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: allow delimiter in ':s' to be escapedRon Yorston2021-07-131-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When regular expressions are allowed in search commands it becomes possible to escape the delimiter in search/replace commands. For example, this command will replace '/abc' with '/abc/': :s/\/abc/\/abc\//g The code to split the command into 'find' and 'replace' strings should allow for this possibility. VI_REGEX_SEARCH isn't enabled by default. When it is: function old new delta strchr_backslash - 38 +38 colon 4378 4373 -5 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 38/-5) Total: 33 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: allow regular expressions in ':s' commandsDenys Vlasenko2021-07-131-15/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BusyBox vi has never supported the use of regular expressions in search/replace (':s') commands. Implement this using GNU regex when VI_REGEX_SEARCH is enabled. The implementation: - uses basic regular expressions, to match those used in the search command; - only supports substitution of back references ('\0' - '\9') in the replacement string. Any other character following a backslash is treated as that literal character. VI_REGEX_SEARCH isn't enabled in the default build. In that case: function old new delta colon 4036 4033 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3) Total: -3 bytes When VI_REGEX_SEARCH is enabled: function old new delta colon 4036 4378 +342 .rodata 108207 108229 +22 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 364/0) Total: 364 bytes v2: Rebase. Code shrink. Ensure empty replacement string is null terminated. Signed-off-by: Andrey Dobrovolsky <andrey.dobrovolsky.odessa@gmail.com> Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: improve handling of anchored searchesRon Yorston2021-07-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Suppose we search for a git conflict marker '<<<<<<< HEAD' using the command '/^<<<'. Using 'n' to go to the next match finds '<<<' on the current line, apparently ignoring the '^' anchor. Set a flag in the compiled regular expression to indicate that the start of the string should not be considered a beginning-of-line anchor. An exception has to be made when the search starts from the beginning of the file. Make a similar change for end-of-line anchors. This doesn't affect a default build with VI_REGEX_SEARCH disabled. When it's enabled: function old new delta char_search 247 285 +38 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: use basic regular expressions for searchRon Yorston2021-07-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both traditional vi and vim use basic regular expressions for search. Also, they don't allow matches to extend across line endings. Thus with the file: 123 234 the search '/2.*4$' should find the second '2', not the first. Make BusyBox vi do the same. Whether or not VI_REGEX_SEARCH is enabled: function old new delta ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes Signed-off-by: Andrey Dobrovolsky <andrey.dobrovolsky.odessa@gmail.com> Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * vi: allow 'gg' to specify a rangeRon Yorston2021-07-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 7b93e317c (vi: enable 'dG' command. Closes 11801) allowed 'G' to be used as a range specifier for change/yank/delete operations. Add similar support for 'gg'. This requires setting the 'cmd_error' flag if 'g' is followed by any character other than another 'g'. function old new delta do_cmd 4852 4860 +8 .rodata 108179 108180 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 9/0) Total: 9 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: in parsing, remove superfluous NEWLINE check; optimize builtin arg ↵Denys Vlasenko2021-07-121-5/+6
| | | | | | | | | | | | | | | | | | evaluation function old new delta exec_builtin 1149 1145 -4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix printf "%-10c", 0Denys Vlasenko2021-07-122-4/+13
| | | | | | | | | | | | | | function old new delta awk_printf 596 626 +30 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix corner case in awk_printfDenys Vlasenko2021-07-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | Example where it wasn't working: awk 'BEGIN { printf "qwe %s rty %c uio\n", "a", 0, "c" }' - the NUL printing in %c caused premature stop of printing. function old new delta awk_printf 593 596 +3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tc: fix for parsing of "dev IFACE" and printing of "class list"Denys Vlasenko2021-07-111-20/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | First part (parsing fix) is from Steffen Nurpmeso <steffen@sdaoden.eu> function old new delta .rodata 104120 104138 +18 print_qdisc 469 464 -5 tc_main 980 969 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 18/-16) Total: 2 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: unbreak "cmd" | getlineDenys Vlasenko2021-07-112-1/+7
| | | | | | | | | | | | | | function old new delta evaluate 3337 3343 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: unbreak "printf('%c') can output NUL" testcaseDenys Vlasenko2021-07-111-17/+26
| | | | | | | | | | | | | | function old new delta awk_printf 546 593 +47 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>