Add a .gitignore
[packages] / gen-macro-list.awk
1 #!/bin/awk -f
2 #
3 # This file is part of XEmacs.
4 #
5 # XEmacs is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
8 # later version.
9
10 # XEmacs is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 # for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with XEmacs; see the file COPYING.  If not, write to
17 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 # Boston, MA 02110-1301, USA.
19 #
20 # Written by Jerry James
21 # December 18, 2002
22 #
23 # Updated January 14, 2004 to record the type of definition (defmacro,
24 # defun, etc.) and to avoid finding definitions in comments and strings.
25 #
26 # Produce a list of macros and the packages/files in which they are defined.
27 # Usage: find $package_root -type f -name \*.el | \
28 #        xargs awk -f gen-macro-list.awk > macro.list
29 #
30 # Find all instances of defmacro and defsubst (including defmacro*, etc.)
31 # not in comments or strings
32 /^[^;\"]*\(def(macro|subst)/ {
33   for (i = 1; i <= NF; i++) {
34     if ($i ~ "\\(def(macro|subst)") {
35       mac = i + 1;
36       ## If the macro name contains a comma, we don't know how to process it
37       if ($mac !~ ",") {
38         ## Get rid of any trailing parentheses (due to not leaving a space
39         ## between the macro name and parameter list.
40         paren = index($mac, "(");
41         ## This is not correct for pathnames with multiple xemacs-packages
42         ## elements, but fixing it is too painful
43         printf("%s\t%s\t%s\n",
44                (paren == 0) ? $mac : substr($mac, 1, $paren - 1),
45                substr(FILENAME, match(FILENAME, "(xemacs|mule)-packages")),
46                substr($i, index($i, "(") + 1));
47       }
48       break;
49     }
50   }
51 }