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