Commit | Line | Data |
3ee700d1 |
1 | # Make a TAGS file for emacs ``M-x find-tag'' from all <c,h,y,xs> source files. |
2 | # (``make realclean'' first to avoid generated files, or ``make'' first |
3 | # to get tags from all files.) |
4 | # |
5 | # (IZ: to be a happier jumper: install 'imenu-go.el' from |
6 | # ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs.) |
7 | # |
8 | # (Some tags should probably live in their own subdirs, like those in x2p/, |
9 | # but I have never been interested in x2p anyway.) |
10 | # |
11 | # Hallvard B Furuseth <h.b.furuseth@usit.uio.no>, Aug -96. |
12 | # |
13 | # Ilya Zakharevich, Oct 97: minor comments, add CPerl scan; |
14 | # Use Hallvard's scan for XS files - since he processes the "C" part too - |
15 | # but with a lot of improvements: now it is no worse than CPerl's one. |
16 | |
777e9161 |
17 | # Avoid builtin on OS/2: |
3ee700d1 |
18 | if test ! -z "$OS2_SHELL"; then alias find=gnufind; fi |
19 | |
ea544449 |
20 | emacs=`(which emacs || which xemacs) 2>/dev/null` |
21 | [ -x "$emacs" ] || { echo "can't find emacs or xemacs in PATH"; exit 1; } |
22 | |
3ee700d1 |
23 | # Insure proper order (.h after .c, .xs before .c in subdirs): |
777e9161 |
24 | # Move autogenerated less-informative files to the end: |
25 | # Hard to do embed.h and embedvar.h in one sweep: |
26 | |
622913ab |
27 | topfiles="`echo ' ' *.y *.c *.h ' ' | sed 's/ / /g' | sed 's/ embedvar\.h\|embed\.h\|perlapi\.h\|os2ish\.h\|\(globals\|perlapi\| os2\)\.c / /g'`" |
3625ddea |
28 | subdirs="`find ./* -maxdepth 0 -type d`" |
29 | subdirfiles="`find $subdirs -name '*.[cy]' -print | sort`" |
30 | subdirfiles1="`find $subdirs -name '*.[hH]' -print | sort`" |
3ee700d1 |
31 | xsfiles="`find . -name '*.xs' -print | sort`" |
32 | |
777e9161 |
33 | # etags -d : process defines too (default now) |
3ee700d1 |
34 | |
35 | # These are example lines for global variables and PP-code: |
36 | ## IEXT SV * Iparsehook; |
37 | ## IEXT char * Isplitstr IINIT(" "); |
38 | ## dEXTCONST char rcsid[] = "perl.c\nPatch level: ###\n"; |
39 | ## PP(pp_const) |
3aefca04 |
40 | ## PERLVARI(Grsfp, PerlIO *, Nullfp) |
41 | ## PERLVAR(cvcache, HV *) |
3ee700d1 |
42 | |
777e9161 |
43 | # Putting PL_\1 in the substitution line makes etags dump core |
44 | # Thus we do it later (but 20.2.92 does it OK). |
3ee700d1 |
45 | set x -d -l c \ |
46 | -r '/[dI]?EXT\(CONST\)?[ \t*]+\([a-zA-Z_0-9]+[ \t*]+\)*\([a-zA-Z_0-9]+\)[ \t]*\($\|;\|\[\|[ \t]I+NIT[ \t]*(\|\/\*\)/\3/' \ |
47 | -r '/IEXT[ \t][^\/]*[ \t*]I\([a-zA-Z_][a-zA-Z_0-9]*\)[\[; \t]/\1/' \ |
777e9161 |
48 | -r '/PERLVAR[a-zA-Z_0-9]*[ \t]*([ \t]*[GIT]?\([a-zA-Z_][a-zA-Z_0-9]*\)[ \t]*[\[,]/\1/' \ |
3ee700d1 |
49 | -r '/PP[ \t]*([ \t]*\([^ \t()]*\)[ \t]*)/\1/' |
50 | |
51 | shift |
52 | |
53 | rm -f TAGS.tmp TAGS.tm2 |
54 | |
55 | # Process lines like this: #define MEM_ALIGNBYTES $alignbytes /**/ |
56 | etags -o TAGS.tmp \ |
57 | -l none -r '/#\(\$[a-zA-Z_0-9]+\|define\)[ \t]+\([a-zA-Z_0-9]+\)/\2/' \ |
58 | config_h.SH |
3625ddea |
59 | # Process lines like this: Mcc (Loc.U): |
60 | etags -o TAGS.tmp -a \ |
61 | -l none -r '/^\([a-zA-Z_0-9]+\)[ \t]+(/\$\1/' \ |
62 | -r '/^\([a-zA-Z_0-9]+\)[ \t]+(/\1/' Porting/Glossary |
63 | |
3ee700d1 |
64 | etags -o TAGS.tmp -a "$@" $topfiles |
777e9161 |
65 | |
66 | # Now add these PL_: |
51371543 |
67 | perl -w014pe 'if (s/^( .* PERLVAR A?I? # 1: TAG group |
777e9161 |
68 | \s* \( \s* [GIT] # |
69 | .* # |
70 | \x7F # End of description |
71 | ) |
3625ddea |
72 | ( .* \x01 ) # 2: Exact group |
777e9161 |
73 | /${1}PL_$2/mgx) { # Add PL_ |
74 | $chars = chomp; |
75 | s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e; |
76 | $_ .= ("\f" x $chars); |
77 | }' TAGS.tmp > TAGS.tm1 && mv TAGS.tm1 TAGS.tmp |
78 | |
79 | |
0c9e4c8c |
80 | # Now remove these Perl_, add empty- and perl_-flavors: |
81 | perl -w014pe 'if (s/^(Perl_ # 1: First group |
82 | (\w+) \( # 2: Stripped name |
83 | \x7F # End of description |
84 | ) # End of description |
85 | (\d+,\d+\n) # 3: TAGS Trail |
86 | /$1$3$1$2\x01$3$1perl_$2\x01$3/mgx) { # Repeat, add empty and perl_ flavors |
87 | $chars = chomp; |
88 | s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e; |
89 | $_ .= ("\f" x $chars); |
90 | }' TAGS.tmp > TAGS.tm1 && mv TAGS.tm1 TAGS.tmp |
91 | |
92 | # Now remove these S_, add empty-flavor: |
93 | perl -w014pe 'if (s/^(S_ # 1: First group |
94 | (\w+) \( # 2: Stripped name |
95 | \x7F # End of description |
96 | ) # End of description |
97 | (\d+,\d+\n) # 3: TAGS Trail |
98 | /$1$3$1$2\x01$3/mgx) { # Repeat, add empty_ flavor |
99 | $chars = chomp; |
100 | s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e; |
101 | $_ .= ("\f" x $chars); |
102 | }' TAGS.tmp > TAGS.tm1 && mv TAGS.tm1 TAGS.tmp |
777e9161 |
103 | |
3ee700d1 |
104 | etags -o TAGS.tmp -a -D -l none -r '/#define.*\t\(Perl_.*\)/\1/' embed.h |
acfe0abc |
105 | etags -o TAGS.tmp -a globals.c embedvar.h perlapi.c perlapi.h |
3ee700d1 |
106 | |
0c9e4c8c |
107 | # The above processes created a lot of descriptions with an |
108 | # an explicitly specified tag. Such descriptions have higher |
109 | # precedence than descriptions without an explicitely specified tag. |
110 | # To restore the justice, make all the descriptions explicit. |
3625ddea |
111 | perl -w014pe 'if (s/^( [^\n\x7F\x01]*\b # 1: TAG group |
79e58eb3 |
112 | (\w+) # 2: word |
3625ddea |
113 | [^\w\x7F\x01\n]* # Most anything |
79e58eb3 |
114 | \x7F # End of description |
115 | ) |
116 | (\d+,\d+\n) # 3: TAGS Trail |
3625ddea |
117 | /$1$2\x01$3/mgx) { # Add specific marking |
79e58eb3 |
118 | $chars = chomp; |
119 | s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e; |
120 | $_ .= ("\f" x $chars); |
121 | }' TAGS.tmp > TAGS.tm1 && mv TAGS.tm1 TAGS.tmp |
122 | |
3ee700d1 |
123 | # Add MODULE lines to TAG files (to be postprocessed later), |
124 | # and BOOT: lines (in DynaLoader processed twice?) |
125 | |
126 | # This skips too many XSUBs: |
127 | |
128 | # etags -o TAGS.tmp -a -d -l c \ |
129 | # -r '/MODULE[ \t=]+\(.*PACKAGE[ \t]*=[ \t]*\)?\([^ \t]+\)\([ \t]*PREFIX[ \t]*=[ \t]*\([^ \t]+\)\)?/\2/' \ |
130 | # -r '/[ \t]*BOOT:/' \ |
131 | # $xsfiles |
132 | |
133 | etags -o TAGS.tmp -a -d -l c \ |
134 | -r '/MODULE[ \t=]+\(.*PACKAGE[ \t]*=[ \t]*\)?\([^ \t]+\)\([ \t]*PREFIX[ \t]*=[ \t]*\([^ \t]+\)\)?/\2/' \ |
135 | -r '/[ \t]*BOOT:/' \ |
136 | -r '/\([_a-zA-Z][a-zA-Z0-9_:]*\)(/' \ |
137 | $xsfiles |
138 | |
139 | # -r '/MODULE[ \t=]+\(.*PACKAGE[ \t]*=[ \t]*\)?\([^ \t]+\)/\2/' \ |
140 | # -r '/MODULE.*PREFIX[ \t]*=[ \t]*\([^ \t]+\)/\1/' \ |
141 | # $xsfiles |
142 | |
143 | etags -o TAGS.tmp -a "$@" $subdirfiles |
3625ddea |
144 | etags -o TAGS.tmp -a "$@" $subdirfiles1 |
3ee700d1 |
145 | |
79e58eb3 |
146 | if test ! -f emacs/cperl-mode.elc ; then |
ea544449 |
147 | ( cd emacs; $emacs -batch -q -no-site-file -f batch-byte-compile cperl-mode.el ) |
3ee700d1 |
148 | fi |
149 | |
150 | # This should work with newer Emaxen |
151 | |
152 | cp TAGS.tmp TAGS |
ea544449 |
153 | if $emacs -batch -q -no-site-file -l emacs/cperl-mode.elc -f cperl-add-tags-recurse-noxs ; then |
3ee700d1 |
154 | mv TAGS TAGS.tmp |
155 | fi |
156 | |
157 | perl -w014pe ' |
158 | $update = s/^PP\(\177\d+,\d+\n//gm; |
159 | $update += s/^(I?EXT.*[ \t])IINIT[ \t]*\((\177)/$1$2/gm; |
160 | if (/^\n*[^\s,]+\.xs,/s) { |
161 | $mod = $cmod = $bmod = $pref = ""; |
162 | s/^(.*\n)\1+/$1/mg; # Remove duplicate lines |
163 | $_ = join("", map { |
164 | if (/^MODULE[ \t]*=[ \t]*(\S+)(?:[ \t]+PACKAGE[ \t]*=[ \t]*(\S+))?[ \t\177]/m) { |
165 | $mod = $+; |
166 | ($bmod = $mod) =~ tr/:/_/; |
167 | $cmod = "XS_${bmod}_"; |
168 | $pref = ""; |
169 | if (s/[ \t]+PREFIX[ \t]*=[ \t]*([^\s\177]+)(\177)/$+/) { |
170 | $pref = $1; |
171 | $pref =~ s/([^\w\s])/\\$1/g; |
172 | $pref = "(?:$pref)?"; |
173 | } |
174 | } elsif ($mod ne "") { |
175 | # Ref points for Module::subr, XS_Module_subr, subr |
176 | s/^($pref(\w+)[ \t()]*\177)(\d+,\d+)$/$1${mod}::${2}\01$3\n$1$2\01$3\n$1$cmod$2\01$3/gm; |
177 | # Ref for Module::bootstrap bootstrap boot_Module |
178 | s/^([ \t]*BOOT:\177)(\d+,\d+)$/$1${mod}::bootstrap\01$2\n${1}bootstrap\01$2\n${1}boot_$bmod\01$2/gm; |
179 | } |
180 | $_; |
181 | } split(/(\nMODULE[ \t]*=[^\n\177]+\177)/)); |
182 | |
183 | $update = 1; |
184 | } |
185 | if ($update) { |
186 | $chars = chomp; |
187 | s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e; |
188 | $_ .= ("\f" x $chars); |
189 | }' TAGS.tmp > TAGS.tm2 |
190 | |
191 | rm -f TAGS |
192 | mv TAGS.tm2 TAGS |
193 | rm -f TAGS.tmp |
194 | |
195 | |
196 | |