]> xenbits.xensource.com Git - libvirt.git/commitdiff
cfg.mk: Introduce rule for setlocale()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 4 Jun 2014 08:57:21 +0000 (10:57 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 4 Jun 2014 09:56:14 +0000 (11:56 +0200)
In the past we had some issues where setlocale() was called without
corresponding include of locale.h. While on some systems this may
work, on others the compilation failed. We should have a syntax-check
rule for that to prevent this from happening again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
cfg.mk

diff --git a/cfg.mk b/cfg.mk
index 9e8fceced8244163c1b771139264970830bb31eb..675af21fcab3b41ecadf89600de3df25b5d69596 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -929,6 +929,15 @@ sc_prohibit_mixed_case_abbreviations:
        halt='Use PCI, USB, SCSI, not Pci, Usb, Scsi'   \
          $(_sc_search_regexp)
 
+# Require #include <locale.h> in all files that call setlocale()
+sc_require_locale_h:
+       @for i in $$($(VC_LIST_EXCEPT) | grep '\.[chx]$$'); do                  \
+               if ! grep -q setlocale\( $$i ; then continue; fi ;              \
+               if ! grep -q '# *include <locale.h>' $$i ; then                 \
+                       echo '$(ME): missing locale.h include in' $$i 1>&2; exit 1;     \
+               fi;                                                                                                                     \
+       done;
+
 # We don't use this feature of maint.mk.
 prev_version_file = /dev/null