[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch] Avoid some of the sc_ rules to freeze
From: |
jemarch |
Subject: |
Re: [patch] Avoid some of the sc_ rules to freeze |
Date: |
Mon, 22 Feb 2010 16:08:55 +0100 |
User-agent: |
Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.1.91 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) |
Would it be better to just add /dev/null as a parameter to grep?
I.E. like:
@grep -nE 'error \(EXIT_SUCCESS,' \
$$($(VC_LIST_EXCEPT) /dev/null | grep -E '\.[chly]$$')&& \
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; exit 1; } || :
The grep freezing is the top-level one, not the one matching the
.[chly] files. It would be:
@grep -nE 'error \(EXIT_SUCCESS,' \
$$($(VC_LIST_EXCEPT) | grep -E '\.[chly]$$') < /dev/null && \
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; exit 1; } || :
But consider the sc_ rules that are searching files not containing a
given pattern:
sc_program_name:
files=$$(grep -l '^main *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$'));
\
grep -LE 'set_program_name *\(m?argv\[0\]\);' $$files < /dev/null
\
| grep . &&
\
{ echo '$(ME): the above files do not call set_program_name'
\
1>&2; exit 1; } || :;
In that case the grep uses the -L option, and the effect of using the
redirection from /dev/null is:
$ make sc_program_name
program_name
(standard input)
I suggest to use the following solution that works properly in all
cases while avoiding the code duplication (in the spirit of
_prohibit_regexp):
define _sc_maybe_matching_files
dummy=; : so we do not need a semicolon before each use; \
test "x$$re" != x || { echo '$(ME): re not defined' 1>&2; exit 1; }; \
if test -n "$$matching"; then matching='yes'; fi \
files=$$($(VC_LIST_EXCEPT) | grep -E "$$fre"); \
if test -n "$$files"; then \
if test "$$matching" = "yes"; then \
grep -nE "$$re" $$files && \
{echo "$(ME): $$msg" 1>&2; exit 1; } || : \
else \
grep -LE "$$re" $$files | grep . && \
{echo "$(ME): $$msg" 1>&2; exit1: } || : \
else :; \
fi
endef
define _sc_matching_files
matching='yes' \
$(_sc_maybe_matching_files)
endef
define _sc_non_matching_files \
matching='no' \
$(_sc_maybe_matching_files)
endef
sc_error_exit_success:
@fre='\.[chly]$$' \
re='error \(EXIT_SUCCESS,' \
msg='$(ME): found error (EXIT_SUCCESS' \
$(_sc_matching_files)
sc_program_name:
@fre='\.c$$' \
re='set_program_name *\(m?argv\[0\]\);' \
msg='$(ME): the above files do not call set_program_name' \
$(_sc_non_matching_files)
...
- [patch] Avoid some of the sc_ rules to freeze, jemarch, 2010/02/21
- Re: [patch] Avoid some of the sc_ rules to freeze, Pádraig Brady, 2010/02/22
- Re: [patch] Avoid some of the sc_ rules to freeze, Jim Meyering, 2010/02/22
- Re: [patch] Avoid some of the sc_ rules to freeze, Eric Blake, 2010/02/22
- Re: [patch] Avoid some of the sc_ rules to freeze,
jemarch <=
- Re: [patch] Avoid some of the sc_ rules to freeze, Pádraig Brady, 2010/02/22
- Re: [patch] Avoid some of the sc_ rules to freeze, Jim Meyering, 2010/02/22
- Re: [patch] Avoid some of the sc_ rules to freeze, jemarch, 2010/02/22
- Re: [patch] Avoid some of the sc_ rules to freeze, jemarch, 2010/02/25
- Re: [patch] Avoid some of the sc_ rules to freeze, Eric Blake, 2010/02/25