From 3c774c5eb56ee1c538d9f153d941dd4596de2db3 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Tue, 24 Jul 2012 19:25:02 +0200 Subject: [PATCH] tags: refactor to reduce code duplication (1) No semantic change is intended. * lib/am/tags.am (am__uniquify_input): New variable, factor out some code common to ... (ctags-am, tags-am, ID): ... the recipes of these targets. Signed-off-by: Stefano Lattarini --- lib/am/tags.am | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/am/tags.am b/lib/am/tags.am index 26a9f13e4..28338a72e 100644 --- a/lib/am/tags.am +++ b/lib/am/tags.am @@ -14,6 +14,15 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' + ## ---- ## ## ID. ## ## ---- ## @@ -24,9 +33,7 @@ ID: $(am__tagged_files) unique=`for i in $$list; do \ ## Handle VPATH correctly. if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ + done | $(am__uniquify_input)`; mkid -fID $$unique @@ -75,9 +82,7 @@ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) unique=`for i in $$list; do \ ## Handle VPATH correctly. if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ + done | $(am__uniquify_input)`; \ ## Remove the 'x' we added first: shift; \ ## Make sure we have something to run etags on. @@ -114,9 +119,7 @@ ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) unique=`for i in $$list; do \ ## Handle VPATH correctly. if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ + done | $(am__uniquify_input)`; \ ## Make sure we have something to run ctags on. test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ -- 2.47.2