annotate lib-src/make-docfile.c @ 468:9b11b9478c68

Initial revision
author Richard M. Stallman <rms@gnu.org>
date Sat, 21 Dec 1991 05:04:13 +0000
parents e0ec73426aea
children 40b255f55df3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 /* Generate doc-string file for GNU Emacs from source files.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 Copyright (C) 1985, 1986 Free Software Foundation, Inc.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
38
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
7 it under the terms of the GNU General Public License as published by
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
9 any later version.
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
38
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
14 GNU General Public License for more details.
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
15
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
16 You should have received a copy of the GNU General Public License
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 24
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 /* The arguments given to this program are all the C and Lisp source files
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 of GNU Emacs. .elc and .el and .c files are allowed.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 A .o file can also be specified; the .c file it was made from is used.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 This helps the makefile pass the correct list of files.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 The results, which go to standard output or to a file
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 specified with -a or -o (-a to append, -o to start from nothing),
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 are entries containing function or variable names and their documentation.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 Each entry starts with a ^_ character.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 Then comes F for a function or V for a variable.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 Then comes the function or variable name, terminated with a newline.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 Then comes the documentation for that function or variable.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 #include <stdio.h>
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 FILE *outfile;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 main (argc, argv)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 int argc;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 char **argv;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 int i;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 int err_count = 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 outfile = stdout;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 /* If first two args are -o FILE, output to FILE. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 i = 1;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 if (argc > i + 1 && !strcmp (argv[i], "-o"))
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 outfile = fopen (argv[i + 1], "w");
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 i += 2;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 if (argc > i + 1 && !strcmp (argv[i], "-a"))
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 outfile = fopen (argv[i + 1], "a");
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 i += 2;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 for (; i < argc; i++)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 err_count += scan_file (argv[i]); /* err_count seems to be {mis,un}used */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 #ifndef VMS
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 exit (err_count); /* see below - shane */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 #endif VMS
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
164
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
67 /* Read file FILENAME and output its doc strings to outfile. */
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 /* Return 1 if file is not found, 0 if it is found. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 scan_file (filename)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 char *filename;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 int len = strlen (filename);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 if (!strcmp (filename + len - 4, ".elc"))
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 return scan_lisp_file (filename);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 else if (!strcmp (filename + len - 3, ".el"))
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 return scan_lisp_file (filename);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 else
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 return scan_c_file (filename);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 char buf[128];
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 /* Skip a C string from INFILE,
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 and return the character that follows the closing ".
164
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
86 If printflag is positive, output string contents to outfile.
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 If it is negative, store contents in buf.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 Convert escape sequences \n and \t to newline and tab;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 discard \ followed by newline. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 read_c_string (infile, printflag)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 FILE *infile;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 int printflag;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 register int c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 char *p = buf;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 while (c != EOF)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 while (c != '"' && c != EOF)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 if (c == '\\')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 if (c == '\n')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 if (c == 'n')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 c = '\n';
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 if (c == 't')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 c = '\t';
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 if (printflag > 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 putc (c, outfile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 else if (printflag < 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 *p++ = c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 if (c != '"')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 break;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 if (printflag > 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 putc (c, outfile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 else if (printflag < 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 *p++ = c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 if (printflag < 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 *p = 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 return c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 /* Write to file OUT the argument names of the function whose text is in BUF.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 MINARGS and MAXARGS are the minimum and maximum number of arguments. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 write_c_args (out, buf, minargs, maxargs)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 FILE *out;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 char *buf;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 int minargs, maxargs;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 register int c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 register char *p = buf;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 int space = 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149
168
e0ec73426aea *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 164
diff changeset
150 fprintf (out, "arguments: ");
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 while (*p)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 c = *p++;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 if (c == ',')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 minargs--;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 maxargs--;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 if (!space)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 putc (' ', out);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 if (minargs == 0 && maxargs > 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 fprintf (out, "&optional ");
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 space = 1;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 else if (c == ' ' && space)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 space = (c == ' ');
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 putc (c, out);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 putc ('\n', out);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 /* Read through a c file. If a .o file is named,
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 the corresponding .c file is read instead.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 Looks for DEFUN constructs such as are defined in ../src/lisp.h.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 scan_c_file (filename)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 char *filename;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 FILE *infile;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 register int c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 register int commas;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 register int defunflag;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 register int defvarflag;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 int minargs, maxargs;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 if (filename[strlen (filename) - 1] == 'o')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 filename[strlen (filename) - 1] = 'c';
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 infile = fopen (filename, "r");
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 /* No error if non-ex input file */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 if (infile == NULL)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 perror (filename);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 return 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 c = '\n';
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 while (!feof (infile))
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 if (c != '\n')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 if (c == ' ')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 while (c == ' ')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 if (c != 'D')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 if (c != 'E')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 if (c != 'F')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 if (c != 'V')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 defvarflag = 1;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 defunflag = 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 else if (c == 'D')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 if (c != 'E')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 if (c != 'F')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 defunflag = c == 'U';
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 defvarflag = 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 else continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 while (c != '(')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 if (c < 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 goto eof;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 if (c != '"')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 c = read_c_string (infile, -1);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 if (defunflag)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 commas = 5;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 else if (defvarflag)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 commas = 1;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 else /* For DEFSIMPLE and DEFPRED */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 commas = 2;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 while (commas)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 if (c == ',')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 commas--;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 if (defunflag && (commas == 1 || commas == 2))
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 do
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 while (c == ' ' || c == '\n' || c == '\t');
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 if (c < 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 goto eof;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 ungetc (c, infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 if (commas == 2) /* pick up minargs */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 fscanf (infile, "%d", &minargs);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 else /* pick up maxargs */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 maxargs = -1;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 else
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 fscanf (infile, "%d", &maxargs);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 if (c < 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 goto eof;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 while (c == ' ' || c == '\n' || c == '\t')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 if (c == '"')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 c = read_c_string (infile, 0);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 while (c != ',')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 while (c == ' ' || c == '\n' || c == '\t')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 if (c == '"')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 putc (037, outfile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 putc (defvarflag ? 'V' : 'F', outfile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 fprintf (outfile, "%s\n", buf);
168
e0ec73426aea *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 164
diff changeset
303 c = read_c_string (infile, 1);
e0ec73426aea *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 164
diff changeset
304
e0ec73426aea *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 164
diff changeset
305 /* If this is a defun, find the arguments and print them. If
e0ec73426aea *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 164
diff changeset
306 this function takes MANY or UNEVALLED args, then the C source
e0ec73426aea *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 164
diff changeset
307 won't give the names of the arguments, so we shouldn't bother
e0ec73426aea *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 164
diff changeset
308 trying to find them. */
e0ec73426aea *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 164
diff changeset
309 if (defunflag && maxargs != -1)
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 char argbuf[1024], *p = argbuf;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 while (c != ')')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 if (c < 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 goto eof;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 /* Skip into arguments. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 while (c != '(')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 if (c < 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 goto eof;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 /* Copy arguments into ARGBUF. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 *p++ = c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 do
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 *p++ = c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 while (c != ')');
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 *p = '\0';
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 /* Output them. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 fprintf (outfile, "\n\n");
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 write_c_args (outfile, argbuf, minargs, maxargs);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 eof:
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 fclose (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 return 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 /* Read a file of Lisp code, compiled or interpreted.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 Looks for
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (defun NAME ARGS DOCSTRING ...)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (autoload 'NAME FILE DOCSTRING ...)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (defvar NAME VALUE DOCSTRING)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (defconst NAME VALUE DOCSTRING)
162
6de3e4609f2c *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 38
diff changeset
348 (fset (quote NAME) (make-byte-code (quote ARGS) ... "\
164
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
349 DOCSTRING")
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 starting in column zero.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 ARGS, FILE or VALUE is ignored. We do not know how to parse Lisp code
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 so we use a kludge to skip them:
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 In a function definition, the form of ARGS of FILE is known, and we
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 can skip it.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 In a variable definition, we use a formatting convention:
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 the DOCSTRING, if present, must be followed by a closeparen and a newline,
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 and no newline must appear between the defvar or defconst and the docstring,
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 The only source file that must follow this convention is loaddefs.el;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 aside from that, it is always the .elc file that we look at, and
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 they are no problem because byte-compiler output follows this convention.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 The NAME and DOCSTRING are output.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 NAME is preceded by `F' for a function or `V' for a variable.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 An entry is output only if DOCSTRING has \ newline just after the opening "
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 scan_lisp_file (filename)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 char *filename;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 FILE *infile;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 register int c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 register int commas;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 register char *p;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 int defvarflag;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 infile = fopen (filename, "r");
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 if (infile == NULL)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 perror (filename);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 return 0; /* No error */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 c = '\n';
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 while (!feof (infile))
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 if (c != '\n')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 if (c != '(')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 continue;
164
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
393
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
394 /* Handle an autoload. */
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 if (c == 'a')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 if (c != 'u')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 if (c != 't')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 if (c != 'o')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 if (c != 'l')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 if (c != 'o')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 if (c != 'a')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 if (c != 'd')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 while (c == ' ')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 if (c == '\'')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 else
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 if (c != '(')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 if (c != 'q')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 if (c != 'u')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 if (c != 'o')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 if (c != 't')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 if (c != 'e')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 if (c != ' ')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 while (c == ' ')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 p = buf;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 while (c != ' ' && c != ')')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 if (c == EOF)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 return 1;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 if (c == '\\')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 *p++ = c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 *p = 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 while (c != '"')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 if (c == EOF)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 return 1;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 c = read_c_string (infile, 0);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 }
164
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
474
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
475 /* Handle def* clauses. */
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 else if (c == 'd')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 if (c != 'e')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 if (c != 'f')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 c = getc (infile);
164
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
485
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
486 /* Is this a defun? */
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 if (c == 'u')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 if (c != 'n')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 defvarflag = 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 }
164
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
494
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
495 /* Or a defvar? */
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 else if (c == 'v')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 if (c != 'a')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 if (c != 'r')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 defvarflag = 1;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 }
164
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
506
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
507 /* Or a defconst? */
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 else if (c == 'c')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 if (c != 'o')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 if (c != 'n')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 if (c != 's')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 if (c != 't')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 defvarflag = 1;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 else
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 /* Now we have seen "defun" or "defvar" or "defconst". */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 while (c != ' ' && c != '\n' && c != '\t')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 while (c == ' ' || c == '\n' || c == '\t')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 /* Read and store name of function or variable being defined
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 Discard backslashes that are for quoting. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 p = buf;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 while (c != ' ' && c != '\n' && c != '\t')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 if (c == '\\')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 *p++ = c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 *p = 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 while (c == ' ' || c == '\n' || c == '\t')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 if (! defvarflag)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 /* A function: */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 /* Skip the arguments: either "nil" or a list in parens */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 if (c == 'n')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 while (c != ' ' && c != '\n' && c != '\t')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 else
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 while (c != '(')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 while (c != ')')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 else
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 /* A variable: */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 /* Skip until the first newline; remember
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 the two previous characters. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 char c1 = 0, c2 = 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 while (c != '\n' && c >= 0)
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 c2 = c1;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 c1 = c;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 /* If two previous characters were " and \,
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 this is a doc string. Otherwise, there is none. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 if (c2 == '"' && c1 == '\\')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 {
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 putc (037, outfile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 putc ('V', outfile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 fprintf (outfile, "%s\n", buf);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 read_c_string (infile, 1);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 }
164
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
595
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
596 /* Handle an fset clause. */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
597 else if (c == 'f')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
598 {
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
599 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
600 if (c != 's')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
601 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
602 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
603 if (c != 'e')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
604 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
605 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
606 if (c != 't')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
607 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
608
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
609 /* Skip white space */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
610 do
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
611 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
612 while (c == ' ' || c == '\n' || c == '\t');
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
613
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
614 /* Recognize "(quote". */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
615 if (c != '(')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
616 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
617 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
618 if (c != 'q')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
619 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
620 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
621 if (c != 'u')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
622 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
623 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
624 if (c != 'o')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
625 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
626 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
627 if (c != 't')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
628 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
629 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
630 if (c != 'e')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
631 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
632
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
633 /* Skip white space */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
634 do
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
635 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
636 while (c == ' ' || c == '\n' || c == '\t');
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
637
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
638 /* Read and store name of function or variable being defined
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
639 Discard backslashes that are for quoting. */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
640 p = buf;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
641 while (c != ')' && c != ' ' && c != '\n' && c != '\t')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
642 {
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
643 if (c == '\\')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
644 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
645 *p++ = c;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
646 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
647 }
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
648 *p = '\0';
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
649
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
650 /* Skip white space */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
651 do
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
652 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
653 while (c == ' ' || c == '\n' || c == '\t');
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
654
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
655 /* Recognize "(make-byte-code". */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
656 if (c != '(')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
657 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
658 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
659 if (c != 'm')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
660 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
661 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
662 if (c != 'a')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
663 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
664 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
665 if (c != 'k')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
666 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
667 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
668 if (c != 'e')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
669 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
670 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
671 if (c != '-')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
672 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
673 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
674 if (c != 'b')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
675 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
676 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
677 if (c != 'y')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
678 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
679 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
680 if (c != 't')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
681 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
682 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
683 if (c != 'e')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
684 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
685 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
686 if (c != '-')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
687 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
688 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
689 if (c != 'c')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
690 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
691 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
692 if (c != 'o')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
693 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
694 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
695 if (c != 'd')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
696 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
697 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
698 if (c != 'e')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
699 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
700
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
701 /* Scan for a \" followed by a newline, or for )) followed by
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
702 a newline. If we find the latter first, this function has
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
703 no docstring. */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
704 {
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
705 char c1 = 0, c2 = 0;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
706
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
707 for (;;)
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
708 {
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
709
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
710 /* Find newlines, and remember the two previous characters. */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
711 for (;;)
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
712 {
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
713 c = getc (infile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
714
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
715 if (c == '\n' || c < 0)
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
716 break;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
717
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
718 c2 = c1;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
719 c1 = c;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
720 }
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
721
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
722 /* If we've hit eof, quit. */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
723 if (c == EOF)
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
724 break;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
725
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
726 /* If the last two characters were \", this is a docstring. */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
727 else if (c2 == '"' && c1 == '\\')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
728 {
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
729 putc (037, outfile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
730 putc ('F', outfile);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
731 fprintf (outfile, "%s\n", buf);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
732 read_c_string (infile, 1);
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
733 break;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
734 }
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
735
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
736 /* If the last two characters were )), there is no
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
737 docstring. */
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
738 else if (c2 == ')' && c1 == ')')
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
739 break;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
740 }
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
741 continue;
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
742 }
aba3ff2b9eb4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 162
diff changeset
743 }
24
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 else
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 /* Here for a function definition.
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 We have skipped the file name or arguments
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 and arrived at where the doc string is,
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 if there is a doc string. */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 /* Skip whitespace */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 while (c == ' ' || c == '\n' || c == '\t')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 /* " followed by \ and newline means a doc string we should gobble */
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 if (c != '"')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 if (c != '\\')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 c = getc (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 if (c != '\n')
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 continue;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 putc (037, outfile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 putc ('F', outfile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 fprintf (outfile, "%s\n", buf);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 read_c_string (infile, 1);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 }
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 fclose (infile);
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 return 0;
2354a499c504 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 }