| Commit message (Collapse) | Author | Age | Files | Lines |
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When the input data contained a cycle it was possible for tsort to
attempt to access freed nodes. This sometimes resulted in the
test case 'echo a b b a | tsort' crashing.
Don't free nodes when they're removed from the graph.
function old new delta
tsort_main 621 596 -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-25) Total: -25 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When I planned to print the command in read_line_input, I found that after
the system started, the command printed for the first time was always
garbled.
After analysis, it is found that in the init() function of ash, the
variable basepf.buf is not initialized after applying for memory, resulting
in garbled initial data. Then assign it to the global variable
g_parsefile->buf in ash.c, and then pass g_parsefile->buf to the parameter
command of the function read_line_input in the function preadfd(), and
finally cause it to be garbled when the command is printed by
read_line_input.
The call stack is as follows:
#0 read_line_input (st=0xb6fff220, prompt=0xb6ffc910 "\\[\\033[32m\\]\\h \\w\\[\\033[m\\] \\$ ", command=command@entry=0xb6ffc230 "P\325\377\266P\325\377\266", maxsize=maxsize@entry=1024) at libbb/lineedit.c:2461
#1 0x0043ef8c in preadfd () at shell/ash.c:10812
#2 preadbuffer () at shell/ash.c:10914
#3 pgetc () at shell/ash.c:10997
#4 0x00440c20 in pgetc_eatbnl () at shell/ash.c:11039
#5 0x00440cbc in xxreadtoken () at shell/ash.c:13157
#6 0x00440f40 in readtoken () at shell/ash.c:13268
#7 0x00441234 in list (nlflag=nlflag@entry=1) at shell/ash.c:11782
#8 0x004420e8 in parsecmd (interact=<optimized out>) at shell/ash.c:13344
#9 0x00442c34 in cmdloop (top=top@entry=1) at shell/ash.c:13549
#10 0x00444e4c in ash_main (argc=<optimized out>, argv=0x444e4c <ash_main+1328>) at shell/ash.c:14747
#11 0x00407954 in run_applet_no_and_exit (applet_no=9, name=<optimized out>, argv=0xbefffd34) at libbb/appletlib.c:1024
#12 0x00407b68 in run_applet_and_exit (name=0xbefffe56 "ash", argv=0x9) at libbb/appletlib.c:1047
#13 0x00407f88 in main (argc=<optimized out>, argv=0xbefffd34) at libbb/appletlib.c:1181
Fixes: 82dd14a510ca ("ash: use CONFIG_FEATURE_EDITING_MAX_LEN")
Signed-off-by: zhuyan <zhuyan34@huawei.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Upstream BusyBox supports the usual Unix functionality where the
login process adds a '-' prefix to the shell's argv[0]. Since
busybox-w32 doesn't have a login process this serves no purpose
and can be removed.
Instead it would be useful to have a way to invoke a login shell
without requiring any arguments. Advantages would be:
- easier to configure busybox-w32 'ash' as the SSH login shell;
- double clicking on a shell binary could start a login shell.
Add 'lash' as an alias for 'ash' which starts a login shell without
requiring the '-l' option.
Saves 16 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In Linux the command name associated with a process (as can be
obtained from '/proc/<PID>/comm') is truncated to 16 characters.
Thus upstream BusyBox only allows 16 characters for the 'comm'
field in 'ps'.
There's no need for such a constraint in busybox-w32. Moreover,
the command name is used for the full command line ('args' field)
in most cases. This field is allowed to be rather long in 'ps'
so it's not expected to be truncated.
Still, to avoid diverging too much from upstream it's best to have
some measure of truncation. Increase the allowed length of the
command name to 32 characters.
Adds 16 bytes.
(GitHub issue #358)
|
| |
| |
| |
| |
| |
| |
| |
| | |
Builds without warnings on:
mingw-msvcrt gcc 13.2 i686/x86-64 (w64devkit).
mingw-ucrt gcc 13.1/13.2 i686/x86-64 (winlibs).
Where previously both the ucrt builds warned about I64.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 3476fb9f4c (ps: display interpreted script name in comm
column) required the applet start up code to detect the index
of the script in a shebang command line.
When a script starts with '#!/bin/busybox' the argument list is
shifted in busybox_main() but the script index wasn't adjusted
to match. This caused the command to fail.
Make the proper adjustment.
Add 16 bytes.
(GitHub issue #357)
|
|\ \
| | |
| | | |
win32: UTF8_OUTPUT: speedup for big outputs
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
With the native Windows console, writeCon_utf8 which converts
a stream of UTF8 into console output is about 1.4x slower for big
unicode writes than the native fwrite (e.g. when the console codepage
is UTF8), which is not too bad.
However, newer versions of conhost are quicker, e.g. OpenConsole.exe
(which is conhost) which ships with the Windows terminal is about 4x
faster than the native conhost in processing (unicode?) input.
And when conhost can process inputs much quicker, it turned out that
fwrite throughput was nearly 3x better than writeCon_utf8.
Luckily, this turned out to be mainly due to the internal 256 wide
chars buffer which writeCon_utf8 uses, and that with 4096 buffer
it becomes only ~ 10% slower than fwrite, which is much better.
However, making the console window very small such that it needs to
spend very little time on rendering, makes it apparent that there's
still a difference - writeCon_utf8 is about 30% slower than fwrite,
but that's still not bad, and that's also an uncommon use case.
So this commit increases the buffer, and also allocates it dynamically
(once) to avoid abusing the stck with additional 8K in one call.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
According to POSIX only fatal diagnostic messages should be written
to stderr. Arrange for warning() to write to stdout.
pdpmake was rather too prolific in generating 'nothing to be done
for XXX' messages. GNU make only issues the equivalent message
for top-level targets and only if nothing at all was (or would have
been) done. bmake doesn't seem to have such a message.
Follow the practice of GNU make. This requires more intensive
tracking of the actions taken while the make is in progress.
Costs 16 bytes.
(GitHub issue #354)
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Commit 4b65e7d9 (Fixes to inference rules) set the N_TARGET flag
for prerequisites being built recursively. That wasn't necessary
for the issue at hand and it lead to other problems.
Undo that part of commit 4b65e7d9.
(GitHub issue #354)
|
| | |
| | |
| | |
| | | |
Add a test for the problem reported in -w32 GitHub issue #354.
|
|/ /
| |
| |
| |
| |
| |
| |
| | |
If upstream BusyBox had a 'make' applet a native build with it
enabled should match the corresponding build from the busybox-w32
source.
Make it so.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Parsing of target rules was too simplistic to allow targets of
the form c:/path.
Allow such targets as a non-POSIX extension. Also add a 'windows'
pragma to allow such targets in POSIX mode. This additionally
requires the use of the 'target_name' pragma to permit slashes in
target names.
This change *doesn't* allow targets of the form c:path, but it's
probably not wise to use them anyway.
Costs 40-80 bytes.
(GitHub issue #353)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The Windows implementation of readlink(2) has caused problems in
the past. As, for example, with commit c29dc205d2 (win32: fix
implementation of readlink(2)).
Most uses of readlink(2) in BusyBox are actually calls to the
(considerably more convenient) library function xmalloc_readlink().
Implement a Windows version of that and used it instead of readlink(2).
This improves the handling of symbolic links (and similar reparse
points) in CJK and UTF-8 code pages.
Saves 48-80 bytes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Set 'noconsole' to match the actual state of the console (normal/
iconified) when the shell is started. Thus ShowWindow() will only
be called if the actual state differs from the default or user
defined state.
Costs 20-24 bytes.
(GitHub issue #325)
|
| |
| |
| |
| |
| | |
The testsuite includes some Windows-specific tests. Exclude these
when running a test on a native build to avoid upsetting the results.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The shell detected a native Windows environment by checking for a
mixed-case 'Path' environment variable. This has always worked on
Windows but recent versions of Wine have a 'PATH' environment
variable.
Check also for 'ComSpec'.
Costs 24-48 bytes.
|
| |
| |
| |
| |
| | |
When the UTF-8 manifest is included in the binary but the ANSI
code page isn't UTF-8 report "UTF8 manifest not supported".
|
| |
| |
| |
| |
| |
| |
| | |
Make it possible to use the 'trap' built-in with command substitution,
process substitution and in pipelines.
Costs 200-256 bytes.
|
| |
| |
| |
| |
| |
| |
| | |
Move the code to handle the case nprocs == 1 from jobtab_size()
to procstat_size().
Saves 16 bytes.
|
| | |
|
| | |
|
|\| |
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
strings_main 422 420 -2
setfattr_main 175 173 -2
brctl_main 1548 1546 -2
makedevs_main 979 975 -4
rev_main 337 332 -5
getfattr_main 307 302 -5
cut_main 1201 1196 -5
cksum_main 398 393 -5
umount_main 573 565 -8
ln_main 516 508 -8
expand_main 660 652 -8
df_main 1068 1060 -8
renice_main 346 332 -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/13 up/down: 0/-76) Total: -76 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
getfattr_main 309 307 -2
.rodata 105395 105391 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6) Total: -6 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
getfattr_main - 309 +309
print_attr - 115 +115
packed_usage 34576 34631 +55
.rodata 105349 105395 +46
lgetxattr - 41 +41
getxattr - 41 +41
llistxattr - 35 +35
listxattr - 35 +35
applet_names 2806 2815 +9
applet_main 1620 1624 +4
------------------------------------------------------------------------------
(add/remove: 7/0 grow/shrink: 4/0 up/down: 690/0) Total: 690 bytes
Signed-off-by: YU Jincheng <shana@zju.edu.cn>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
function old new delta
hwclock_main 576 579 +3
.rodata 105404 105349 -55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 3/-55) Total: -52 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Pass job data to child shells. This makes it possible to use
the 'jobs' built-in with command substitution, process substitution
and in pipelines.
Costs 576-672 bytes
(GitHub issue #350)
|
| |
| |
| |
| | |
Allow nproc to build without error when LONG_OPTS is disabled.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The changes introduced to support the --binary option gave incorrect
results when comparing files with CRLF line endings *without* the
--binary option present.
The code needs to keep track of the position within the file and is
confused by text mode.
As an alternative solution, always use binary mode but skip the CR
of a CRLF pair when the --binary option isn't used. This gives
results matching GNU diff when comparing files with matching line
endings, with or without --binary. When line endings differ the
results aren't always the same.
Costs 32 bytes in the 32-bit build, saves 16 in 64-bit.
(GitHub issue #348)
|
| | |
|
|\ \
| | |
| | | |
Win32: make unicode print correctly regardless of console CP
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Previously, when writing to the console, the non-unicode build always
assumed the source data is in the ANSI codepage, and used charToCon
to convert it unconditionally to the console CP.
Similarly, the unicode build made the same assumption (where ANSI CP
is UTF8), and always tried to convert it so that it's printed
correctly (at least when FEATURE_UTF8_OUTPUT is enabled - which it is
by default at the unicode build).
However, there could be cases where this assumption is incorrect, for
instance if the data comes from a file encoded for some codepage X,
and after the user also changed the console CP to X does 'cat file.X'
This commit allows disabling this conversion, using the same env vars
which can be used to disable the locale/unicode elsewhere, (LANG,
LC_CTYPE, LC_ALL as "C") e.g. 'LC_ALL=C cat file.X' now doesn't
convert, and the console renders it according to its own codepage.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Previously, the unicode build required console (out) codepage of UTF8
in order for unicode output to be printed correctly - e.g. at the
shell command prompt or the output of `ls` for unicode file names.
This is inconvenient, because by default it's not UTF8, and so unless
the user invoked 'chcp 65001' - by default unicode output didn't work.
This feature (which is now enabled for the unicode build) makes it
print unicode output correctly regardless of the console CP, by
using a new stream-conversion funcion from UTF8 chars to wchar_t,
and writing those using WriteConsoleW.
If the console CP happens to be UTF8 - this conversion is disabled.
We could have instead changed the console CP to UTF8, but that's
a slippery slope, and some old program which expect the default CP
might get broken, so achieving the same result without touching
the console CP is hopefully better.
|
|/ /
| |
| |
| |
| |
| |
| |
| | |
Use one call to do both charToCon and then write it to the console.
Technically, this commit only reduces boilerplate code slightly,
but it also makes it easier for future modifications to make
changes to this sequence in one place.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When the UTF8 manifest is included in the binary and ACP isn't UTF8
fail at once. This avoids raising false hopes if the binary is run
on Window 7/8. On Windows XP it won't even run.
When the busybox applet is run without arguments always report the
build-time configuration of globbing and the UTF8 manifest.
|
| | |
|
|\ \
| | |
| | | |
win32: version with UTF8 manifest: add '(Unicode on/off)'
|
|/ /
| |
| |
| |
| |
| | |
When the UTF8 manifest is enabled at build time, then the version
now includes a string indicating whether unicode is active (e.g. it's
inactive on win 7/8, but should be active on Win10 1903+).
|
|\ \
| | |
| | | |
Win32: support unicode editing
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This adds the Emoticons block U+1F600..U+1F64F as double-width
codepoints, and the skin tone modifiers range U+1F3FB..U+1F3FF
as combining codepoints.
The Emoticons variant modifiers U+FE0E and U+FE0F were already in.
It's unclear how to test UNICODE_COMBINING_WCHARS and
UNICODE_WIDE_WCHARS in general and also here specifically,
but at least the data on Emojis width and combinings now exits.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Commit 8ade494 added VT input support and, among others,
disabled inc_cursor (in favor of the upstream busybox code) when
the terminal has VT input enabled.
However, inc_cursor works correctly regardless of the VT mode,
and that condition was not required.
Revert this condition (but still disable inc_cursor with unicode
because it handles wide-glyphs incorrectly).
|
| | |
| | |
| | |
| | |
| | |
| | | |
Run ./scripts/mk_mingw64u_defconfig to create (or update)
configs/mingw64u_defconfig from configs/mingw64_defconfig while
enabling UTF8 manifest, UTF8 input, and unicode editing.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
FEATURE_UTF8_MANIFEST enables Unicode args and filenames on Win 10+.
FEATURE_UTF8_INPUT allows the shell prompt to digest correctly
Unicode strings (as UTF8) which are typed or pasted.
This commit adds support for building with FEATURE_UNICODE_SUPPORT
(mostly by supporting 32 bit wchar_t which busybox expects):
- Unicode-aware line-edit - for the most part cursor movement/del
being (UTF8) codepoint-aware rather than assuming that one-byte
equals one-char-on-screen.
- Codepoint-aware operations in some other utils, like rev or wc -c.
- When UNICODE_COMBINING_WCHARS and UNICODE_WIDE_WCHARS are enabled,
some screen-width-aware operations, like with fold, ls, expand, etc.
The busybox Unicode support is incomplete, and even less so with the
builtin libc replacement functions, like wcwidth, which are active
when UNICODE_USING_LOCALE is unset (mingw lacks those functions).
FEATURE_CHECK_UNICODE_IN_ENV should be set so that Unicode is not
hardcoded but rather depends on the ANSI codepage and some env vars:
LC_ALL=C disables Unicode support, else it's enabled if ACP is UTF8.
There's at least one known issue where the tab-completion-prefix-case
is not updated correctly, e.g. ~/desk<tab> completes to ~/desktop/
instead of ~/Desktop/, because the code which handles it exists
only at the non-unicode code paths, but that's not very critical.
That seems to be the only case where mingw-specific code is disabled
when Unicode is enabled, but there could be other unknown issues.
None of the Unicode options is enabled by default, and the next
commit will make it easier to create a build which supports Unicode.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The UTF8 input code works around an issue when pasting at the
windows console (but not terminal) that sometimes we get key-up
without a prior matching key-down - at which case it generates down.
However, previously it detected this by comparing an up-event to the
last down-event, which could result in false-positive in cases like:
X-down Y-down X-up Y-up (e.g. when typing quickly).
Now it remembers the last 8 key-down events when searching a prior
matching key-down, which fixes an issue of incorrect repeated keys
(in the example above Y-up was incorrectly changed to Y-down).
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Commit 8e6991733 (ash: fix 'read' shell built-in (1)) introduced
the use of poll(2) in the shell 'read' built-in. When the UTF8
code page is in use this results in the console crashing if a 3 or
more byte UTF8 character is entered.
The crash is caused by the use of PeekConsoleInputA() which, like
ReadConsoleInputA(), is broken. It can be avoided by using
PeekConsoleInputW() instead.
The number of key events will differ but this doesn't matter in
this case as poll(2) effectively runs in a busy loop with a 1ms
sleep.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Implement clock_settime(2) and enable the '-s' option to allow
the system time to be set. This requires elevated privileges.
The code in date.c is now identical to upstream BusyBox.
Costs 256-272 bytes.
|