jema...@gnu.org wrote: ... > I suggest to use the following solution that works properly in all > cases while avoiding the code duplication (in the spirit of > _prohibit_regexp):
Good idea. > 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: } || : \ There is a missing "fi" here, and various trailing semicolons. Please factor out the duplicated echo line so it appears just once. Also, of course, s/exit1:/exit 1;/ if you use the latter "copy". Thanks! > 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) > > ...