aboutsummaryrefslogtreecommitdiff
path: root/editors/awk.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-03-29Revert "unicode: identify emoji width and modifiers"Avi Halachmi (:avih)1-8/+0
This reverts commit 878b3cd27fe83f2b0ff476b884c34d165be0072c. It's no longer required, since the last commit uses a new wcwidth implementation which covers the cases added by commit 878b3cd2 .
2024-03-29win32: unicode: use newer wcwidth by defaultAvi Halachmi (:avih)4-0/+683
This commit adds a new wcwidth implementation at libbb/wcwidth_alt.c, and uses it instead of the existing implementation when compiling for windows and CONFIG_LAST_SUPPORTED_WCHAR >= 0x30000 - which is the case with the unicode configs/mingw64u_defconfig. The windows-target condition keeps non-windows build unmodified, and the last supported wchar threshold is a semi-hack to allow switching between implementations without adding a new config option (the old code supports codepoints up to 0x2ffff). The new file wcwidth_alt.c was generated by a new scripts/mkwcwidth, which prints a wcwidth implementation using latest unicode data from a local clone of https://github.com/jquast/wcwidth . This repo is the main python wcwidth implementation, and is maintained and up to date. Functional differences from the existing implementation: - Unicode 15.1.0 (latest) with the new version (about 450 ranges of wide and zero-width codepoints), compared to roughly Unicode 5.0 of the existing code (nearly 20 years old spec, about 150 ranges). The new spec includes, among others, various wide icons and emojis, which can now be edited correctly at the shell prompt, have correct alignment in 'ls', etc. - The old implementation returns -1 (non-printable) for surrogates, while the new code returns 1, though this is inconsequential, and POSIX doesn't care. Also libc implementations vary in this regard. Technical differences: - The old version compiles less code/data when the last supported wchar is smaller, while the new version doesn't. This doesn't matter because the new version is enabled only for the full range. - The new version is smaller and relatively straight forward, and fully automated (generated), so updates to newer spec is trivial. The old version mixes data, ad-hoc code (tailored to the data), and preprocessor checks, and is hard to automate updates. The old version has various forms of 32 and 16 bit data ranges, in several arrays, while the new version uses single data array with unified form of 32 bits per range, with two rules: - A data range can't span Unicode planes (enforced, but unlikely required, and if yes, code to split ranges would be simple). - A range can't hold more than 32768 codepoints, so bigger ranges are split automatically (currently there are 2 such ranges). Performance wise, the new version should be faster, even with three times the data ranges. Both versions do effectively at most one binary search in one Unicode plane data, but the new version finds both zero-width and wide-width results in this one search, while the old version only finds zero-width, and to detect wide-width it does an additional linear series of manual range tests, but since most results are width 1, this sequence is performed in most (non-ASCII) calls. In a cursory comparison of the new wcwidth with glibc and musl-libc (both use O(1) lookup tables), with few bodies of text, we're in the same ballpark, with typical speed of 60% or better. Bloat-wise, the new version is about 180 bytes code and 1800 bytes data. If it had similar number of data ranges as the old code (150), the new version would be about 200 bytes smaller, but because the new version has 450 data ranges, it's about 1K bigger.
2024-03-26ash: strip path from NOFORK applet namesRon Yorston1-0/+3
Commit 26ba73098 (win32: search PATH for missing Unix-style executables) extended the cases in which PATH would be searched for executables specified with a Unix-style path. A side effect of this change was to pass the Unix-style path as argv[0] to NOFORK applets. The 'uname' applet examines argv[0] to determine how to behave. When invoked as '/bin/uname' it returned unexpected results. Other applets may be similarly affected. When a NOFORK applet is invoked in evalcommand(), strip any path. Costs 16 bytes. (GitHub issue #392)
2024-03-11make: allow '#' to be escaped with a backslashRon Yorston2-3/+20
POSIX doesn't allow the '#' comment marker to be escaped, though some implementations do. As a non-POSIX extension allow '#' to be escaped with a preceding backslash. It isn't necessary to escape '#' in macro expansions or command lines: these cases are covered by an existing extension. Commit 0aceca867 (make: comments in macro expansions and command lines) Adds 16-32 bytes. (pdpmake GitHub issue 38)
2024-03-09win32: improvements to realpath(3)Ron Yorston1-2/+6
The previous commit unnecessarily duplicated the path returned from resolve_symlinks(), resulting in a memory leak. Thanks to avih for spotting this. Even if we can't canonicalise the path in resolve_symlinks() we can at least return the result of resolving the trailing symlink. Moreover, this can be done both when the necessary API is missing and when the filesystem doesn't support it. Not perfect, but better than nothing, and there's no cost. This change gets rid of a handful of realpath-related test failures on ReactOS and Windows XP. Some background: Commit 8ebe81483 returned the raw path when the required API was missing. This was reverted in commit f902184fa because it caused an infinite loop (GitHub issue #204). Commit 31467ddfc fixed the cause of the loop, which is why it's now safe to reintroduce a fallback return. (GitHub commit #389)
2024-03-08win32: let realpath(3) work on flaky filesystemsRon Yorston1-0/+3
Some filesystems don't support the feature required to resolve symlinks for realpath(3). In such cases just carry on without resolving symlinks. This is a trade-off between correctness and convenience. Adds 16 bytes. (GitHub issue #389)
2024-03-08su: free all allocated memoryRon Yorston1-14/+18
Ensure memory is freed even on early exit. Saves 0-16 bytes.
2024-03-07su: handle restricted disk driversRon Yorston1-6/+18
Certain tools which allow disk image files and RAM disks to be mounted were found to lack a feature used to implement realpath(3). This resulted in a segfault in the 'su' applet when it was run in such a virtual filesystem. 'su' uses realpath(3) to canonicalise the current directory. This is only really required to handle network shares mapped to a drive letter. (GitHub issue #148) - If the call to realpath(3) fails for some reason fall back to using the current directory determined by calling getcwd(3). - If getcwd(3) fails simply don't pass any directory to the shell being started by 'su'. Also, ensure all allocated memory is freed, if required. (GitHub issue #389) Adds 16-32 bytes.
2024-03-06ash: fix 'read' built-in performance regressionRon Yorston1-0/+4
Commits 8e6991733 and b2901ce8e fixed problems with the 'read' shell built-in when the '-t' option was used. However, they result in a performance penalty. This pipeline: seq -w 0 999999 | while read line; do :; done takes 10 times longer than prior to the changes. If no timeout is specified don't call poll(2). Costs 16 bytes in a 32-bit build; 0 in 64-bit.
2024-03-03tls: use C code for x86_64 sp_256_sub_8_p256_mod()Ron Yorston1-1/+1
There's an upstream bug report: https://bugs.busybox.net/show_bug.cgi?id=15679 that if BusyBox is built for x86_64 with gcc and the use of OpenSSL for wget is disabled, failures ensue. A similar issue also affects the busybox-w32 build with the comparable configuration. The problem appears to be in the assembly code for the function sp_256_sub_8_p256_mod(), as forcing the use of the provided C code seems to fix both upstream and busybox-w32. Since my knowledge of x64_64 assembler is non-existent, someone else will need to determine the actual issue. For the moment, just avoid the faulty code. Saves 32 bytes in the 64-bit build. (GitHub issue #263)
2024-03-02awk: fix segfault when compiled by clangRon Yorston1-1/+1
A 32-bit build of BusyBox using clang segfaulted in the test "awk assign while assign". Specifically, on line 7 of the test input where the adjustment of the L.v pointer when the Fields array was reallocated L.v += Fields - old_Fields_ptr; was out by 4 bytes. Rearrange to code so both gcc and clang generate code that works. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2024-03-02crond: log5 fix typo, replace log level '4' with '5'Jones Syue1-1/+1
log5() with crondlog(5, msg, va) seems making logging more consistent. function old new delta ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes Signed-off-by: Jones Syue <jonessyue@qnap.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2024-02-26ash: fix handling of single-quoted strings in pattern substitutionDenys Vlasenko5-0/+29
function old new delta subevalvar 1576 1588 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-02-26ip link: support for the CAN netlinkDario Binacchi3-11/+333
I developed this application to test the Linux kernel series [1]. As described in it I could not use the iproute2 package since the microcontroller is without MMU. function old new delta do_set_can - 920 +920 packed_usage 34645 34908 +263 get_float_1000 - 164 +164 .rodata 105427 105539 +112 do_iplink 1313 1381 +68 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 3/0 up/down: 1527/0) Total: 1527 bytes cc: Marc Kleine-Budde <mkl@pengutronix.de> [1] https://marc.info/?l=linux-netdev&m=167999323611710&w=2 Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-02-25hush: detect when terminating "done"/"fi" is missingDenys Vlasenko9-1/+22
function old new delta parse_stream 2271 2292 +21 .rodata 105408 105427 +19 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0) Total: 40 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-02-25hush: set G.ifs sooner (prevents segfault)Denys Vlasenko1-28/+34
function old new delta set_G_ifs - 151 +151 run_list 1024 1031 +7 run_pipe 1567 1445 -122 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 158/-122) Total: 36 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-02-25win32: add a comment about LTO to mkreleaseRon Yorston1-2/+7
2024-02-25win32: add BB_VER.h to .gitignoreRon Yorston1-0/+1
2024-02-25ls: do not truncate username/groupname to 8 charsDenys Vlasenko1-2/+2
function old new delta .rodata 105412 105408 -4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-02-23Update README.mdRon Yorston1-2/+7
2024-02-20win32: fix uname(2) if ARM architecture is undefinedFRP-5301-gda71f7c57Ron Yorston1-0/+2
Older versions of mingw don't define PROCESSOR_ARCHITECTURE_ARM64. Don't let this stop the build.
2024-02-20build system: fix for older GNU makeRon Yorston1-3/+9
Commit 992387539 (build system: more clang/llvm tweaks) added a test in scripts/Makefile.build which used the intcmp function. This isn't present in GNU make prior to 4.4. Rewrite the test so it works with older versions of GNU make.
2024-02-16build system: avoid full rebuild when EXTRAVERSION changesRon Yorston7-2/+25
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.
2024-02-16build system: improvements to EXTRAVERSION detectionRon Yorston1-8/+9
The previous commit to detect EXTRAVERSION more accurately was lacking in some respects: - Only attempt to detect EXTRAVERSION if it's currently set to the default value '.git'. - Use immediate-expansion macro assignments to avoid time-consuming repeated evaluations. - Remove a useless use of cat. - Correctly allow for the output being sent to a separate directory.
2024-02-15build system: try to find a more precise EXTRAVERSIONRon Yorston2-0/+34
The default EXTRAVERSION is .git. Use some clues to determine a more precise EXTRAVERSION: - git describe - A .frp_describe file embedded in the release tarball - The name of the build directory: tarballs of release tags from GitLab and GitHub include the version in the directory name.
2024-02-11httpd: enable interpreter script featureRon Yorston5-18/+38
The web server in BusyBox has an optional feature to allow pages with a given suffix to be processed by a script interpreter: PHP, for example. Enable this in the busybox-w32 build. Costs 256-320 bytes. (GitHub issue #266)
2024-02-11httpd: code shrinkRon Yorston1-10/+7
When setting up the arguments for the CGI handler: - Use '-I0' rather than two separate arguments. - Use memcpy() to copy the server arguments. Saves 32 bytes.
2024-02-09httpd: avoid unnecessary process creationRon Yorston1-3/+4
The httpd server made unnecessary calls to detach from the console. Avoiding this saves one process creation when a file is being served and two for a CGI script. Then again, commit ad4bd5bbd (win32: avoid console windows from CGI scripts) results in a console host always being created for a CGI script even if it turns out to be unnecessary. So the net saving is only one process for CGI scripts.
2024-02-08ash: allow nofork applets in Windows on ARM + UCRTRon Yorston1-1/+2
Commit ea8742bc16 (ash: workaround environment issue in Windows on ARM) prevented nofork applets from being run without a fork in standalone shell mode in Windows on ARM. This was due to a deficiency in the handling of the 'environ' global. However, the problem is specific to MSVCRT. If the target is UCRT nofork applets can be made to work without a fork.
2024-02-07win32: avoid console windows from CGI scriptsRon Yorston1-1/+1
When httpd is run in the background its processes are detached from the console. CGI scripts could create subprocesses which needed a console, resulting in annoying console windows appearing. Prevent this by changing the creation flags for CGI scripts to CREATE_NO_WINDOW.
2024-02-03win32: update sample script for release buildRon Yorston2-36/+67
Update the mkrelease script to include cross-compilation of the Windows on ARM binary on Linux using llvm-mingw.
2024-02-02win32: stat(1) requires find_mount_point()Ron Yorston1-0/+1
In the Microsoft Windows build stat(1) requires find_mount_point() from libbb. This won't be available unless df(1) is also enabled. Add a dependency so stat(1) can be built without df(1). This may result in find_mount_point() being compiled needlessly in some upstream builds, but we can live with that. (GitHub issue #385)
2024-02-02win32: rearrange applet override handlingRon Yorston4-36/+38
- Rename some functions to be more meaningful. - Adjust conditional compilation to clarify which code is required for 'standalone shell' and 'exec prefers applets' settings. This shouldn't result in any change to the behaviour or size of default builds.
2024-01-31win32: UTF8_OUTPUT: recover quicker from bad byteAvi Halachmi (:avih)1-12/+19
When an unexpected value is detected in UTF-8, we should print the placeholder codepoint, and then recover whenever we detect a value which is valid for starting a new UTF-8 codepoint (including ASCII7). However, previously, we only tested recovery at the bytes following the unexpected one, and so if the first unexpected value was also valid for a new codepoint, then didn't rcover it. Now we check for recovery from the first unexpected byte, which, if recoverable, requires both placeholder printout and recovery, so the recovery "unwinding" is modified a bit to allow placeholder. Example of of a sequence which now recovers quicker than before: (where UTF-8 for U+1F600 "😀" is: 0xF0 0x9F 0x98 0x80) printf "\xF0\xF0\x9F\x98\x80A" Previously: ?A Now: ?😀A
2024-01-30win32: import dirname(3) from mingw-w64Ron Yorston2-0/+288
The mingw-w64 project has updated its implementation of dirname(3). In some circumstances the new version doesn't preserve the type of the user-supplied top-level directory separator. As a result of this the dirname-handles-root test case failed. Import the new implementation and tweak it to preserve the type of the separator. This only affects mingw-w64 versions 12 and above. Currently only the aarch64 build using llvm-mingw is affected.
2024-01-30ls: support NO_COLOR environment variableRon Yorston1-0/+5
If the NO_COLOR environment variable is set and is not empty 'ls' won't output ANSI colour codes. This is an alternative to the existing approach of setting 'LS_COLORS=none'. See https://no-color.org/. Costs 24-32 bytes. (GitHub issue #382)
2024-01-24win32: avoid invalid freeRon Yorston1-3/+5
In external_exists() in appletlib.c it's necessary to take a copy of the pointer to the allocated variable path1 so it can be freed: find_executable() will change its value.
2024-01-23win32: hardcode numeric value of MANIFEST resourceRon Yorston1-2/+3
It seems windres in llvm doesn't understand MANIFEST resources. Use the numeric value 24 instead.
2024-01-23Fix POSIX build in standalone shell modeRon Yorston3-4/+7
The conditional compilation to control standalone shell mode was incorrect when building for POSIX. This hadn't been noticed before as it had only been tested in the default configuration where standalone shell mode is disabled.
2024-01-21build system: try a different exception methodRon Yorston1-1/+1
Use -fsjls-exceptions with clang.
2024-01-21build system: actually detect lack of --warn-commonRon Yorston1-1/+7
Commit 992387539 (build system: more clang/llvm tweaks) falsely claimed that the lack of the --warn-common linker option was being detected. It wasn't, but it is now.
2024-01-21win32: add aarch64 to uname(2)Ron Yorston1-0/+3
For Windows on ARM we need to report the aarch64 processor architecture.
2024-01-21build system: improved handling of silent modeRon Yorston1-1/+8
The top-level makefile attempted to detect if make was being run in silent mode (-s option). It then turned off reporting of commands as they were run. There were false positives where unrelated 's' characters in the command line were detected as silent mode. Import the relevant section from the latest Linux build system to improve matters.
2024-01-21win32: update sample scriptRon Yorston1-15/+38
Update the mkprerelease script to include cross-compilation of the Windows on ARM binary on Linux using llvm-mingw.
2024-01-20build system: make compiler names configurableRon Yorston6-6/+48
The top-level Makefile hardcoded the host and cross compiler name to "gcc". Make it possible to set different values either on the command line (make CROSS_COMPILER=clang) or in the configuration file.
2024-01-19awk: fix segfault when compiled by clangRon Yorston1-0/+4
A 32-bit build of BusyBox using clang segfaulted in the test "awk assign while assign". Specifically, on line 7 of the test input where the adjustment of the L.v pointer when the Fields array was reallocated: L.v += Fields - old_Fields_ptr; was out by 4 bytes. Rearrange to code so both gcc and clang generate code that works. This patch has been submitted upstream. Until it's accepted there the new code is only used in builds for Windows.
2024-01-18ash: workaround environment issue in Windows on ARMRon Yorston1-1/+2
The environment is handled differently in ARM64 Windows. Assignments to 'environ' result in a compiler error. Omit the offending code for now. NOFORK applets will cause a fork.