Commit | Line | Data |
---|---|---|
3ee700d1 IZ |
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 IZ |
18 | if test ! -z "$OS2_SHELL"; then alias find=gnufind; fi |
19 | ||
20 | # Insure proper order (.h after .c, .xs before .c in subdirs): | |
777e9161 IZ |
21 | # Move autogenerated less-informative files to the end: |
22 | # Hard to do embed.h and embedvar.h in one sweep: | |
23 | ||
24 | topfiles="`echo ' ' *.y *.c *.h ' ' | sed 's/ \(embed\(var\|\)\.h\|obj\(pp\|XSUB\)\.h\|globals\.c\) \(\(embedvar\|objpp\).h \|\)/ /g'`" | |
3625ddea IZ |
25 | subdirs="`find ./* -maxdepth 0 -type d`" |
26 | subdirfiles="`find $subdirs -name '*.[cy]' -print | sort`" | |
27 | subdirfiles1="`find $subdirs -name '*.[hH]' -print | sort`" | |
3ee700d1 IZ |
28 | xsfiles="`find . -name '*.xs' -print | sort`" |
29 | ||
777e9161 | 30 | # etags -d : process defines too (default now) |
3ee700d1 IZ |
31 | |
32 | # These are example lines for global variables and PP-code: | |
33 | ## IEXT SV * Iparsehook; | |
34 | ## IEXT char * Isplitstr IINIT(" "); | |
35 | ## dEXTCONST char rcsid[] = "perl.c\nPatch level: ###\n"; | |
36 | ## PP(pp_const) | |
3aefca04 IZ |
37 | ## PERLVARI(Grsfp, PerlIO *, Nullfp) |
38 | ## PERLVAR(cvcache, HV *) | |
3ee700d1 | 39 | |
777e9161 IZ |
40 | # Putting PL_\1 in the substitution line makes etags dump core |
41 | # Thus we do it later (but 20.2.92 does it OK). | |
3ee700d1 IZ |
42 | set x -d -l c \ |
43 | -r '/[dI]?EXT\(CONST\)?[ \t*]+\([a-zA-Z_0-9]+[ \t*]+\)*\([a-zA-Z_0-9]+\)[ \t]*\($\|;\|\[\|[ \t]I+NIT[ \t]*(\|\/\*\)/\3/' \ | |
44 | -r '/IEXT[ \t][^\/]*[ \t*]I\([a-zA-Z_][a-zA-Z_0-9]*\)[\[; \t]/\1/' \ | |
777e9161 | 45 | -r '/PERLVAR[a-zA-Z_0-9]*[ \t]*([ \t]*[GIT]?\([a-zA-Z_][a-zA-Z_0-9]*\)[ \t]*[\[,]/\1/' \ |
3ee700d1 IZ |
46 | -r '/PP[ \t]*([ \t]*\([^ \t()]*\)[ \t]*)/\1/' |
47 | ||
48 | shift | |
49 | ||
50 | rm -f TAGS.tmp TAGS.tm2 | |
51 | ||
52 | # Process lines like this: #define MEM_ALIGNBYTES $alignbytes /**/ | |
53 | etags -o TAGS.tmp \ | |
54 | -l none -r '/#\(\$[a-zA-Z_0-9]+\|define\)[ \t]+\([a-zA-Z_0-9]+\)/\2/' \ | |
55 | config_h.SH | |
3625ddea IZ |
56 | # Process lines like this: Mcc (Loc.U): |
57 | etags -o TAGS.tmp -a \ | |
58 | -l none -r '/^\([a-zA-Z_0-9]+\)[ \t]+(/\$\1/' \ | |
59 | -r '/^\([a-zA-Z_0-9]+\)[ \t]+(/\1/' Porting/Glossary | |
60 | ||
3ee700d1 | 61 | etags -o TAGS.tmp -a "$@" $topfiles |
777e9161 IZ |
62 | |
63 | # Now add these PL_: | |
51371543 | 64 | perl -w014pe 'if (s/^( .* PERLVAR A?I? # 1: TAG group |
777e9161 IZ |
65 | \s* \( \s* [GIT] # |
66 | .* # | |
67 | \x7F # End of description | |
68 | ) | |
3625ddea | 69 | ( .* \x01 ) # 2: Exact group |
777e9161 IZ |
70 | /${1}PL_$2/mgx) { # Add PL_ |
71 | $chars = chomp; | |
72 | s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e; | |
73 | $_ .= ("\f" x $chars); | |
74 | }' TAGS.tmp > TAGS.tm1 && mv TAGS.tm1 TAGS.tmp | |
75 | ||
76 | ||
77 | ||
3ee700d1 | 78 | etags -o TAGS.tmp -a -D -l none -r '/#define.*\t\(Perl_.*\)/\1/' embed.h |
777e9161 | 79 | etags -o TAGS.tmp -a globals.c embedvar.h objXSUB.h objpp.h |
3ee700d1 | 80 | |
3625ddea | 81 | perl -w014pe 'if (s/^( [^\n\x7F\x01]*\b # 1: TAG group |
79e58eb3 | 82 | (\w+) # 2: word |
3625ddea | 83 | [^\w\x7F\x01\n]* # Most anything |
79e58eb3 IZ |
84 | \x7F # End of description |
85 | ) | |
86 | (\d+,\d+\n) # 3: TAGS Trail | |
3625ddea | 87 | /$1$2\x01$3/mgx) { # Add specific marking |
79e58eb3 IZ |
88 | $chars = chomp; |
89 | s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e; | |
90 | $_ .= ("\f" x $chars); | |
91 | }' TAGS.tmp > TAGS.tm1 && mv TAGS.tm1 TAGS.tmp | |
92 | ||
3ee700d1 IZ |
93 | # Add MODULE lines to TAG files (to be postprocessed later), |
94 | # and BOOT: lines (in DynaLoader processed twice?) | |
95 | ||
96 | # This skips too many XSUBs: | |
97 | ||
98 | # etags -o TAGS.tmp -a -d -l c \ | |
99 | # -r '/MODULE[ \t=]+\(.*PACKAGE[ \t]*=[ \t]*\)?\([^ \t]+\)\([ \t]*PREFIX[ \t]*=[ \t]*\([^ \t]+\)\)?/\2/' \ | |
100 | # -r '/[ \t]*BOOT:/' \ | |
101 | # $xsfiles | |
102 | ||
103 | etags -o TAGS.tmp -a -d -l c \ | |
104 | -r '/MODULE[ \t=]+\(.*PACKAGE[ \t]*=[ \t]*\)?\([^ \t]+\)\([ \t]*PREFIX[ \t]*=[ \t]*\([^ \t]+\)\)?/\2/' \ | |
105 | -r '/[ \t]*BOOT:/' \ | |
106 | -r '/\([_a-zA-Z][a-zA-Z0-9_:]*\)(/' \ | |
107 | $xsfiles | |
108 | ||
109 | # -r '/MODULE[ \t=]+\(.*PACKAGE[ \t]*=[ \t]*\)?\([^ \t]+\)/\2/' \ | |
110 | # -r '/MODULE.*PREFIX[ \t]*=[ \t]*\([^ \t]+\)/\1/' \ | |
111 | # $xsfiles | |
112 | ||
113 | etags -o TAGS.tmp -a "$@" $subdirfiles | |
3625ddea | 114 | etags -o TAGS.tmp -a "$@" $subdirfiles1 |
3ee700d1 | 115 | |
79e58eb3 | 116 | if test ! -f emacs/cperl-mode.elc ; then |
3ee700d1 IZ |
117 | ( cd emacs; emacs -batch -q -no-site-file -f batch-byte-compile cperl-mode.el ) |
118 | fi | |
119 | ||
120 | # This should work with newer Emaxen | |
121 | ||
122 | cp TAGS.tmp TAGS | |
123 | if emacs -batch -q -no-site-file -l emacs/cperl-mode.elc -f cperl-add-tags-recurse-noxs ; then | |
124 | mv TAGS TAGS.tmp | |
125 | fi | |
126 | ||
127 | perl -w014pe ' | |
128 | $update = s/^PP\(\177\d+,\d+\n//gm; | |
129 | $update += s/^(I?EXT.*[ \t])IINIT[ \t]*\((\177)/$1$2/gm; | |
130 | if (/^\n*[^\s,]+\.xs,/s) { | |
131 | $mod = $cmod = $bmod = $pref = ""; | |
132 | s/^(.*\n)\1+/$1/mg; # Remove duplicate lines | |
133 | $_ = join("", map { | |
134 | if (/^MODULE[ \t]*=[ \t]*(\S+)(?:[ \t]+PACKAGE[ \t]*=[ \t]*(\S+))?[ \t\177]/m) { | |
135 | $mod = $+; | |
136 | ($bmod = $mod) =~ tr/:/_/; | |
137 | $cmod = "XS_${bmod}_"; | |
138 | $pref = ""; | |
139 | if (s/[ \t]+PREFIX[ \t]*=[ \t]*([^\s\177]+)(\177)/$+/) { | |
140 | $pref = $1; | |
141 | $pref =~ s/([^\w\s])/\\$1/g; | |
142 | $pref = "(?:$pref)?"; | |
143 | } | |
144 | } elsif ($mod ne "") { | |
145 | # Ref points for Module::subr, XS_Module_subr, subr | |
146 | s/^($pref(\w+)[ \t()]*\177)(\d+,\d+)$/$1${mod}::${2}\01$3\n$1$2\01$3\n$1$cmod$2\01$3/gm; | |
147 | # Ref for Module::bootstrap bootstrap boot_Module | |
148 | s/^([ \t]*BOOT:\177)(\d+,\d+)$/$1${mod}::bootstrap\01$2\n${1}bootstrap\01$2\n${1}boot_$bmod\01$2/gm; | |
149 | } | |
150 | $_; | |
151 | } split(/(\nMODULE[ \t]*=[^\n\177]+\177)/)); | |
152 | ||
153 | $update = 1; | |
154 | } | |
155 | if ($update) { | |
156 | $chars = chomp; | |
157 | s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e; | |
158 | $_ .= ("\f" x $chars); | |
159 | }' TAGS.tmp > TAGS.tm2 | |
160 | ||
161 | rm -f TAGS | |
162 | mv TAGS.tm2 TAGS | |
163 | rm -f TAGS.tmp | |
164 | ||
165 | ||
166 |