Skip to content

Commit 87f21d2

Browse files
committed
Fix make_etags failure on Mac.
Previously make_etags always ran make_ctags -e when make_etags was executed. However, because non-Exuberant ctags on Mac does not support -e option (and also on other platforms including old Linux), ctags failed. To avoid the failure change make_ctags so that if non-Exuberant ctags is used and ctags -e option is requested, run etags command instead. If etags command does not exist, make_ctags will fail. Also refactor make_ctags and tweak make_etags to emit proper usage message. Author: Fujii Masao Reviewed-by: Tatsuo Ishii Discussion: https://www.postgresql.org/message-id/369c13b9-8b0f-d6f9-58fc-61258ec8f713%40oss.nttdata.com
1 parent 3b12e68 commit 87f21d2

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

src/tools/make_ctags

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ then echo $usage
99
exit 1
1010
fi
1111

12-
MODE=
12+
EMACS_MODE=
1313
NO_SYMLINK=
14+
IS_EXUBERANT=
15+
PROG="ctags"
16+
TAGS_OPT="-a -f"
1417
TAGS_FILE="tags"
18+
FLAGS=
19+
IGNORE_IDENTIFIES=
1520

1621
while [ $# -gt 0 ]
1722
do
1823
if [ $1 = "-e" ]
19-
then MODE="-e"
20-
TAGS_FILE="TAGS"
24+
then EMACS_MODE="Y"
2125
elif [ $1 = "-n" ]
2226
then NO_SYMLINK="Y"
2327
else
@@ -27,15 +31,24 @@ do
2731
shift
2832
done
2933

30-
command -v ctags >/dev/null || \
34+
if [ ! "$EMACS_MODE" ]
35+
then (command -v ctags >/dev/null) || \
3136
{ echo "'ctags' program not found" 1>&2; exit 1; }
37+
fi
3238

33-
trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
34-
rm -f ./$TAGS_FILE
35-
36-
IS_EXUBERANT=""
3739
ctags --version 2>&1 | grep Exuberant && IS_EXUBERANT="Y"
3840

41+
if [ "$EMACS_MODE" ]
42+
then TAGS_FILE="TAGS"
43+
if [ "$IS_EXUBERANT" ]
44+
then PROG="ctags -e"
45+
else (command -v etags >/dev/null) || \
46+
{ echo "neither 'etags' nor exuberant 'ctags' program not found" 1>&2; exit 1; }
47+
PROG="etags"
48+
TAGS_OPT="-a -o"
49+
fi
50+
fi
51+
3952
# List of kinds supported by Exuberant Ctags 5.8
4053
# generated by ctags --list-kinds
4154
# --c-kinds was called --c-types before 2003
@@ -56,20 +69,23 @@ ctags --version 2>&1 | grep Exuberant && IS_EXUBERANT="Y"
5669

5770
if [ "$IS_EXUBERANT" ]
5871
then FLAGS="--c-kinds=+dfmstuv"
59-
else FLAGS="-dt"
72+
elif [ ! "$EMACS_MODE" ]
73+
then FLAGS="-dt"
6074
fi
6175

6276
# Use -I option to ignore a macro
6377
if [ "$IS_EXUBERANT" ]
6478
then IGNORE_IDENTIFIES="-I pg_node_attr+"
65-
else IGNORE_IDENTIFIES=
6679
fi
6780

81+
trap "ret=$?; rm -rf /tmp/$$; exit $ret" 0 1 2 3 15
82+
rm -f ./$TAGS_FILE
83+
6884
# this is outputting the tags into the file 'tags', and appending
6985
find `pwd`/ \( -name tmp_install -prune -o -name tmp_check -prune \) \
7086
-o \( -name "*.[chly]" -o -iname "*makefile*" -o -name "*.mk" -o -name "*.in" \
7187
-o -name "*.sql" -o -name "*.p[lm]" \) -type f -print |
72-
xargs ctags $MODE -a -f $TAGS_FILE "$FLAGS" "$IGNORE_IDENTIFIES"
88+
xargs $PROG $TAGS_OPT $TAGS_FILE $FLAGS $IGNORE_IDENTIFIES
7389

7490
# Exuberant tags has a header that we cannot sort in with the other entries
7591
# so we skip the sort step

src/tools/make_etags

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/sh
2-
# src/tools/make_etags
2+
3+
# src/tools/make_etags [-n]
4+
5+
if [ $# -gt 1 ] || ( [ $# -eq 1 ] && [ $1 != "-n" ] )
6+
then echo "Usage: $0 [-n]"
7+
exit 1
8+
fi
39

410
cdir=`dirname $0`
511
dir=`(cd $cdir && pwd)`

0 commit comments

Comments
 (0)