On 22/02/10 15:08, jema...@gnu.org wrote:
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)
Yes that's problematic
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)
That refactoring looks good. thanks, Pádraig.