Paul Eggert wrote:
> I thought programs in macOS etc. start off in the "C" locale, 
> and that this locale uses UTF-8.

Yes, I was focused on macOS etc. too. But the same problem exists
also on GNU systems; therefore it is better to think about these
systems in the first place, and about macOS etc. only later.

> I'd like to avoid the use of setlocale even in these environments, if 
> possible, as gzip is supposed to be small and "primitive".

If you are worried about startup time, one possibility is to delay
the   setlocale (LC_CTYPE, "")   invocation until just before each
diagnostic.

> But I agree 
> that the behavior in current master is bad. I'll try to think of a 
> better solution.

The way it's done in all other packages that use quotearg (e.g. coreutils)
is a reasonable one. 'echo' is "small and primitive" as well, and still
uses setlocale:

$ nm -D /bin/echo | grep ' U '
                 U abort@GLIBC_2.2.5
                 U __assert_fail@GLIBC_2.2.5
                 U bindtextdomain@GLIBC_2.2.5
                 U calloc@GLIBC_2.2.5
                 U __ctype_b_loc@GLIBC_2.3
                 U __ctype_get_mb_cur_max@GLIBC_2.2.5
                 U __cxa_atexit@GLIBC_2.2.5
                 U dcgettext@GLIBC_2.2.5
                 U __errno_location@GLIBC_2.2.5
                 U _exit@GLIBC_2.2.5
                 U exit@GLIBC_2.2.5
                 U fclose@GLIBC_2.2.5
                 U fcntl@GLIBC_2.2.5
                 U fflush@GLIBC_2.2.5
                 U fflush_unlocked@GLIBC_2.2.5
                 U fileno@GLIBC_2.2.5
                 U __fpending@GLIBC_2.2.5
                 U __fprintf_chk@GLIBC_2.3.4
                 U fputc_unlocked@GLIBC_2.2.5
                 U fputs_unlocked@GLIBC_2.2.5
                 U __freading@GLIBC_2.2.5
                 U free@GLIBC_2.2.5
                 U fseeko@GLIBC_2.2.5
                 U fwrite_unlocked@GLIBC_2.2.5
                 U getenv@GLIBC_2.2.5
                 U iswprint@GLIBC_2.2.5
                 U __libc_start_main@GLIBC_2.34
                 U lseek@GLIBC_2.2.5
                 U malloc@GLIBC_2.2.5
                 U mbrtoc32@GLIBC_2.16
                 U mbsinit@GLIBC_2.2.5
                 U memcmp@GLIBC_2.2.5
                 U memcpy@GLIBC_2.14
                 U memset@GLIBC_2.2.5
                 U nl_langinfo@GLIBC_2.2.5
                 U __overflow@GLIBC_2.2.5
                 U __printf_chk@GLIBC_2.3.4
                 U realloc@GLIBC_2.2.5
                 U setlocale@GLIBC_2.2.5
                 U strchr@GLIBC_2.2.5
                 U strcmp@GLIBC_2.2.5
                 U strcspn@GLIBC_2.2.5
                 U strerror_r@GLIBC_2.2.5
                 U strlen@GLIBC_2.2.5
                 U strncmp@GLIBC_2.2.5
                 U strrchr@GLIBC_2.2.5
                 U strspn@GLIBC_2.2.5
                 U textdomain@GLIBC_2.2.5
                 U __vfprintf_chk@GLIBC_2.3.4

Bruno






Reply via email to