automake-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Fix TAGS and GTAGS rules to cope with whitespace in `pwd`.


From: Ralf Wildenhues
Subject: Re: [PATCH] Fix TAGS and GTAGS rules to cope with whitespace in `pwd`.
Date: Mon, 26 Nov 2007 20:30:40 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

* Ralf Wildenhues wrote on Sun, Nov 25, 2007 at 07:23:29PM CET:
> * lib/am/tags.am (TAGS): Use positional parameters to avoid
> the need to quote absolute file names.
> (GTAGS): Quote absolute file name.
> (CTAGS): Simplify, dropping unused variable `$tags'.

>  ## Make sure we have something to run etags on.
> -     if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
> +     if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
>         test -n "$$unique" || unique=$$empty_fix; \
>         $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
> -         $$tags $$unique; \
> +         "$$@" $$unique; \

Hmm, if there are no positional parameters, old shells will expand to ""
here, so we need to distinguish between that.

>       fi

Applied like this.

Cheers,
Ralf

  Fix TAGS and GTAGS rules to cope with whitespace in `pwd`.

  * lib/am/tags.am (TAGS): Use positional parameters to avoid
  the need to quote absolute file names.
  (GTAGS): Quote absolute file name.
  (CTAGS): Simplify, dropping unused variable `$tags'.

diff --git a/lib/am/tags.am b/lib/am/tags.am
index b3cfe6f..7900a5e 100644
--- a/lib/am/tags.am
+++ b/lib/am/tags.am
@@ -43,7 +43,9 @@ tags: TAGS
 
 TAGS: %TAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
                $(TAGS_FILES) $(LISP)
-       tags=; \
+## We use the positional parameters to build the subdir list with
+## absolute names, without the need to worry about white space in `pwd`.
+       set x; \
        here=`pwd`; \
 ## It is tempting to use if/endif here, but don't: the previous
 ## backslash will cause bad results (automake doesn't `see' the `if').
@@ -64,7 +66,7 @@ TAGS: %TAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% 
$(TAGS_DEPENDENCIES) \
 ?SUBDIRS?        if test "$$subdir" = .; then :; else \
 ?SUBDIRS?          test ! -f $$subdir/TAGS || \
 ## Note that the = is mandatory for --etags-include.
-?SUBDIRS?            tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+?SUBDIRS?            set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 ?SUBDIRS?        fi; \
 ?SUBDIRS?      done; \
 ## Make sure the list of sources is unique.
@@ -75,11 +77,18 @@ TAGS: %TAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% 
$(TAGS_DEPENDENCIES) \
          done | \
          $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
              END { if (nonempty) { for (i in files) print i; }; }'`; \
+## Remove the `x' we added first:
+       shift; \
 ## Make sure we have something to run etags on.
-       if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
          test -n "$$unique" || unique=$$empty_fix; \
-         $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-           $$tags $$unique; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
        fi
 
 
@@ -96,7 +105,6 @@ ctags: CTAGS
 ## dependencies here are useless.
 CTAGS: %CTAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% $(TAGS_DEPENDENCIES) \
                $(TAGS_FILES) $(LISP)
-       tags=; \
 ## Make sure the list of sources is unique.
        list='$(SOURCES) $(HEADERS) %CONFIG% $(LISP) $(TAGS_FILES)'; \
        unique=`for i in $$list; do \
@@ -106,9 +114,9 @@ CTAGS: %CTAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% 
$(TAGS_DEPENDENCIES) \
          $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
              END { if (nonempty) { for (i in files) print i; }; }'`; \
 ## Make sure we have something to run ctags on.
-       test -z "$(CTAGS_ARGS)$$tags$$unique" \
+       test -z "$(CTAGS_ARGS)$$unique" \
          || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-            $$tags $$unique
+            $$unique
 
 
 ## --------------- ##
@@ -119,7 +127,7 @@ CTAGS: %CTAGSDIRS% $(HEADERS) $(SOURCES) %CONFIG% 
$(TAGS_DEPENDENCIES) \
 GTAGS:
        here=`$(am__cd) $(top_builddir) && pwd` \
          && cd $(top_srcdir) \
-         && gtags -i $(GTAGS_ARGS) $$here
+         && gtags -i $(GTAGS_ARGS) "$$here"
 
 
 ## ---------- ##




reply via email to

[Prev in Thread] Current Thread [Next in Thread]