unobfuscate cplus-dem.c

Marc Espie espie@quatramaran.ens.fr
Thu Apr 29 18:20:00 GMT 1999


In article < 199904291337.JAA07519@pincoya.inf.utfsm.cl > you write:
>Paul Eggert <eggert@twinsun.com> said:
>[...]
>
>> +/* Do not use the standard isdigit, since it's locale-dependent.  */
>> +#define isdigit(x) ((unsigned) (x) - '0' <= 9)
>
>Won't this break on EBCDIC or other non-ASCII encodings?

Current cplus-demangler will break on EBCDIC anyways, it contains comparisons
that look like c >= 'a' && c <= 'z' anyways.

I'm not too fond about worrying over locales in that context.  
Basic fact is, the C locale system is a mess.
If you use is*() functions, you may have to worry about locales unless you
control the whole program (since you start with the C locale anyways);
if you don't use them, you are going to fail on EBCDIC.

As far as the C++ demangler, I would tend to say there is next to nothing to
localize in that program... sanest way is to just use is*, document that these
functions only work in the C locale, and let the application programmer worry
about l10n.  Any program that tries to use the C++ demangler and other
functions related to code text, and doesn't bother changing to the C locale
before that is *broken*, in my opinion.

Then wait for ANSI/ISO to come up with a sane way to handle locales with 
respect to library functions, or for a new fangled configure to come up with
a magic way to handle that.


More information about the Gcc-patches mailing list