<feed xmlns='http://www.w3.org/2005/Atom'>
<title>busybox-w32/win32/actype.c, branch join2</title>
<subtitle>A mirror of https://github.com/rmyorston/busybox-w32.git
</subtitle>
<id>https://git.lua4.win/busybox-w32/atom?h=join2</id>
<link rel='self' href='https://git.lua4.win/busybox-w32/atom?h=join2'/>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/'/>
<updated>2026-04-18T09:27:47+00:00</updated>
<entry>
<title>Win32: trivial refinements (#577)</title>
<updated>2026-04-18T09:27:47+00:00</updated>
<author>
<name>avih</name>
<email>2164962+avih@users.noreply.github.com</email>
</author>
<published>2026-04-18T09:27:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=0495eb5c75d62fc574a8c5477f9196f0917f723d'/>
<id>urn:sha1:0495eb5c75d62fc574a8c5477f9196f0917f723d</id>
<content type='text'>
* 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 &lt;string.h&gt;" at actype.c, which we don't need anymore.

* scripts/patbench.sh: make executable (chmod +x)</content>
</entry>
<entry>
<title>win32: actype: remove size-optimization option (no-op)</title>
<updated>2026-04-16T09:42:13+00:00</updated>
<author>
<name>Avi Halachmi (:avih)</name>
<email>avihpit@yahoo.com</email>
</author>
<published>2026-04-13T15:24:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=35f5b03d2fa2d1884c25b9e4854ec293ea534d4d'/>
<id>urn:sha1:35f5b03d2fa2d1884c25b9e4854ec293ea534d4d</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>win32: actype: code shrink</title>
<updated>2026-04-16T09:42:13+00:00</updated>
<author>
<name>Avi Halachmi (:avih)</name>
<email>avihpit@yahoo.com</email>
</author>
<published>2026-04-12T22:09:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=9f1aec537dafda10c3f297b802eca348616bf288'/>
<id>urn:sha1:9f1aec537dafda10c3f297b802eca348616bf288</id>
<content type='text'>
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:]]'
</content>
</entry>
<entry>
<title>win32: actype/isactype: optimize both to O(1)</title>
<updated>2026-04-16T09:42:13+00:00</updated>
<author>
<name>Avi Halachmi (:avih)</name>
<email>avihpit@yahoo.com</email>
</author>
<published>2026-04-12T21:45:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=7c49824cb6137c05583a3ed343975114d12ff0a4'/>
<id>urn:sha1:7c49824cb6137c05583a3ed343975114d12ff0a4</id>
<content type='text'>
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".
</content>
</entry>
<entry>
<title>win32: add actype/isactype instead of match_class</title>
<updated>2026-04-16T09:42:13+00:00</updated>
<author>
<name>Avi Halachmi (:avih)</name>
<email>avihpit@yahoo.com</email>
</author>
<published>2026-03-25T13:12:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/busybox-w32/commit/?id=b9a1b0db1d7d455278611efb1d63c96675b15b67'/>
<id>urn:sha1:b9a1b0db1d7d455278611efb1d63c96675b15b67</id>
<content type='text'>
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.
</content>
</entry>
</feed>
