[Toybox] [PATCH] Fix wcwidth(3) on Mac.

enh enh at google.com
Fri Nov 22 14:37:16 PST 2019


The Mac doesn't support "C.UTF-8" (and toybox ignores the setlocale(3)
failure), leading to numerous test failures because wcwidth(3)
always returns -1 for non-ASCII in the default C locale.

Our choices are:
1. Always use "" (the environment).
2. Always use "en_US.UTF-8" (the closest to "C.UTF-8" supported on Macs).
3. Continue to use "C.UTF-8" elsewhere but one of the above on Macs.

I've gone with #1 because it's the default advice for setlocale(3),
and it's probably closest to the user's intentions. Every OS I'm
aware of has $LANG set to <something>.UTF-8 these days, and has
done for a decade now.

Note though that we'd also need to change LC_CTYPE to LC_ALL if we
also want strerror(3) to be localized. For now, despite this
setlocale(3) call, you'll still get "C" locale error messages.

---
 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-wcwidth-3-on-Mac.patch
Type: application/octet-stream
Size: 1494 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20191122/afb603e6/attachment-0002.obj>


More information about the Toybox mailing list