Re: [PATCH] cfg.mk: Introduce rule for setlocale()

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

 



On 04.06.2014 18:21, Eric Blake wrote:
On 06/04/2014 03:15 AM, Martin Kletzander wrote:
On Wed, Jun 04, 2014 at 10:59:08AM +0200, Michal Privoznik wrote:
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@xxxxxxxxxx>
---
cfg.mk | 9 +++++++++
1 file changed, 9 insertions(+)


+# Require #include <locale.h> in all files that call setlocale()
+sc_require_locale_h:
+    @for i in $$($(VC_LIST_EXCEPT) | grep '\.[chx]$$'); do            \
+        if test -z "$$(grep setlocale $$i)" ; then continue; fi;    \

Why not:

if ! grep -q setlocale $$i; then continue; fi

Even simpler, let maint.mk do it for you:

sc_require_locale_h:
	@require='include.*locale\.h'		\
	containing='setlocale *('		\
	halt='setlocale() requires <locale.h>'	\
	  $(_sc_search_regexp)


This is the maint.mk-ism I was looking for. Feel free to replace my code. Just out of pure curiosity - is your code any faster?

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]