there is slight difference between wctoutf8 and wcrtomb, wcrtomb
returns -1 if its presented with non valid char, of its char is not
presentable on current locale. I think wctoutf8 only returns positive
integers.
so your patch to strlower for example might introduce unreachable code path.
diff --git a/lib/lib.c b/lib/lib.c
index 6a4a77dd..79ae2a1d 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -426,7 +426,7 @@ char *strlower(char *s)
// if we had a valid utf8 sequence, convert it to lower case, and can't
// encode back to utf8, something is wrong with your libc. But just
// in case somebody finds an exploit...
- len = wcrtomb(new, c, 0);
+ len = wctoutf8(new, c);
if (len < 1) error_exit("bad utf8 %x", (int)c);
new += len;
On Wed, Apr 10, 2024 at 12:54 AM Oliver Webb via Toybox
<[email protected]> wrote:
>
> Not pulling in 2 localization functions (One from libc, one from lib.c)
> reduces executable
> size, also more portable on glibc systems because locale installation
> nonsense. No
> typecasting to int's either.
>
> 15 bytes saved in bloatcheck. tests pass for everything with changes applied
> (Except the shell).
>
> - Oliver Webb <[email protected]>
> _______________________________________________
> Toybox mailing list
> [email protected]
> http://lists.landley.net/listinfo.cgi/toybox-landley.net
-Jarno
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net