From: Eric Blake Date: Thu, 31 Mar 2011 02:26:27 +0000 (-0600) Subject: maint: avoid locale-sensitivity in string case comparisons X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=6c9e89bbd2ff78fdbf0a6e7ba88d604b2da655c8;p=libvirt.git maint: avoid locale-sensitivity in string case comparisons 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. * bootstrap.conf (gnulib_modules): Drop strcasestr, add c-strcase and c-strcasestr. * cfg.mk (sc_avoid_strcase): New rule. (exclude_file_name_regexp--sc_avoid_strcase): New exception. * src/internal.h (STRCASEEQ, STRCASENEQ, STRCASEEQLEN) (STRCASENEQLEN): Adjust offenders. * src/qemu/qemu_monitor_text.c (qemuMonitorTextEjectMedia): Likewise. * tools/virsh.c (namesorter): Document exception. --- diff --git a/.gnulib b/.gnulib index 422ab2e0d7..790645d837 160000 --- a/.gnulib +++ b/.gnulib @@ -1 +1 @@ -Subproject commit 422ab2e0d70ed348e2fd0a82558be38e5859011a +Subproject commit 790645d837f8084991421107fba639b110d58335 diff --git a/bootstrap.conf b/bootstrap.conf index 6e10828814..733c3541c7 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -22,6 +22,8 @@ gnulib_modules=' areadlink base64 c-ctype +c-strcase +c-strcasestr canonicalize-lgpl chown close @@ -63,7 +65,6 @@ sigpipe snprintf socket stpcpy -strcasestr strchrnul strndup strerror diff --git a/cfg.mk b/cfg.mk index ac419f74a8..f802cee494 100644 --- a/cfg.mk +++ b/cfg.mk @@ -349,6 +349,11 @@ sc_avoid_ctype_macros: halt="don't use ctype macros (use c-ctype.h)" \ $(_sc_search_regexp) +sc_avoid_strcase: + @prohibit='\bstrn?case(cmp|str) *\(' \ + halt="don't use raw strcase functions (use c-strcase instead)" \ + $(_sc_search_regexp) + sc_prohibit_virBufferAdd_with_string_literal: @prohibit='\