| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Update the 'rpm' applet so it also respects the BB_SYSTEMROOT
environment variable.
Replace chdir_system_drive() with xchdir_system_drive(), which
exits on failure to change directory.
Saves 32-36 bytes.
(GitHub PR #603)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
| |
Make the corners of the symbolic bitmap icon look more rounded.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
Reduce the colour depth of the bitmap icons from 24-bits colour/
8-bit alpha to 8-bit colour/1-bit alpha for aterm.ico and 1-bit
colour/1-bit alpha for sterm.ico.
This reduces the size of the standard builds by 21KB. The builds
targeting Windows 10/11 already used smaller PNG icons.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Recent changes to our mntent routines added support for Windows
volume names. If such a name is available use it in our sync(2)
implementation to flush file buffers. Failing that, use the drive
letter as before.
This handles edge cases where only one or other of the volume name
or drive letter is available.
Adds 32 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Revert "find: reset stat(2) flags before terminating"
This reverts commit 228ee18fbe8cf408440e7bbe91db4ef201312983.
* test: fix flags for stat with NOFORK
test is a NOFORK applet, so the flags under mingw_stat may not have been
reset before calling it. We have it so it also restores the flags after,
since it could be called in the middle of another applet.
This also needed a way to retrieve the flags, so they are just done
through the return value.
* Add comments about not having to restore flags
Just for future reference
* lineedit: use new flag restoring
* win32: simplify mingw_access calling
Since we now have a way to get the previous flags, mingw_access can be
changed to ignore any stat flags
* stat: comments from PR
Adds 32 bytes.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add code to distinguish between volume mount points and junctions.
Volume mount points are to be treated like directries while
junctions are like symlinks.
Update the 'mntent' functions to scan drive letters first, then
volume names and their associated mount points. By default the
filesystem is returned as a drive letter, if possible, though
the volume name is also returned.
The function 'find_mount_point()' has been updated to use the
new 'mntent' routines.
Adds 772-803 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 62e4c5d29 (win32: special treatment for virtual hard disk)
added special treatment for mount points associated with virtual
hard disks. One statement made there was incorrect: a VHD without
a drive letter containing no files *does* have a '.' directory.
The error message for this case was misleading.
The changes made to handle VHDs were insufficiently general:
- lstat(2) only resolved symlinks for the explicit path '.'.
It should also do so for paths of the form 'path/to/.'.
- opendir(3) only generated entries for '.' and '..' directories
when FindFirstFileA() failed for the path '.'. It should also
do so for any path which resolves to a volume mount point.
Make the necessary changes.
Adds 64-80 bytes.
(GitHub issue #597)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Virtual hard disks (VHD) without a drive letter gave incorrect
results in 'ls' and 'stat'. There were two problems:
- If the disk is empty it doesn't have a '.' directory.
- If it contains files the '.' directory is actually the mount
point, which looks like a symbolic link and can't be opened
as a directory.
Modify our 'stat(2)' and 'opendir(3)' implementations to handle
these quirks.
Adds 78-80 bytes.
(GitHub issue #597)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Running 'C:/Windows/System32/cmd.exe' from the shell was found to
have the unxpected result of creating the directory '.exe'. This
is due to the weirdness of cmd.exe.
A similar problem with batch files was already being handled in
`spawnveq()` by converting forward slashes to backslashes in the
path to the executable file. Doing this unconditionally will fix
the above case too.
(GitHub issue #598)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
It was reported that a mounted volume looked like a broken symlink
and that changing to the mount directory failed.
Preserve the format of the volume name when resolving the link.
Adds 84-96 bytes.
(GitHub issue #597)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
| |
The current implementation of 'stty' for Windows only uses a
limited subset of the flags in 'struct termios'. Remove some
unused features.
Saves 16-40 bytes.
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit a560fdf23 (win32: better handling of console state) changed
to using CONIN$/CONOUT$ to handle terminal modes.
In tcgetattr() CONOUT$ was used instead of CONIN$, leading to
incorrect mode bits being fetched.
Saves 8-16 bytes.
(GitHub issue #594)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When 'stty size' was run in a command substitution with stderr
redirected or 'stty -echo' with stdin redirected, it failed to
work properly. The redirections broke its connection to the
terminal.
To fix this, ioctl/tcsetattr/tcgetattr have been modified to use
CONIN$ or CONOUT$ to access the screen buffer. Using CON isn't
an adequate substitute in this case.
Also, if ioctl(fd, TIOCGWINSZ) fails, set errno.
Adds 112-116 bytes.
(GitHub issue #594)
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If 'ls' is invoked without the '-l' option (or something that's
equivalent) and colour output isn't required, there's no need to
perform the expensive check for execute permission.
Allow 'ls' to inform stat(2) not to call has_exec_format(). This
has been combined with the existing mechanism to enable counting
subdirectories.
With this change the command 'ls | wc -l' used in issue #589
doesn't perform the test which upset Windows' anti-malware thing.
Adds 32-48 bytes.
(GitHub issue #589)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The 'reset' applet hasn't kept pace with developments elsewhere.
We now have support for 'stty sane', so the code in 'reset' which
calls that can be enabled.
Windows 10 and 11 have updated Terminal and Console programs, with
varying features and behaviours. Add ANSI emulation code to handle
clearing the scrollback buffer and use ANSI sequences in 'reset'
to do that. It was also necessary to retain the explicit call to
reset_screen(), or 'reset' didn't work properly in the Terminal I'd
installed in Windows 10.
Adds 92-128 bytes.
(GitHub issue #161)
|
| |
|
|
|
| |
Silence a compiler warning that 'arg' is an unused variable if
neither stty nor ttysize is defined.
|
| |
|
|
|
|
|
|
|
| |
I've been far too lax in applying FAST_FUNC annotations. These
can make function calls smaller and faster, but only on 32-bit
systems and for non-static, non-variadic functions with non-void
arguments.
Saves 4680 bytes in the 32-bit build; 64-bit builds are unaffected.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Enable crontab
* Enable crond
* Allow sendmail to be used in crond
This also adds another option to the mingw_popen_fd function to capture
stderr as well. And also added the options to support WNOHANG as well
as an unused status in mingw_wait3
* Check current uid when running crond
* Only show tail for mailto jobs
* Use system drive for cron
* crond: add missing feature check
* crond: use spawn_detach for background operation
|
| |
|
|
|
|
|
|
|
| |
Support for /dev/urandom and /dev/zero relies on having a working
dd. If the dd applet is disabled attempts to access them should
fail.
Theoretically a third-party dd utility could also work, but let's
not encourage that sort of heresy.
|
| |
|
|
|
|
| |
Rearrange the code to avoid a superfluous process creation.
Saves 16 bytes in the 64-bit build, adds 24 in the 32-bit.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously the special devices /dev/urandom and /dev/zero could
only be used via the 'dd' applet. They were also used internally
by some applets.
Expose /dev/urandom and /dev/zero so they can be used as file
arguments to applets and a source of redirections in the shell.
They're also now visible to 'stat' and 'ls', but only if given
as an explicit argument.
Adds 122-144 bytes.
(GitHub issues #98, #282)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* win32: fnmatch2 minor refinements (no-op)
With beacket, add '\' to the switch/case, and at fnmatch, pre-calc
the two most used flags (CASEFOLD and PATHNAME) once on init.
Negligible perf impact, and happens to save few bytes in x64.
* win32: actype: trivial refinments (no-op)
NULL was used in actype.h but requires stddef.h - which we don't
include, so use (int*)0 which also expresses it more clearly.
Remove "#include <string.h>" at actype.c, which we don't need anymore.
* scripts/patbench.sh: make executable (chmod +x)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This was done to be more concise, but it also happens to speed up
the two slowest test patterns by about ~ 30%, and without measurable
impact on any of the other test patterns (nor the correctness).
Maybe the stars aligned for compiler optimizations. We'll take it.
Here are results of scripts/patbench.sh with recent iterations of
fnmatch, from most recent to the original old fnmatch:
CURRENT results:
[ 1] 107 ms OK (M:-----) ''
[ 2] 105 ms OK (M:12345) '*'
[ 3] 106 ms OK (M:-----) '@'
[ 4] 111 ms OK (M:1----) 'Lorem*'
[ 5] 122 ms OK (M:-2---) '*quis'
[ 6] 133 ms OK (M:--3--) '*nisi*'
[ 7] 229 ms OK (M:--3--) '*[fobar]xyz*'
[ 8] 451 ms OK (M:--3--) '*[foobarfoobarfoobarfoobar]xyz*'
[ 9] 463 ms OK (M:-2---) '*[!foobarfoobarfoobarfoobar]xyz*'
[10] 136 ms OK (M:12345) '*[hello world, this is a test]*'
[11] 126 ms OK (M:12345) '*[!hello world, this is a test]*'
[12] 169 ms OK (M:1-3--) '*[*'
[13] 175 ms OK (M:1----) '*[]*'
[14] 171 ms OK (M:--3--) '*[!]*'
[15] 162 ms OK (M:-23-5) '*[!]].*'
[16] 243 ms OK (M:1----) '*[![:print:]]*'
[17] 135 ms OK (M:-23--) '*z*'
[18] 131 ms OK (M:---4-) '*-*'
[19] 157 ms OK (M:---4-) '*[-]*'
[20] 165 ms OK (M:-234-) '*[-z]*'
[21] 176 ms OK (M:-234-) '*[z-]*'
[22] 182 ms OK (M:-234-) '*[-z-]*'
[23] 130 ms OK (M:1-3--) '*]*'
[24] 153 ms OK (M:1-3--) '*[]]*'
[25] 164 ms OK (M:1-34-) '*[]-]*'
[26] 167 ms OK (M:123--) '*[]-_]*'
[27] 168 ms OK (M:1234-) '*[]-_-]*'
[28] 122 ms OK (M:12-45) '*[0-9A-Za-z][0-9A-Za-z]'
[29] 126 ms OK (M:12-45) '*[[:alnum:]][[:alnum:]]'
[30] 118 ms OK (M:12-45) '*[a-z][a-z]'
[31] 127 ms OK (M:12-45) '*[a-bc-de-z][a-bc-de-z]'
[32] 131 ms OK (M:12-45) '*[[:lower:]][[:lower:]]'
[33] 136 ms OK (M:-----) '*[0-9A-Fa-ef][0-9A-Fa-ef]'
[34] 124 ms OK (M:-----) '*[[:xdigit:]][[:xdigit:]]'
[35] 128 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 129 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[37] 127 ms OK (M:12-45) '*[a-z]*[a-z]'
[38] 123 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 124 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 136 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 134 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
[42] 136 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]'
[43] 131 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]*[[:alnum:]]'
[44] 124 ms OK (M:12-45) '*[a-z]*[a-z]*[a-z]'
[45] 137 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]*[a-bc-de-z]'
[46] 129 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]*[[:lower:]]'
[47] 160 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[48] 164 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]*[[:xdigit:]]'
[49] 152 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]'
[50] 152 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]*[[:alnum:]]*[[:alnum:]]'
[51] 130 ms OK (M:12-45) '*[a-z]*[a-z]*[a-z]*[a-z]'
[52] 165 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]*[a-bc-de-z]*[a-bc-de-z]'
[53] 146 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]*[[:lower:]]*[[:lower:]]'
[54] 180 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[55] 189 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]*[[:xdigit:]]*[[:xdigit:]]'
Previous commit (if-else-...) is mainly slower in patterns 8 and 9:
[ 6] 143 ms OK (M:--3--) '*nisi*'
[ 7] 251 ms OK (M:--3--) '*[fobar]xyz*'
[ 8] 638 ms OK (M:--3--) '*[foobarfoobarfoobarfoobar]xyz*'
[ 9] 651 ms OK (M:-2---) '*[!foobarfoobarfoobarfoobar]xyz*'
[10] 138 ms OK (M:12345) '*[hello world, this is a test]*'
[11] 137 ms OK (M:12345) '*[!hello world, this is a test]*'
Initial fnmatch2 commit (without any optimizations):
[ 1] 101 ms OK (M:-----) ''
[ 2] 123 ms OK (M:12345) '*'
[ 3] 105 ms OK (M:-----) '@'
[ 4] 115 ms OK (M:1----) 'Lorem*'
[ 5] 134 ms OK (M:-2---) '*quis'
[ 6] 131 ms OK (M:--3--) '*nisi*'
[ 7] 235 ms OK (M:--3--) '*[fobar]xyz*'
[ 8] 586 ms OK (M:--3--) '*[foobarfoobarfoobarfoobar]xyz*'
[ 9] 613 ms OK (M:-2---) '*[!foobarfoobarfoobarfoobar]xyz*'
[10] 153 ms OK (M:12345) '*[hello world, this is a test]*'
[11] 160 ms OK (M:12345) '*[!hello world, this is a test]*'
[12] 164 ms OK (M:1-3--) '*[*'
[13] 165 ms OK (M:1----) '*[]*'
[14] 157 ms OK (M:--3--) '*[!]*'
[15] 157 ms OK (M:-23-5) '*[!]].*'
[16] 244 ms OK (M:1----) '*[![:print:]]*'
[17] 132 ms OK (M:-23--) '*z*'
[18] 134 ms OK (M:---4-) '*-*'
[19] 160 ms OK (M:---4-) '*[-]*'
[20] 157 ms OK (M:-234-) '*[-z]*'
[21] 168 ms OK (M:-234-) '*[z-]*'
[22] 166 ms OK (M:-234-) '*[-z-]*'
[23] 130 ms OK (M:1-3--) '*]*'
[24] 150 ms OK (M:1-3--) '*[]]*'
[25] 151 ms OK (M:1-34-) '*[]-]*'
[26] 157 ms OK (M:123--) '*[]-_]*'
[27] 156 ms OK (M:1234-) '*[]-_-]*'
[28] 402 ms OK (M:12-45) '*[0-9A-Za-z][0-9A-Za-z]'
[29] 416 ms OK (M:12-45) '*[[:alnum:]][[:alnum:]]'
[30] 265 ms OK (M:12-45) '*[a-z][a-z]'
[31] 410 ms OK (M:12-45) '*[a-bc-de-z][a-bc-de-z]'
[32] 426 ms OK (M:12-45) '*[[:lower:]][[:lower:]]'
[33] 347 ms OK (M:-----) '*[0-9A-Fa-ef][0-9A-Fa-ef]'
[34] 370 ms OK (M:-----) '*[[:xdigit:]][[:xdigit:]]'
[35] 294 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 301 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[37] 214 ms OK (M:12-45) '*[a-z]*[a-z]'
[38] 304 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 302 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 306 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 291 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
[42] 291 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]'
[43] 302 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]*[[:alnum:]]'
[44] 208 ms OK (M:12-45) '*[a-z]*[a-z]*[a-z]'
[45] 314 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]*[a-bc-de-z]'
[46] 288 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]*[[:lower:]]'
[47] 315 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[48] 340 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]*[[:xdigit:]]'
[49] 309 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]'
[50] 304 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]*[[:alnum:]]*[[:alnum:]]'
[51] 217 ms OK (M:12-45) '*[a-z]*[a-z]*[a-z]*[a-z]'
[52] 317 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]*[a-bc-de-z]*[a-bc-de-z]'
[53] 322 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]*[[:lower:]]*[[:lower:]]'
[54] 315 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[55] 348 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]*[[:xdigit:]]*[[:xdigit:]]'
Old fnmatch with actype/isactype in O(1):
[ 1] 103 ms OK (M:-----) ''
[ 2] 116 ms OK (M:12345) '*'
[ 3] 108 ms OK (M:-----) '@'
[ 4] 112 ms OK (M:1----) 'Lorem*'
[ 5] 122 ms OK (M:-2---) '*quis'
[ 6] 123 ms OK (M:--3--) '*nisi*'
[ 7] 270 ms OK (M:--3--) '*[fobar]xyz*'
[ 8] 650 ms OK (M:--3--) '*[foobarfoobarfoobarfoobar]xyz*'
[ 9] 681 ms OK (M:-2---) '*[!foobarfoobarfoobarfoobar]xyz*'
[10] 133 ms OK (M:12345) '*[hello world, this is a test]*'
[11] 135 ms OK (M:12345) '*[!hello world, this is a test]*'
[12] 191 ms E:1-3-- (M:-----) '*[*'
[13] 213 ms E:1---- (M:-----) '*[]*'
[14] 215 ms E:--3-- (M:-----) '*[!]*'
[15] 182 ms OK (M:-23-5) '*[!]].*'
[16] 296 ms OK (M:1----) '*[![:print:]]*'
[17] 121 ms OK (M:-23--) '*z*'
[18] 115 ms OK (M:---4-) '*-*'
[19] 167 ms OK (M:---4-) '*[-]*'
[20] 189 ms OK (M:-234-) '*[-z]*'
[21] 194 ms OK (M:-234-) '*[z-]*'
[22] 203 ms OK (M:-234-) '*[-z-]*'
[23] 122 ms OK (M:1-3--) '*]*'
[24] 166 ms OK (M:1-3--) '*[]]*'
[25] 185 ms OK (M:1-34-) '*[]-]*'
[26] 163 ms OK (M:123--) '*[]-_]*'
[27] 176 ms OK (M:1234-) '*[]-_-]*'
[28] 381 ms OK (M:12-45) '*[0-9A-Za-z][0-9A-Za-z]'
[29] 510 ms OK (M:12-45) '*[[:alnum:]][[:alnum:]]'
[30] 274 ms OK (M:12-45) '*[a-z][a-z]'
[31] 379 ms OK (M:12-45) '*[a-bc-de-z][a-bc-de-z]'
[32] 488 ms OK (M:12-45) '*[[:lower:]][[:lower:]]'
[33] 340 ms OK (M:-----) '*[0-9A-Fa-ef][0-9A-Fa-ef]'
[34] 398 ms OK (M:-----) '*[[:xdigit:]][[:xdigit:]]'
[35] 1402 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 1962 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[37] 939 ms OK (M:12-45) '*[a-z]*[a-z]'
[38] 1453 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 1965 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 1683 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 2117 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
(aborted manually due to exponential slowness)
Old fnmatch (before actype/isactype):
[ 1] 107 ms OK (M:-----) ''
[ 2] 108 ms OK (M:12345) '*'
[ 3] 104 ms OK (M:-----) '@'
[ 4] 112 ms OK (M:1----) 'Lorem*'
[ 5] 120 ms OK (M:-2---) '*quis'
[ 6] 127 ms OK (M:--3--) '*nisi*'
[ 7] 244 ms OK (M:--3--) '*[fobar]xyz*'
[ 8] 544 ms OK (M:--3--) '*[foobarfoobarfoobarfoobar]xyz*'
[ 9] 588 ms OK (M:-2---) '*[!foobarfoobarfoobarfoobar]xyz*'
[10] 129 ms OK (M:12345) '*[hello world, this is a test]*'
[11] 136 ms OK (M:12345) '*[!hello world, this is a test]*'
[12] 192 ms E:1-3-- (M:-----) '*[*'
[13] 201 ms E:1---- (M:-----) '*[]*'
[14] 203 ms E:--3-- (M:-----) '*[!]*'
[15] 182 ms OK (M:-23-5) '*[!]].*'
[16] 454 ms OK (M:1----) '*[![:print:]]*'
[17] 124 ms OK (M:-23--) '*z*'
[18] 123 ms OK (M:---4-) '*-*'
[19] 160 ms OK (M:---4-) '*[-]*'
[20] 175 ms OK (M:-234-) '*[-z]*'
[21] 177 ms OK (M:-234-) '*[z-]*'
[22] 197 ms OK (M:-234-) '*[-z-]*'
[23] 126 ms OK (M:1-3--) '*]*'
[24] 168 ms OK (M:1-3--) '*[]]*'
[25] 173 ms OK (M:1-34-) '*[]-]*'
[26] 168 ms OK (M:123--) '*[]-_]*'
[27] 170 ms OK (M:1234-) '*[]-_-]*'
[28] 365 ms OK (M:12-45) '*[0-9A-Za-z][0-9A-Za-z]'
[29] 513 ms OK (M:12-45) '*[[:alnum:]][[:alnum:]]'
[30] 263 ms OK (M:12-45) '*[a-z][a-z]'
[31] 376 ms OK (M:12-45) '*[a-bc-de-z][a-bc-de-z]'
[32] 815 ms OK (M:12-45) '*[[:lower:]][[:lower:]]'
[33] 311 ms OK (M:-----) '*[0-9A-Fa-ef][0-9A-Fa-ef]'
[34] 756 ms OK (M:-----) '*[[:xdigit:]][[:xdigit:]]'
[35] 1305 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 1928 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[37] 919 ms OK (M:12-45) '*[a-z]*[a-z]'
[38] 1446 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 3192 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 1586 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 4601 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
[42] 22491 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]*[0-9A-Za-z]'
(aborted manually due to exponential slowness)
|
| |
|
|
|
|
|
|
| |
This adds two fairly cheap and effective optimizations at the tail
of the pattern (after the last '*'). Speeds up many cases by ~ x2+.
Details at the comment inside.
Adds 192 bytes in x64.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
win32/fnmatch.c has several issues:
- *[* doesn't match foo[bar - but it should (non-special '[').
- FMN_CASEFOLD is not handled corrrectly. It does tolower on pattern
and string, which doesn't always work, e.g. *[@-[]* correctly
matches '@', A-Z, and '[', but as case-insensitive it only matches
'@' and '[' (tolower on the string breaks all the alpha matches):
set -o nocaseglob; echo *[@-[]*
set +o nocaseglob; echo *[@-[]*
- According to posix, negative bracket range, like [z-a], should be
either invalid or empty, but instead it matches only 'z'.
- There could be more issues hiding - the code is not easy to follow.
- It's exponential time in the number of '*' in pattern.
This commit adds win32/fnmatch2.c and disables win32/fnmatch.c
(currently using "#if 0"), but still keeps it in the tree.
The new implementation is written from scratch, non-recursive and
linear time, improves POSIX compliance, and hopefully more readable
and fixable if needed. Also, it's about half the size at the binary
(saves 908 bytes in x64).
See implementation details and choices as comment at fnmatch2.c .
|
| |
|
|
|
|
| |
It was already disabled (ASH_OPTIMIZE_FOR_SIZE is 0 by default),
and it saved ~ 40 bytes but with big hit on performance, so not
really worth it. This also makes actype.c less noisy.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Unify actype/actail into a single function, and make actype
a wrapper macro which invokes actail(str, NULL) (to avoid calling
a function actype which then trampolines to actail with NULL).
This concludes the integration of actype/isactype.
Overall:
- Unified/standard-ish char-class handling in fnmatch/regcomp/tr.
- Saved about 1400 bytes at the binary as x64.
- regcomp.c is negligibly faster (actype/isactype are O(1)).
- tr.c now also supports [:graph:] and [:print:], and not slower.
fnmatch.c (tested using scripts/patbench.sh):
Before actype was integrated, alnum was fastest and xdigit slowest
due to their order in the names strings list and in the switch/case:
[35] 1305 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 1928 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[38] 1446 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 3192 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 1586 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 4601 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
Now all classes are similar relative to an equivalent range,
and just barely slower than "alnum" before actype was added
(still slower than range due to additional temp name buffer):
[35] 1402 ms OK (M:12-45) '*[0-9A-Za-z]*[0-9A-Za-z]'
[36] 1962 ms OK (M:12-45) '*[[:alnum:]]*[[:alnum:]]'
[38] 1453 ms OK (M:12-45) '*[a-bc-de-z]*[a-bc-de-z]'
[39] 1965 ms OK (M:12-45) '*[[:lower:]]*[[:lower:]]'
[40] 1683 ms OK (M:---4-) '*[0-9A-Fa-ef]*[0-9A-Fa-ef]'
[41] 2117 ms OK (M:---4-) '*[[:xdigit:]]*[[:xdigit:]]'
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The premise, and implementation, is simple: instead of doing string
search in a list of strings for the class name - which is fast for the
first strings in the list but slow for the last strings, use perfect
hash to map the string directly to a potential class to match in O(1).
The switch/case in isactype is also changed to a function table in O(1)
(the compiler might have optimized this switch to O(1) jump-table, but
now we don't leave it to chance).
Two implementations are supported: one which allows testing actype_t
value against specific classes like AC_ALNUM etc, and one which doesn't
allow that (just like wctype/iswctype) and is more efficient.
Since nothing uses specific class matches anymore, default is the more
efficient choice - where actype_t is a function pointer to isalnum etc.
And while at it, also change the enum names CCLASS_ALNUM etc to more
appropriate AC_ALNUM etc, to use the AC "namespace".
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This saves more than 1K size because the original switch code expanded
a two-loops macro - BUILD_CHARCLASS_LOOP in each of the 12 "case".
Performance is non critical here in regcomp, but nevertheless, a future
commit will optimize actype/isactype, and especially isactype_not0
(which is used here with non-0 type).
Also:
- "#if 0" was replaced with "#ifndef CONFIG_BUSYBOX" for clarity.
- is_blank is no longer used, and disabled in this commit.
|
| |
|
|
|
|
|
|
|
|
| |
This preserves the original semantics where only ASCII chars are
tested, and unknown class name is considered known-but-unmatched name,
which is different than the equivalent wctype code just above.
The ASCII test is redundant, at least on windows - where all the
class tests (isalnum, isupper, etc) can only return true for ASCII
values, but nevertheless it's kept as the original semantics.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
TL;DR:
- Add actype/isactype, like POSIX wctype/iswctype, but single-byte.
- actype is a renamed match_class, isactype is yet unused.
- This can be used in win32/{fnmatch,regcomp}.c, and elsewhere - tr.c.
Details:
win32/fnmatch.c and win32/regcomp.c used match_class to get char-class
index for char-class name, which is then used in a switch statement to
choose the single-byte isupper, isalpha, etc.
This is analogous to the POSIX wctype/iswctype, except that wctype
returns 0 for unknown name but match_class returned -1.
This commit renames match_class to actype:
- Returns 0 for unknown name, which at the enum is a new CCLASS_NONE.
- Return type is actype_t (still enum), analogous to wctype_t.
- Rename match_class* to actype* at fname/kbuild/includes/usage.
Both fnmatch.c and regcomp.c don't care whether unknown name in
match_class/actype is -1 (match_class) or 0 (actype). All they care
about is the values at each "case".
Also implemented, but not yet used:
- isactype(c, t): test whether char c is of type t.
- isactype_not0(c, t): when t is not-0 - same as isactype but faster.
- actail(s, int*): test for "NAME:]..." without temporary buffer.
Note that this commit focuses on exposing a useful API rather than
performance. Future commits may improve actype/isactype performance.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move existing code which obtains process execution times into a
separate function. Use it to allow times(2) to report execution
times for the current process, though not child execution times.
Change TICKS_PER_SECOND from 100 to 1000 to increase the displayed
resolution of process times (though the measured resolution may
well be less than this).
Adds 48-80 bytes.
(GitHub issue #574)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Overlong UTF8 encoding means that a codepoint is encoded using more
bytes than necessary, and it's disallowed.
Until now we didn't reject it, e.g. 2-bytes sequence of 0xc0 0x9b
was incorrectly decoded as codepoint 0x1b (ESC), but it's overlong
because 1-byte 0x1b is enough for this codepoint.
Now we reject such sequences and print '?' (CONFIG_SUBST_WCHAR).
Additionally, we now also reject 4-bytes sequences which end up above
the maximum valid codepoint value (0x10ffff). No such issue with 1/2/3
bytes UTF-8 because technically only 4 can encode a too big value.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The "nwritten" argument and failure conditions were added in commit
208649d7b5, as it crashed on windows XP without it, and specifically
because WriteConsoleW on XP expects this to be a non-NULL argument.
However, writeCon_utf8 should not be called on XP - and indeed it's
not since commit 234a3b97d3, because it produces incorrect output
unless the UTF8 manifest is in effect - which never happens on XP.
So it was called due to a bug, and it's not called on XP anymore.
Nevertheless, it's possible that in the future we will support native
Windows Unicode without the manifest - also on XP, and in such case
writeCon_utf8 might get called on XP as well, so keep this argument.
However the nwritten failure condition doesn't belong here.
It's not needed on XP, and MS docs doesn't say that this value should
tested in addition to the return value in order to determine failure,
and theoretically there could be differences unrelated to failure.
So ignore this value when determining failure. Return value is enough.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, at writeCon_utf8, when we detected an invalid byte (for
the current state), then we printed one '?' which also covered any
following invalid bytes, until a valid byte for state 0 was detected.
For instance printf '\377\377\377A' printed '?A' (3 bad bytes, 1 '?').
This was by design to avoid excessive '?' noise.
However, other terminals (xterm), and specifically windows console
(and terminal), print one '?' for any decoding error, and also reset
the decoding state after every error.
I.e. the same input would error 3 times, and display '???A'.
Now we do the same, which also happens to simplify the code.
The reference behavior is windows console/terminal in UTF-8 codepage
(which writeCon_utf8 tries to emulate in other console codepages).
To compare, do 'chcp 65001' to set the console to UTF-8 - which also
bypasses writeCon_utf8, and check how the terminal displays some
sequence. We should be the same, up to CONFIG_SUBST_WCHAR value.
The "state" comment is updated since we no longer maintain bad state.
While at it, refine also few nearby comments.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the busybox-w32 binary didn't have an extension the shell was
unable to spawn itself:
$ ls -l busybox
-rwxrwxr-x 1 rmy rmy 661006 Feb 25 09:37 busybox
$ ./busybox sh
$ ls
sh: unable to spawn shell
This happened because the shell used spawnve() from the C runtime
to execute itself. Microsoft insists on trying to add an extension
to the name of the binary unless it has an explicit '.' as its
last character.
Use the internal spawnveq() instead, as it handles various quirks
like the above.
Adds 16-32 bytes.
(GitHub issue #566)
|
| |
|
|
|
|
|
| |
Allow applets to open the "files" /dev/stdin, /dev/stdout and
/dev/stderr. The 'stat' and 'ls' applets pretend they exist.
Adds 48-56 bytes.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before commit 208649d7, when unicode was enabled (utf8 manifest), the
build refused to run unless the manifest was in effect (the codepage
is UTF8, and argv, win APIs, and internal strings are UTF8 too).
That commit, however, allows such build to also run where the manifest
has no effect (prior to win10 1903), and so some of the unicode code
paths behave incorrectly in such cases when the runtime ACP is ANSI.
This commit fixes the UTF8_OUTPUT code path in such case, to also
check ACP, instead of unconditionally printing to the console as UTF8.
When ACP is not UTF8, it now behaves identically to a non-unicode
build (doing output conversion from ACP to console out-CP if needed).
Example: create a filename which is valid in the ANSI codepage with
chars above 127, and do "echo *" (glob expansion), which now prints the
name correctly, but previously it didn't when the build has unicode
enabled at buildtime but not runtime (see next why not just try "ls").
This covers the existing busybox-w32 unicode code paths, as the others
(UTF8_INPUT and unicode-aware editing) already had runtime ACP test,
so unicode _should_ be disabled correctly if the runtime ACP is ANSI.
However, there are also some new upstream unicode code paths which
can be entered now - when unicode is enabled at build time but
disabled at runtime.
One we know of is printable-chars code, which is used by applets like
"ls", and so currently, when unicode is enabled at build time but
disabled at runtime, "ls" displays valid ANSI chars above 127 as "?".
The next commit will address this.
|
| |
|
|
| |
Return "armv7" in this case.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now that a binary with a UTF-8 manifest can run on Windows XP
it's possible to configure a build which supports Unicode on
Windows 10+ but which still runs on legacy systems.
- Add the config file mingw32w_defconfig. This is a 32-bit build
with the UTF-8 manifest which also runs on legacy systems.
- A new config option, FEATURE_FAIL_IF_UTF8_MANIFEST_UNSUPPORTED,
allows the check for legacy systems to be skipped.
- An incompatibility with Windows XP in writeCon_utf8() has been
fixed.
See this GitHub issue for details:
https://github.com/skeeto/w64devkit/issues/315
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
It seems that the UTF-8 manifest can be adjusted to avoid binaries
failing to run on Windows XP.
Make the necessary adjustment. This doesn't affect the legacy
builds, only those with Unicode enabled. Nor does it change the
code which prevents Unicode builds from running on platforms
that don't support the manifest.
See this GitHub issue for details:
https://github.com/skeeto/w64devkit/issues/315
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The implementation of localtime(3) in the Microsoft Windows
runtime only accepts arguments between the Unix epoch (1970)
and either 2038 or 3000 for 32-bit or 64-bit systems respectively.
For values outside those limits it returns a NULL pointer.
Unfortunately, upstream BusyBox hardly ever bothers to check the
return value. Thus, when a call to stat(2) returned an all-zero
FILETIME for a file, the 'stat' applet failed. An all-zero FILETIME
represents a date in 1600, which is clearly before the Unix epoch.
Add a wrapper to localtime(3) which detects an out-of-range value
and returns a valid 'struct tm' for the Unix epoch. This is easier
than adding checks on the return value of every call to localtime(3).
Adds 32-48 bytes.
(GitHub issue #548)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It was found that 'mkdir -p --verbose C:/' incorrectly reported
that 'C:/' was created.
Commit 0e0b5e9ff8 (mingw.c: ignore EACCES from mkdir if directory
exists) fixed a failure to create directories but caused the
`mkdir` applet to issue the wrong diagnostic.
The underlying problem is in the Windows runtime implementation
of _mkdir(): it can return the wrong errno in some cases, EACCES
instead of EEXIST.
Having the mkdir(2) wrapper return the correct errno should fix
both the directory creation and verbose diagnostic problems.
The website referenced in the previous commit is no longer
available. archive.org has a copy:
https://web.archive.org/web/20150224075238/http://www.apijunkie.com/APIJunkie/blog/post/2009/12/22/_mkdir-C-runtime-library-function-might-return-unexpected-error-values.aspx
(GitHub issue #546)
|
| |
|
|
|
|
|
|
|
| |
Treat /dev/tty as an alias for Windows' 'con' device. The code
is similar to that used for /dev/null.
Adds 24-48 bytes.
(GitHub issue #538)
|
| |
|
|
|
| |
aterm.png: 2477 -> 2303 (-174 bytes)
sterm.png: 1022 -> 774 (-248 bytes)
|
| |
|
|
|
|
|
|
|
|
|
| |
Convert the icons to PNG format (by simply exporting them from
GIMP and selecting the 'Compressed (PNG)' chackbox). Allow these
to be selected instead of ICO format at build time.
Use the PNG icons by default in the Unicode and aarch64 builds.
Saves 26KB in those cases.
(GitHub PR #540)
|
| |
|
|
|
|
|
|
|
|
| |
It also makes the version number within the manifest use the version
macros, replacing the hard-coded "6.0.0.0".
Unicode: 32668 -> 32188 (-480 bytes)
non-Unicode: 32412 -> 31956 (-456 bytes)
with icons included.
|
| |
|
|
|
|
|
|
|
| |
Setting the console dimensions doesn't work reliably. Drop
support for the 'rows' and 'columns' settings.
Saves 752-768 bytes.
(GitHub issue #58)
|
| |
|
|
|
|
|
|
|
| |
Use the Gnulib implementation of flock(2) to allow the flock
applet to be enabled.
Costs 900-984 bytes.
(GitHub issue #528)
|
| |
|
|
|
|
|
|
|
| |
Use the (somewhat ancient) Microsoft RtlGenRandom() function to
provide random data for /dev/urandom.
Saves 176-240 bytes.
(GitHub issue #519)
|