>> I am not sure if this is good way to check if ctags supports "-e" or not.
>>
>> + then ctags --version 2>&1 | grep -- -e >/dev/null
>>
>> Perhaps, "--help" might be intended rather than "--version" to check
>> supported options?
>
> Yeah, that was my mistake.
>
>> Even so, ctags would have other option whose name contains
>> "-e" than Emacs support, so this check could end in a wrong result.
>> Therefore,
>> it seems to me that it is better to check immediately if etags is available
>> in case that we don't have Exuberant-type ctags.
>
> That makes sense.
Attached is the v2 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..14089c5a7c 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,8 +30,10 @@ 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
@@ -36,6 +41,22 @@ 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
+ 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,16 @@ then IGNORE_IDENTIFIES="-I pg_node_attr+"
else IGNORE_IDENTIFIES=
fi
+if [ $PROG = "ctags" ]
+then TAGS_OPT="-a -f"
+else TAGS_OPT="-a -o"
+fi
+
# 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