[libvirt] [PATCH] maint: avoid locale-sensitivity in string case comparisons

Eric Blake eblake at redhat.com
Thu Mar 31 12:01:14 UTC 2011


On 03/30/2011 10:44 PM, Daniel Veillard wrote:
> On Wed, Mar 30, 2011 at 08:29:53PM -0600, Eric Blake wrote:
>> strcase{cmp/str} have the drawback of being sensitive to the global
>> locale; this is unacceptable in a library setting.  Prefer a
>> hard-coded C locale alternative for all but virsh, which is user
>> facing and where the global locale isn't changing externally.
>>
>> * .gnulib: Update to latest, for c-strcasestr change.

>> +++ b/tools/virsh.c
>> @@ -432,6 +432,7 @@ static int namesorter(const void *a, const void *b) {
>>    const char **sa = (const char**)a;
>>    const char **sb = (const char**)b;
>>
>> +  /* User visible sort, so we want locale-specific case comparison.  */
>>    return strcasecmp(*sa, *sb);

Hmm, maybe strcoll would be better, but that has undefined behavior if
not all strings have valid encodings.  It's a perfect fit for gnulib's
mbmemcasecoll module, except that it is GPL with no chance of being
relaxed (that really is a value-added function that goes way beyond libc
basics).  And while virsh could link with GPL stuff, I'm not ready to
deal with the hassle of two gnulib-tool invocations (lgpl for the
library, gpl for virsh).  So I'm fine with keeping strcasecmp for now.

> 
>   ACK

Thanks; pushed.

I've got one more gnulib update coming later today which should fix the
non-blocking pipe fd problem for mingw.

Oh, and I realized I forgot to list the gnulib commits being pulled in
by this change:

* .gnulib 422ab2e...790645d (47):
  > stdio: Avoid GCC >= 4.4 warnings when using %lld and similar on mingw.
  > passfd: fix scoping bug
  > passfd: standardize coding conventions
  > passfd: fix incorrect sendmsg arguments
  > c-strcasestr: Relicense under LGPLv2+.
  > doc: update users.txt
  > tests: readlink* ("",... fails with EINVAL on newer kernels
  > Relicense some modules under LGPLv2+, for libidn2.
  > lib-symbol-visibility: Add a notice.
  > autoupdate
  > getaddrinfo: Doc fix.
  > getaddrinfo: Doc fix.
  > unictype/property-byname: Reduce the number of load-time relocations.
  > unictype/property-byname: Allow omitted word separators and aliases.
  > unictype/joininggroup-byname: Allow hyphens, omitted word separators.
  > unictype/joiningtype-byname: Recognize long names as well.
  > Tests for module 'unictype/joiningtype-longname'.
  > New module 'unictype/joiningtype-longname'.
  > unictype/bidiclass-byname: Recognize long names as well.
  > Tests for module 'unictype/bidiclass-longname'.
  > New module 'unictype/bidiclass-longname'.
  > unictype/bidi*: Rename modules, part 2.
  > unictype/bidi*: Rename modules.
  > unictype/bidi*: Rename functions, part 2.
  > New module 'unictype/combining-class-all'.
  > Tests for module 'unictype/combining-class-byname'.
  > New module 'unictype/combining-class-byname'.
  > Tests for module 'unictype/combining-class-longname'.
  > New module 'unictype/combining-class-longname'.
  > Tests for module 'unictype/combining-class-name'.
  > New module 'unictype/combining-class-name'.
  > unictype/combining-class: Rename source files.
  > unictype: Update list of canonical combining classes.
  > unictype/category-byname: Recognize long names as well.
  > Tests for module 'unictype/category-longname'.
  > New module 'unictype/category-longname'.
  > New module 'unictype/category-LC', part 2.
  > Tests for module 'unictype/category-LC'.
  > New module 'unictype/category-LC'.
  > xmalloc: revert yesterday's regression
  > maint.mk: add missing version to VC-tag
  > valgrind: do leak checking, and exit with code 1 on error (not 0)
  > posix-modules: say what it does.
  > xmalloc: Do not leak if underlying realloc is C99 compatible.
  > realloc: document portability problem
  > autoupdate
  > doc: add cvsps and tmpwatch to users.txt

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110331/d652f9b9/attachment-0001.sig>


More information about the libvir-list mailing list