[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11786: Use c_strcasecmp for portable ASCII case-insensitive comparis

From: Eli Zaretskii
Subject: bug#11786: Use c_strcasecmp for portable ASCII case-insensitive comparison
Date: Tue, 26 Jun 2012 19:02:20 +0300

> Date: Mon, 25 Jun 2012 18:42:08 -0700
> From: Paul Eggert <address@hidden>
> Emacs currently use 'strcasecmp' and 'strncasecmp' for
> case-insensitive comparison but these have problems in multibyte
> locales.  In practice Emacs code really just wants a C-locale
> version of these functions so I'm planning on installing the
> following patch after some more testing.  I'm giving some
> heads-up as this affects the Microsoft ports.

Not related to "Microsoft ports", but can we please step back one
notch and discuss this stuff in a little bit more detail?

First, until revision 108735, committed yesterday by Dmitry, we didn't
use strcasecmp or strncasecmp (except in the NS port, which looks like
an oversight).  We used xtrcasecmp, whose only dependence on the
locale is the tolower function/macro.  Then Dmitry replaced
xstrcasecmp with strcasecmp for those platforms that have it (which I
think means all the supported platforms), for reasons that AFAIK were
never discussed.  Why was that done?

Now you are going to replace strcasecmp with several gnulib modules.

All the calls to xtrcasecmp are for comparing strings that are known
to be plain ASCII: names of fonts, extensions of certain file types,
fixed ASCII strings, etc.  Can tolower fail for these, somehow, in a
locale that uses a multibyte encoding for these strings, and if so,
can you give a practical example of such a failure?

If tolower is good enough for these cases, I suggest that we revert
changes in revision 108735, and perhaps add comments somewhere as to
the reasons why we use that custom function instead of library

If tolower can fail in some locale, I suggest that we restore
xstrcasecmp, and simply augment it with c_tolower from gnulib, or its
equivalent.   That sounds like a much simpler change to me.

Comments are welcome.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]