Re: stumped on a simple autoconf/m4/sh problem

"G. Branden Robinson" <[email protected]> Mon, 2 Dec 2024 15:15:53 -0600
Newsgroups gmane.comp.printing.groff.general,gmane.comp.sysutils.autoconf.general
Message-ID <20241202211553.ajwxptxjpzw6hbuq@illithid>
At 2024-12-02T12:55:02-0800, Paul Eggert wrote:
> On 2024-12-02 12:26, G. Branden Robinson wrote:
> > > Why shouldn't the test succeed? Solaris 10 /usr/bin/tr supports
> > > character classes like [:cntrl:].
> > It doesn't for me in the instance at gcc210.fsffrance.org.
> 
> It works for me there:
> 
>   $ uname -a
>   SunOS gcc-solaris10 5.10 Generic_Virtual sun4u sparc SUNW,SPARC-Enterprise
>   $ printf 'a\003b\n' | /usr/bin/tr '[:cntrl:]' '[ *]'
>   a b $
> 
> Solaris 10 /usr/bin/tr has trouble in multibyte locales. Perhaps
> that's your problem? 'configure' should set LC_ALL=C early on, though,
> so if this is your problem it suggests that part of your script is
> messing with the locale, when it shouldn't be.

You've put your finger on the problem!

$ locale
LANG=C
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_ALL=

However, none of my .profile, .bashrc, or .bash_profile manipulate any
locale variables.  I'm guessing ssh(1) is responsible.

This also explains why the test of `tr` behavior _passes_ when I run the
configure script, but fails when I try it at the shell prompt.

bash-3.2$ export LC_ALL=C
bash-3.2$ printf 'a\tb' | tr '[:cntrl:]' '[ *]'
a bbash-3.2$

Interestingly, if you misspell the character class (_only_ in the C
locale), you get a more helpful diagnostic--the program at least
discloses who's talking.

bash-3.2$ printf 'a\tb' | tr '[:ctrl:]' '[ *]'
tr: Bad string between [ and ].

It's still not brilliant (it could at least tell you which of the two
mandatory arguments is defective).

But what really impresses me is how someone stuck this diagnostic in at
some point, but didn't go fix this instance as part of the deal:

$ printf 'a\tb' | LC_ALL=en_US.UTF-8 tr '[:cntrl:]' '[ *]'
Bad string

That's some rock star programming, there.  Why they get the big bucks.

> I installed the attached doc patch into Autoconf master to document
> more of the tr issues.

Thanks!  I have some revisions to make to groff to work around this
misfortune.  And it looks like maybe I can get away without a new
Autoconf macro after all.  This time.  :)

I appreciate the sleuthing and Autoconf macro writing advice.

Regards,
Branden
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEh3PWHWjjDgcrENwa0Z6cfXEmbc4FAmdOI4IACgkQ0Z6cfXEm
bc6H7RAAjBarR3+fN371XmmPhCG9b5AW74bV8ze0YcxQ5I6keeBeMCC+RaYpF4da
peUDKC0U7GdNVoUWZlGTjQrDwH199IFDLixie/PV8dI3Sw2Am5Ypt6fdAAHcBvvb
pEm+WZ5k6gcWqClKLXDvqO/4UkgeWVqsgaoDwxOJcu3FqdWNLWvaXYlfkbnLe/7M
fgVPjZ4JeZU97dgQqlPsMlGdrQuawc3ZDotEg8f2k5kpAkmlfiDMUvNzKzTaqLvp
ZlL4+CwcXE/nLY6YtItXQSnTUHi0RsIsMx0B0clpJoQcsrnA0klwDr96M5K1AHAF
E4XPWnEqKpW1TmiOj4UIXAQqG5Mm4HZWIO3Oe/XjfKPDE2TFm2oxBArlRvtZE6jo
Lui7WVXCV6R3TeWbs8nxFCtd6g3UxAlAfIkrtKIK5AdjaM4QPxLGpcjsOolZrvBF
wt7XBSPB5BjStFf+BelXTuA6xYJAHTS1QGHuOvB9VluqMOFaLSUO9tnRSy4BFtPj
p8LpBwY5yjGFK7Ceup3/iyyj2hqb7QPjFJZmHGNEdng9BryXt1nJu2c2bhuenGqk
tu6XMBrOOf7cqkurhriY0uiDgFnsz2px9koUPlJKHvFmovvXhgganZmYO2Ln+2d3
genn5s9quAX+43Qjpr6INS4zT4B26kGv5vHaEj9QXQn7s4zUyO8=
=a/ES
-----END PGP SIGNATURE-----