exit 1
fi
-MODE=
+EMACS_MODE=
NO_SYMLINK=
+IS_EXUBERANT=
+PROG="ctags"
+TAGS_OPT="-a -f"
TAGS_FILE="tags"
+FLAGS=
+IGNORE_IDENTIFIES=
while [ $# -gt 0 ]
do
if [ $1 = "-e" ]
- then MODE="-e"
- TAGS_FILE="TAGS"
+ then EMACS_MODE="Y"
elif [ $1 = "-n" ]
then NO_SYMLINK="Y"
else
shift
done
-command -v ctags >/dev/null || \
+if [ ! "$EMACS_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"
+if [ "$EMACS_MODE" ]
+then TAGS_FILE="TAGS"
+ if [ "$IS_EXUBERANT" ]
+ then PROG="ctags -e"
+ else (command -v etags >/dev/null) || \
+ { echo "neither 'etags' nor exuberant 'ctags' program not found" 1>&2; exit 1; }
+ PROG="etags"
+ TAGS_OPT="-a -o"
+ fi
+fi
+
# List of kinds supported by Exuberant Ctags 5.8
# generated by ctags --list-kinds
# --c-kinds was called --c-types before 2003
if [ "$IS_EXUBERANT" ]
then FLAGS="--c-kinds=+dfmstuv"
-else FLAGS="-dt"
+elif [ ! "$EMACS_MODE" ]
+then FLAGS="-dt"
fi
# Use -I option to ignore a macro
if [ "$IS_EXUBERANT" ]
then IGNORE_IDENTIFIES="-I pg_node_attr+"
-else IGNORE_IDENTIFIES=
fi
+trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
+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 $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