Missed FREAD in bytecode.h
[p5sagit/p5-mst-13.2.git] / emacs / ptags
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
17 # Avoid builitin on OS/2:
18 if test ! -z "$OS2_SHELL"; then alias find=gnufind; fi
19
20 # Insure proper order (.h after .c, .xs before .c in subdirs):
21 topfiles="`echo ' ' *.y *.c *.h ' ' | sed 's/ embed.h / /'`"
22 subdirfiles="`( find ./*/* -name '*.[cy]' -print | sort ; find ./*/* -name '*.[hH]' -print | sort )`"
23 xsfiles="`find . -name '*.xs' -print | sort`"
24
25 # What is `etags -d'?
26
27 # These are example lines for global variables and PP-code:
28 ## IEXT SV *       Iparsehook;
29 ## IEXT char *     Isplitstr IINIT(" ");
30 ## dEXTCONST char rcsid[] = "perl.c\nPatch level: ###\n";
31 ## PP(pp_const)
32
33 set x   -d -l c \
34         -r '/[dI]?EXT\(CONST\)?[ \t*]+\([a-zA-Z_0-9]+[ \t*]+\)*\([a-zA-Z_0-9]+\)[ \t]*\($\|;\|\[\|[ \t]I+NIT[ \t]*(\|\/\*\)/\3/' \
35         -r '/IEXT[ \t][^\/]*[ \t*]I\([a-zA-Z_][a-zA-Z_0-9]*\)[\[; \t]/\1/'  \
36         -r '/PP[ \t]*([ \t]*\([^ \t()]*\)[ \t]*)/\1/'
37
38 shift
39
40 rm -f TAGS.tmp TAGS.tm2
41
42 # Process lines like this: #define MEM_ALIGNBYTES $alignbytes      /**/
43 etags -o TAGS.tmp \
44         -l none -r '/#\(\$[a-zA-Z_0-9]+\|define\)[ \t]+\([a-zA-Z_0-9]+\)/\2/' \
45         config_h.SH
46 etags -o TAGS.tmp -a "$@" $topfiles
47 etags -o TAGS.tmp -a -D -l none -r '/#define.*\t\(Perl_.*\)/\1/' embed.h
48
49 # Add MODULE lines to TAG files (to be postprocessed later),
50 #   and BOOT: lines (in DynaLoader processed twice?)
51
52 # This skips too many XSUBs:
53
54 # etags -o TAGS.tmp -a -d -l c \
55 #       -r '/MODULE[ \t=]+\(.*PACKAGE[ \t]*=[ \t]*\)?\([^ \t]+\)\([ \t]*PREFIX[ \t]*=[ \t]*\([^ \t]+\)\)?/\2/' \
56 #       -r '/[ \t]*BOOT:/' \
57 #       $xsfiles
58
59 etags -o TAGS.tmp -a -d -l c \
60         -r '/MODULE[ \t=]+\(.*PACKAGE[ \t]*=[ \t]*\)?\([^ \t]+\)\([ \t]*PREFIX[ \t]*=[ \t]*\([^ \t]+\)\)?/\2/' \
61         -r '/[ \t]*BOOT:/' \
62         -r '/\([_a-zA-Z][a-zA-Z0-9_:]*\)(/' \
63         $xsfiles
64
65 #       -r '/MODULE[ \t=]+\(.*PACKAGE[ \t]*=[ \t]*\)?\([^ \t]+\)/\2/' \
66 #       -r '/MODULE.*PREFIX[ \t]*=[ \t]*\([^ \t]+\)/\1/'        \
67 #       $xsfiles
68
69 etags -o TAGS.tmp -a "$@" $subdirfiles
70
71 if ! test -f emacs/cperl-mode.elc ; then
72     ( cd emacs; emacs -batch -q -no-site-file -f batch-byte-compile cperl-mode.el )
73 fi
74
75 # This should work with newer Emaxen
76
77 cp TAGS.tmp TAGS
78 if emacs -batch -q -no-site-file -l emacs/cperl-mode.elc -f cperl-add-tags-recurse-noxs ; then
79     mv TAGS TAGS.tmp
80 fi
81
82 perl -w014pe '
83     $update  = s/^PP\(\177\d+,\d+\n//gm;
84     $update += s/^(I?EXT.*[ \t])IINIT[ \t]*\((\177)/$1$2/gm;
85     if (/^\n*[^\s,]+\.xs,/s) {
86         $mod = $cmod = $bmod = $pref = "";
87         s/^(.*\n)\1+/$1/mg;                     # Remove duplicate lines
88         $_ = join("", map {
89             if (/^MODULE[ \t]*=[ \t]*(\S+)(?:[ \t]+PACKAGE[ \t]*=[ \t]*(\S+))?[ \t\177]/m) {
90                 $mod = $+;
91                 ($bmod = $mod) =~ tr/:/_/;
92                 $cmod = "XS_${bmod}_";
93                 $pref = "";
94                 if (s/[ \t]+PREFIX[ \t]*=[ \t]*([^\s\177]+)(\177)/$+/) {
95                     $pref = $1;
96                     $pref =~ s/([^\w\s])/\\$1/g;
97                     $pref = "(?:$pref)?";
98                 }
99             } elsif ($mod ne "") {
100                 # Ref points for Module::subr, XS_Module_subr, subr
101                 s/^($pref(\w+)[ \t()]*\177)(\d+,\d+)$/$1${mod}::${2}\01$3\n$1$2\01$3\n$1$cmod$2\01$3/gm;
102                 # Ref for Module::bootstrap bootstrap boot_Module
103                 s/^([ \t]*BOOT:\177)(\d+,\d+)$/$1${mod}::bootstrap\01$2\n${1}bootstrap\01$2\n${1}boot_$bmod\01$2/gm;
104             }
105             $_;
106         } split(/(\nMODULE[ \t]*=[^\n\177]+\177)/));
107
108         $update = 1;
109     }
110     if ($update) {
111         $chars = chomp;
112         s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e;
113         $_ .= ("\f" x $chars);
114     }' TAGS.tmp > TAGS.tm2
115
116 rm -f TAGS
117 mv TAGS.tm2 TAGS
118 rm -f TAGS.tmp
119
120
121