>> Attached is the v2 patch. > > Thanks for the patch! > > With the patch, I got the following error when executing make_etags.. > > $ ./src/tools/make_etags > etags: invalid option -- 'e' > Try 'etags --help' for a complete list of options. > sort: No such file or directory
Oops. Thank you for pointing it out. BTW, just out of curiosity, do you have etags on you Mac? Mine doesn't have etags. That's why I missed the error. > + if [ $? != 0 -a -z "$ETAGS_EXISTS" ] > + then echo "'ctags' does not support emacs mode and etags does not > exist" 1>&2; exit 1 > + fi > > This code can be reached after "rm -f ./$TAGS_FILE" is executed in > make_ctags. > But we should check whether the required program has been already > installed > and exit immediately if not, before modifying anything? Agreed. > This is the comment for the commit d1e2a380cb. I found that make_etags > with > an invalid option reported the following usage message mentioning > make_ctags > (not make_etags). Isn't this confusing? > > $ ./src/tools/make_etags -a > Usage: /.../make_ctags [-e][-n] That's hard to fix without some code duplication. We decided that make_etags is not a symlink to make_ctags, rather execs make_ctags. Of course we could let make_etags perform the same option check, but I doubt it's worth the trouble. Anyway, attached is the v3 patch. Best reagards, -- Tatsuo Ishii SRA OSS LLC English: http://www.sraoss.co.jp/index_en/ Japanese:http://www.sraoss.co.jp
diff --git a/src/tools/make_ctags b/src/tools/make_ctags index 102881667b..38f4d8e2d5 100755 --- a/src/tools/make_ctags +++ b/src/tools/make_ctags @@ -12,12 +12,15 @@ fi MODE= NO_SYMLINK= TAGS_FILE="tags" +ETAGS_EXISTS= +PROG=ctags while [ $# -gt 0 ] do if [ $1 = "-e" ] then MODE="-e" TAGS_FILE="TAGS" + command -v etags >/dev/null && ETAGS_EXISTS="Y" elif [ $1 = "-n" ] then NO_SYMLINK="Y" else @@ -27,15 +30,33 @@ do shift done -command -v ctags >/dev/null || \ +if test -z "$MODE" +then (command -v ctags >/dev/null) || \ { echo "'ctags' program not found" 1>&2; exit 1; } +fi trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15 -rm -f ./$TAGS_FILE IS_EXUBERANT="" ctags --version 2>&1 | grep Exuberant && IS_EXUBERANT="Y" +# ctags is not exuberant and emacs mode is specified +if [ -z "$IS_EXUBERANT" -a -n "$MODE" ] +then + if [ -n "$ETAGS_EXISTS" ] + then + # etags exists. Use it. + PROG=etags + MODE= + else ctags --help 2>&1 | grep -- -e >/dev/null + # Note that "ctags --help" does not always work. Even certain ctags does not have the option. + # In that case we assume that the ctags does not support emacs mode. + if [ $? != 0 -a -z "$ETAGS_EXISTS" ] + then echo "'ctags' does not support emacs mode and etags does not exist" 1>&2; exit 1 + fi + fi +fi + # List of kinds supported by Exuberant Ctags 5.8 # generated by ctags --list-kinds # --c-kinds was called --c-types before 2003 @@ -65,11 +86,19 @@ then IGNORE_IDENTIFIES="-I pg_node_attr+" else IGNORE_IDENTIFIES= fi +if [ $PROG = "ctags" ] +then TAGS_OPT="-a -f" +else TAGS_OPT="-a -o" + FLAGS= +fi + +rm -f ./$TAGS_FILE + # this is outputting the tags into the file 'tags', and appending find `pwd`/ \( -name tmp_install -prune -o -name tmp_check -prune \) \ -o \( -name "*.[chly]" -o -iname "*makefile*" -o -name "*.mk" -o -name "*.in" \ -o -name "*.sql" -o -name "*.p[lm]" \) -type f -print | - xargs ctags $MODE -a -f $TAGS_FILE "$FLAGS" "$IGNORE_IDENTIFIES" + xargs $PROG $MODE $TAGS_OPT $TAGS_FILE "$FLAGS" "$IGNORE_IDENTIFIES" # Exuberant tags has a header that we cannot sort in with the other entries # so we skip the sort step