428
|
1 /* Generate doc-string file for XEmacs from source files.
|
930
|
2 Copyright (C) 1985, 86, 92, 93, 94, 97, 1999, 2000, 2001
|
|
3 Free Software Foundation, Inc.
|
428
|
4 Copyright (C) 1995 Board of Trustees, University of Illinois.
|
|
5 Copyright (C) 1998, 1999 J. Kean Johnston.
|
814
|
6 Copyright (C) 2001, 2002 Ben Wing.
|
930
|
7
|
|
8 This file is part of XEmacs.
|
|
9
|
|
10 XEmacs is free software; you can redistribute it and/or modify
|
|
11 it under the terms of the GNU General Public License as published by
|
|
12 the Free Software Foundation; either version 2, or (at your option)
|
|
13 any later version.
|
428
|
14
|
930
|
15 XEmacs is distributed in the hope that it will be useful,
|
|
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 GNU General Public License for more details.
|
|
19
|
|
20 You should have received a copy of the GNU General Public License
|
|
21 along with XEmacs; see the file COPYING. If not, write to
|
|
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
23 Boston, MA 02111-1307, USA. */
|
|
24
|
|
25 /* Synched up with: FSF 21.2. */
|
428
|
26
|
|
27 /* The arguments given to this program are all the C and Lisp source files
|
930
|
28 of XEmacs. .elc and .el and .c files are allowed.
|
|
29 A .o or .obj file can also be specified; the .c file it was made from is used.
|
|
30 This helps the makefile pass the correct list of files.
|
|
31
|
|
32 The results, which go to standard output or to a file
|
|
33 specified with -a or -o (-a to append, -o to start from nothing),
|
|
34 are entries containing function or variable names and their documentation.
|
|
35 Each entry starts with a ^_ character.
|
|
36 Then comes F for a function or V for a variable.
|
|
37 Then comes the function or variable name, terminated with a newline.
|
|
38 Then comes the documentation for that function or variable.
|
|
39
|
|
40 Added 19.15/20.1: `-i site-packages' allow installer to dump extra packages
|
|
41 without modifying Makefiles, etc.
|
428
|
42 */
|
|
43
|
438
|
44 #include <config.h>
|
930
|
45 #include <sysfile.h>
|
428
|
46
|
|
47 #include <stdio.h>
|
|
48 #include <stdlib.h>
|
|
49 #include <string.h>
|
|
50 #include <ctype.h>
|
|
51
|
930
|
52 /* XEmacs addition */
|
|
53 #define C_IDENTIFIER_CHAR_P(c) \
|
|
54 (('A' <= c && c <= 'Z') || \
|
|
55 ('a' <= c && c <= 'z') || \
|
|
56 ('0' <= c && c <= '9') || \
|
|
57 (c == '_'))
|
428
|
58
|
442
|
59 static int scan_file (const char *filename);
|
428
|
60 static int read_c_string (FILE *, int, int);
|
442
|
61 static void write_c_args (FILE *out, const char *func, char *buf, int minargs,
|
428
|
62 int maxargs);
|
442
|
63 static int scan_c_file (const char *filename, const char *mode);
|
428
|
64 static void skip_white (FILE *);
|
|
65 static void read_lisp_symbol (FILE *, char *);
|
442
|
66 static int scan_lisp_file (const char *filename, const char *mode);
|
428
|
67
|
930
|
68 /* Stdio stream for output to the DOC file. */
|
|
69 static FILE *outfile;
|
|
70
|
|
71 /* XEmacs addition */
|
|
72 enum
|
|
73 {
|
|
74 el_file,
|
|
75 elc_file,
|
|
76 c_file
|
|
77 } Current_file_type;
|
428
|
78
|
|
79 /* Name this program was invoked with. */
|
|
80 char *progname;
|
|
81
|
930
|
82 /* XEmacs addition: set to 1 if this was invoked by ellcc */
|
428
|
83 int ellcc = 0;
|
|
84
|
|
85 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
|
|
86
|
|
87 static void
|
442
|
88 error (const char *s1, const char *s2)
|
428
|
89 {
|
|
90 fprintf (stderr, "%s: ", progname);
|
|
91 fprintf (stderr, s1, s2);
|
|
92 fprintf (stderr, "\n");
|
|
93 }
|
|
94
|
|
95 /* Print error message and exit. */
|
|
96
|
|
97 static void
|
442
|
98 fatal (const char *s1, const char *s2)
|
428
|
99 {
|
|
100 error (s1, s2);
|
|
101 exit (1);
|
|
102 }
|
|
103
|
|
104 /* Like malloc but get fatal error if memory is exhausted. */
|
|
105
|
|
106 static long *
|
|
107 xmalloc (unsigned int size)
|
|
108 {
|
|
109 long *result = (long *) malloc (size);
|
|
110 if (result == NULL)
|
|
111 fatal ("virtual memory exhausted", 0);
|
|
112 return result;
|
|
113 }
|
|
114
|
930
|
115 /* XEmacs addition */
|
428
|
116 static char *
|
814
|
117 next_extra_elc (char *extra_elcs)
|
428
|
118 {
|
|
119 static FILE *fp = NULL;
|
|
120 static char line_buf[BUFSIZ];
|
|
121 char *p = line_buf+1;
|
|
122
|
814
|
123 if (!fp)
|
|
124 {
|
|
125 if (!extra_elcs)
|
|
126 return NULL;
|
|
127 else if (!(fp = fopen (extra_elcs, READ_BINARY)))
|
|
128 {
|
|
129 /* It is not an error if this file doesn't exist. */
|
|
130 /*fatal ("error opening site package file list", 0);*/
|
|
131 return NULL;
|
|
132 }
|
|
133 fgets (line_buf, BUFSIZ, fp);
|
|
134 }
|
|
135
|
930
|
136 do
|
814
|
137 {
|
930
|
138 if (!fgets (line_buf, BUFSIZ, fp))
|
|
139 {
|
|
140 fclose (fp);
|
|
141 fp = NULL;
|
|
142 return NULL;
|
|
143 }
|
|
144 line_buf[0] = '\0';
|
814
|
145 /* reject too short or too long lines */
|
930
|
146 } while (strlen (p) <= 2 || strlen (p) >= (BUFSIZ - 5));
|
|
147
|
814
|
148 p[strlen (p) - 2] = '\0';
|
|
149 strcat (p, ".elc");
|
428
|
150
|
|
151 return p;
|
|
152 }
|
|
153
|
|
154
|
|
155 int
|
|
156 main (int argc, char **argv)
|
|
157 {
|
|
158 int i;
|
|
159 int err_count = 0;
|
|
160 int first_infile;
|
930
|
161 char *extra_elcs = NULL; /* XEmacs addition */
|
428
|
162
|
|
163 progname = argv[0];
|
|
164
|
|
165 outfile = stdout;
|
|
166
|
|
167 /* Don't put CRs in the DOC file. */
|
442
|
168 #ifdef WIN32_NATIVE
|
428
|
169 _fmode = O_BINARY;
|
|
170 _setmode (fileno (stdout), O_BINARY);
|
442
|
171 #endif /* WIN32_NATIVE */
|
428
|
172
|
|
173 /* If first two args are -o FILE, output to FILE. */
|
|
174 i = 1;
|
|
175 if (argc > i + 1 && !strcmp (argv[i], "-o"))
|
|
176 {
|
|
177 outfile = fopen (argv[i + 1], WRITE_BINARY);
|
|
178 i += 2;
|
|
179 }
|
|
180 if (argc > i + 1 && !strcmp (argv[i], "-a"))
|
|
181 {
|
|
182 outfile = fopen (argv[i + 1], APPEND_BINARY);
|
|
183 i += 2;
|
|
184 }
|
930
|
185 if (argc > i + 1 && !strcmp (argv[i], "-d"))
|
|
186 {
|
|
187 chdir (argv[i + 1]);
|
|
188 i += 2;
|
|
189 }
|
|
190
|
|
191 /* Additional command line arguments for XEmacs */
|
428
|
192 if (argc > i + 1 && !strcmp (argv[i], "-E"))
|
|
193 {
|
|
194 outfile = fopen (argv[i + 1], APPEND_BINARY);
|
|
195 i += 2;
|
|
196 ellcc = 1;
|
|
197 }
|
814
|
198 if (argc > (i + 1) && !strcmp (argv[i], "-i"))
|
|
199 {
|
|
200 extra_elcs = argv[i + 1];
|
|
201 i += 2;
|
|
202 }
|
428
|
203
|
|
204 if (outfile == 0)
|
|
205 fatal ("No output file specified", "");
|
|
206
|
930
|
207 /* XEmacs addition */
|
428
|
208 if (ellcc)
|
|
209 fprintf (outfile, "{\n");
|
|
210
|
|
211 first_infile = i;
|
|
212 for (; i < argc; i++)
|
|
213 {
|
930
|
214 /* XEmacs addition: the "if" clause is new; the "else" clause is the
|
|
215 original FSF Emacs code */
|
771
|
216 if (argv[i][0] == '@')
|
|
217 {
|
|
218 /* Allow a file containing files to process, for use w/MS Windows
|
|
219 (where command-line length limits are more problematic) */
|
|
220 FILE *argfile = fopen (argv[i] + 1, READ_TEXT);
|
|
221 char arg[PATH_MAX];
|
|
222
|
|
223 if (!argfile)
|
|
224 fatal ("Unable to open argument file %s", argv[i] + 1);
|
|
225 while (fgets (arg, PATH_MAX, argfile))
|
|
226 {
|
|
227 if (arg[strlen (arg) - 1] == '\n')
|
|
228 arg[strlen (arg) - 1] = '\0'; /* chop \n */
|
|
229 err_count += scan_file (arg);
|
|
230 }
|
|
231 }
|
|
232 else
|
|
233 {
|
|
234 int j;
|
|
235 /* Don't process one file twice. */
|
|
236 for (j = first_infile; j < i; j++)
|
|
237 if (! strcmp (argv[i], argv[j]))
|
|
238 break;
|
|
239 if (j == i)
|
|
240 err_count += scan_file (argv[i]);
|
|
241 }
|
428
|
242 }
|
|
243
|
930
|
244 /* XEmacs addition */
|
814
|
245 if (extra_elcs)
|
|
246 {
|
|
247 char *p;
|
428
|
248
|
814
|
249 while ((p = next_extra_elc (extra_elcs)) != NULL)
|
|
250 err_count += scan_file (p);
|
428
|
251 }
|
|
252
|
|
253 putc ('\n', outfile);
|
|
254 if (ellcc)
|
|
255 fprintf (outfile, "}\n\n");
|
930
|
256 /* End XEmacs addition */
|
|
257
|
428
|
258 #ifndef VMS
|
|
259 exit (err_count > 0);
|
|
260 #endif /* VMS */
|
|
261 return err_count > 0;
|
|
262 }
|
|
263
|
|
264 /* Read file FILENAME and output its doc strings to outfile. */
|
|
265 /* Return 1 if file is not found, 0 if it is found. */
|
|
266
|
|
267 static int
|
442
|
268 scan_file (const char *filename)
|
428
|
269 {
|
|
270 int len = strlen (filename);
|
930
|
271
|
|
272 /* XEmacs change: test ellcc and set Current_file_type in each case */
|
428
|
273 if (ellcc == 0 && len > 4 && !strcmp (filename + len - 4, ".elc"))
|
|
274 {
|
|
275 Current_file_type = elc_file;
|
|
276 return scan_lisp_file (filename, READ_BINARY);
|
|
277 }
|
|
278 else if (ellcc == 0 && len > 3 && !strcmp (filename + len - 3, ".el"))
|
|
279 {
|
|
280 Current_file_type = el_file;
|
|
281 return scan_lisp_file (filename, READ_TEXT);
|
|
282 }
|
|
283 else
|
|
284 {
|
|
285 Current_file_type = c_file;
|
|
286 return scan_c_file (filename, READ_TEXT);
|
|
287 }
|
|
288 }
|
930
|
289
|
|
290 /* XEmacs addition: ISO 2022 handling */
|
814
|
291 static int
|
|
292 getc_skipping_iso2022 (FILE *file)
|
|
293 {
|
|
294 register int c;
|
|
295 /* #### Kludge -- Ignore any ISO2022 sequences */
|
|
296 c = getc (file);
|
|
297 while (c == 27)
|
|
298 {
|
|
299 c = getc (file);
|
|
300 if (c == '$')
|
|
301 c = getc (file);
|
|
302 if (c >= '(' && c <= '/')
|
|
303 c = getc (file);
|
|
304 c = getc (file);
|
|
305 }
|
|
306 return c;
|
|
307 }
|
|
308
|
|
309 enum iso2022_state
|
|
310 {
|
|
311 ISO_NOTHING,
|
|
312 ISO_ESC,
|
|
313 ISO_DOLLAR,
|
|
314 ISO_FINAL_IS_NEXT,
|
|
315 ISO_DOLLAR_AND_FINAL_IS_NEXT
|
|
316 };
|
|
317
|
|
318 static int non_ascii_p;
|
|
319
|
|
320 static int
|
|
321 getc_iso2022 (FILE *file)
|
|
322 {
|
|
323 /* #### Kludge -- Parse ISO2022 sequences (more or less) */
|
|
324 static enum iso2022_state state;
|
|
325 static int prevc;
|
|
326 register int c;
|
|
327 c = getc (file);
|
|
328 switch (state)
|
|
329 {
|
|
330 case ISO_NOTHING:
|
|
331 if (c == 27)
|
|
332 state = ISO_ESC;
|
|
333 break;
|
|
334
|
|
335 case ISO_ESC:
|
|
336 if (c == '$')
|
|
337 state = ISO_DOLLAR;
|
|
338 else if (c >= '(' && c <= '/')
|
|
339 state = ISO_FINAL_IS_NEXT;
|
|
340 else
|
|
341 state = ISO_NOTHING;
|
|
342 break;
|
|
343
|
|
344 case ISO_DOLLAR:
|
|
345 if (c >= '(' && c <= '/')
|
|
346 state = ISO_DOLLAR_AND_FINAL_IS_NEXT;
|
|
347 else if (c >= '@' && c <= 'B') /* ESC $ @ etc */
|
|
348 {
|
|
349 non_ascii_p = 1;
|
|
350 state = ISO_NOTHING;
|
|
351 }
|
|
352 else
|
|
353 state = ISO_NOTHING;
|
|
354 break;
|
|
355
|
|
356 case ISO_FINAL_IS_NEXT:
|
|
357 if (prevc == '(' && c == 'B') /* ESC ( B, invoke ASCII */
|
|
358 non_ascii_p = 0;
|
|
359 else if (prevc == '(' || prevc == ',') /* ESC ( x or ESC , x */
|
|
360 non_ascii_p = 1;
|
|
361 state = ISO_NOTHING;
|
|
362 break;
|
|
363
|
|
364 case ISO_DOLLAR_AND_FINAL_IS_NEXT:
|
|
365 if (prevc == '(' || prevc == ',') /* ESC $ ( x or ESC $ , x */
|
|
366 non_ascii_p = 1;
|
|
367 state = ISO_NOTHING;
|
|
368 break;
|
|
369 }
|
|
370
|
|
371 prevc = c;
|
|
372 return c;
|
|
373 }
|
|
374
|
428
|
375
|
1111
|
376 char globalbuf[128];
|
428
|
377
|
|
378 /* Skip a C string from INFILE,
|
930
|
379 and return the character that follows the closing ".
|
428
|
380 If printflag is positive, output string contents to outfile.
|
|
381 If it is negative, store contents in buf.
|
|
382 Convert escape sequences \n and \t to newline and tab;
|
|
383 discard \ followed by newline. */
|
|
384
|
814
|
385 #define MDGET do { prevc = c; c = getc_iso2022 (infile); } while (0)
|
428
|
386 static int
|
|
387 read_c_string (FILE *infile, int printflag, int c_docstring)
|
|
388 {
|
442
|
389 register int prevc = 0, c = 0;
|
1111
|
390 char *p = globalbuf;
|
930
|
391 int start = -1; /* XEmacs addition */
|
428
|
392
|
442
|
393 MDGET;
|
428
|
394 while (c != EOF)
|
|
395 {
|
814
|
396 while ((c_docstring || c != '"' || non_ascii_p) && c != EOF)
|
428
|
397 {
|
930
|
398 /* XEmacs addition: the first two "if" clauses are new */
|
814
|
399 if (c == '*' && !non_ascii_p)
|
428
|
400 {
|
442
|
401 int cc = getc (infile);
|
|
402 if (cc == '/')
|
428
|
403 {
|
442
|
404 if (prevc != '\n')
|
|
405 {
|
|
406 if (printflag > 0)
|
|
407 {
|
|
408 if (ellcc)
|
|
409 fprintf (outfile, "\\n\\");
|
|
410 putc ('\n', outfile);
|
|
411 }
|
|
412 else if (printflag < 0)
|
|
413 *p++ = '\n';
|
|
414 }
|
|
415 break;
|
428
|
416 }
|
442
|
417 else
|
|
418 ungetc (cc, infile);
|
|
419 }
|
428
|
420
|
442
|
421 if (start == 1)
|
|
422 {
|
|
423 if (printflag > 0)
|
428
|
424 {
|
442
|
425 if (ellcc)
|
|
426 fprintf (outfile, "\\n\\");
|
|
427 putc ('\n', outfile);
|
428
|
428 }
|
442
|
429 else if (printflag < 0)
|
|
430 *p++ = '\n';
|
428
|
431 }
|
930
|
432 /* End XEmacs addition */
|
428
|
433
|
814
|
434 if (c == '\\' && !non_ascii_p)
|
428
|
435 {
|
442
|
436 MDGET;
|
428
|
437 if (c == '\n')
|
|
438 {
|
442
|
439 MDGET;
|
428
|
440 start = 1;
|
|
441 continue;
|
|
442 }
|
|
443 if (!c_docstring && c == 'n')
|
|
444 c = '\n';
|
|
445 if (c == 't')
|
|
446 c = '\t';
|
|
447 }
|
930
|
448
|
|
449 /* XEmacs change: the "if" clause is new; the "else" clause is
|
|
450 mostly the original FSF Emacs code */
|
428
|
451 if (c == '\n')
|
|
452 start = 1;
|
|
453 else
|
|
454 {
|
|
455 start = 0;
|
442
|
456 if (printflag > 0)
|
|
457 {
|
814
|
458 if (ellcc && c == '"' && !non_ascii_p)
|
442
|
459 putc ('\\', outfile);
|
|
460 putc (c, outfile);
|
|
461 }
|
428
|
462 else if (printflag < 0)
|
|
463 *p++ = c;
|
|
464 }
|
442
|
465 MDGET;
|
428
|
466 }
|
930
|
467 /* XEmacs change: look for continuation of string */
|
428
|
468 if (Current_file_type == c_file)
|
|
469 {
|
442
|
470 do
|
|
471 {
|
|
472 MDGET;
|
|
473 }
|
|
474 while (isspace (c));
|
814
|
475 if (c != '"' || non_ascii_p)
|
428
|
476 break;
|
|
477 }
|
|
478 else
|
|
479 {
|
442
|
480 MDGET;
|
814
|
481 if (c != '"' || non_ascii_p)
|
428
|
482 break;
|
|
483 /* If we had a "", concatenate the two strings. */
|
|
484 }
|
442
|
485 MDGET;
|
428
|
486 }
|
930
|
487
|
428
|
488 if (printflag < 0)
|
|
489 *p = 0;
|
930
|
490
|
428
|
491 return c;
|
|
492 }
|
|
493
|
|
494 /* Write to file OUT the argument names of function FUNC, whose text is in BUF.
|
|
495 MINARGS and MAXARGS are the minimum and maximum number of arguments. */
|
|
496
|
|
497 static void
|
930
|
498 write_c_args (FILE *out, const char *func, char *buf, int minargs, int maxargs)
|
428
|
499 {
|
|
500 register char *p;
|
|
501 int in_ident = 0;
|
|
502 int just_spaced = 0;
|
|
503 #if 0
|
|
504 int need_space = 1;
|
|
505
|
|
506 fprintf (out, "(%s", func);
|
|
507 #else
|
|
508 /* XEmacs - "arguments:" is for parsing the docstring. FSF's help system
|
|
509 doesn't parse the docstring for arguments like we do, so we're also
|
|
510 going to omit the function name to preserve compatibility with elisp
|
|
511 that parses the docstring. Finally, not prefixing the arglist with
|
|
512 anything is asking for trouble because it's not uncommon to have an
|
|
513 unescaped parenthesis at the beginning of a line. --Stig */
|
|
514 fprintf (out, "arguments: (");
|
|
515 #endif
|
|
516
|
930
|
517 if (*buf == '(')
|
|
518 ++buf;
|
428
|
519
|
930
|
520 for (p = buf; *p; p++)
|
428
|
521 {
|
|
522 char c = *p;
|
|
523 int ident_start = 0;
|
|
524
|
930
|
525 /* XEmacs addition: add support for ANSI prototypes. Hop over
|
428
|
526 "Lisp_Object" string (the only C type allowed in DEFUNs) */
|
|
527 static char lo[] = "Lisp_Object";
|
|
528 if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident &&
|
|
529 (strncmp (p, lo, sizeof (lo) - 1) == 0) &&
|
930
|
530 isspace ((unsigned char) p[sizeof (lo) - 1]))
|
428
|
531 {
|
|
532 p += (sizeof (lo) - 1);
|
438
|
533 while (isspace ((unsigned char) (*p)))
|
428
|
534 p++;
|
|
535 c = *p;
|
|
536 }
|
|
537
|
|
538 /* Notice when we start printing a new identifier. */
|
|
539 if (C_IDENTIFIER_CHAR_P (c) != in_ident)
|
|
540 {
|
|
541 if (!in_ident)
|
|
542 {
|
|
543 in_ident = 1;
|
|
544 ident_start = 1;
|
|
545 #if 0
|
|
546 /* XEmacs - This goes along with the change above. */
|
|
547 if (need_space)
|
|
548 putc (' ', out);
|
|
549 #endif
|
|
550 if (minargs == 0 && maxargs > 0)
|
|
551 fprintf (out, "&optional ");
|
|
552 just_spaced = 1;
|
|
553
|
|
554 minargs--;
|
|
555 maxargs--;
|
|
556 }
|
|
557 else
|
|
558 in_ident = 0;
|
|
559 }
|
|
560
|
|
561 /* Print the C argument list as it would appear in lisp:
|
930
|
562 print underscores as hyphens, and print commas and newlines
|
|
563 as spaces. Collapse adjacent spaces into one. */
|
|
564 if (c == '_')
|
|
565 c = '-';
|
|
566 else if (c == ',' || c == '\n')
|
|
567 c = ' ';
|
428
|
568
|
930
|
569 #if 0
|
|
570 /* In C code, `default' is a reserved word, so we spell it
|
|
571 `defalt'; unmangle that here. */
|
|
572 if (ident_start
|
|
573 && strncmp (p, "defalt", 6) == 0
|
|
574 && ! (('A' <= p[6] && p[6] <= 'Z')
|
|
575 || ('a' <= p[6] && p[6] <= 'z')
|
|
576 || ('0' <= p[6] && p[6] <= '9')
|
|
577 || p[6] == '_'))
|
|
578 {
|
|
579 fprintf (out, "DEFAULT");
|
|
580 p += 5;
|
|
581 in_ident = 0;
|
|
582 just_spaced = 0;
|
|
583 }
|
|
584 #endif
|
428
|
585 /* If the C argument name ends with `_', change it to ' ',
|
|
586 to allow use of C reserved words or global symbols as Lisp args. */
|
|
587 if (c == '-' && ! C_IDENTIFIER_CHAR_P (p[1]))
|
|
588 {
|
|
589 in_ident = 0;
|
|
590 just_spaced = 0;
|
|
591 }
|
930
|
592 else if (c != ' ' || !just_spaced)
|
428
|
593 {
|
|
594 if (c >= 'a' && c <= 'z')
|
|
595 /* Upcase the letter. */
|
|
596 c += 'A' - 'a';
|
|
597 putc (c, out);
|
|
598 }
|
|
599
|
|
600 just_spaced = (c == ' ');
|
|
601 #if 0
|
|
602 need_space = 0;
|
|
603 #endif
|
|
604 }
|
930
|
605 /* XEmacs addition */
|
428
|
606 if (!ellcc)
|
930
|
607 putc ('\n', out);
|
428
|
608 }
|
|
609
|
771
|
610 /* Read through a c file. If a .o or .obj file is named,
|
428
|
611 the corresponding .c file is read instead.
|
|
612 Looks for DEFUN constructs such as are defined in ../src/lisp.h.
|
930
|
613 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED ...
|
|
614 which don't exist anymore! */
|
428
|
615
|
|
616 static int
|
442
|
617 scan_c_file (const char *filename, const char *mode)
|
428
|
618 {
|
|
619 FILE *infile;
|
|
620 register int c;
|
|
621 register int commas;
|
|
622 register int defunflag;
|
|
623 register int defvarperbufferflag = 0;
|
|
624 register int defvarflag;
|
|
625 int minargs, maxargs;
|
|
626 int l = strlen (filename);
|
771
|
627 char f[PATH_MAX];
|
428
|
628
|
930
|
629 /* XEmacs change: different method for checking filename extension */
|
|
630 if (l > PATH_MAX - 1)
|
647
|
631 {
|
428
|
632 #ifdef ENAMETOOLONG
|
647
|
633 errno = ENAMETOOLONG;
|
428
|
634 #else
|
647
|
635 errno = EINVAL;
|
428
|
636 #endif
|
930
|
637 return 0;
|
647
|
638 }
|
428
|
639
|
|
640 strcpy (f, filename);
|
771
|
641 if (l > 4 && !strcmp (f + l - 4, ".obj")) /* MS Windows */
|
|
642 strcpy (f + l - 4, ".c");
|
428
|
643 if (f[l - 1] == 'o')
|
|
644 f[l - 1] = 'c';
|
|
645 infile = fopen (f, mode);
|
|
646
|
|
647 /* No error if non-ex input file */
|
|
648 if (infile == NULL)
|
|
649 {
|
|
650 perror (f);
|
|
651 return 0;
|
|
652 }
|
|
653
|
930
|
654 #if 0
|
|
655 /* Reset extension to be able to detect duplicate files. */
|
|
656 filename[strlen (filename) - 1] = extension;
|
|
657 #endif
|
|
658
|
428
|
659 c = '\n';
|
|
660 while (!feof (infile))
|
|
661 {
|
|
662 if (c != '\n')
|
|
663 {
|
|
664 c = getc (infile);
|
|
665 continue;
|
|
666 }
|
|
667 c = getc (infile);
|
|
668 if (c == ' ')
|
|
669 {
|
|
670 while (c == ' ')
|
|
671 c = getc (infile);
|
|
672 if (c != 'D')
|
|
673 continue;
|
|
674 c = getc (infile);
|
|
675 if (c != 'E')
|
|
676 continue;
|
|
677 c = getc (infile);
|
|
678 if (c != 'F')
|
|
679 continue;
|
|
680 c = getc (infile);
|
|
681 if (c != 'V')
|
|
682 continue;
|
|
683 c = getc (infile);
|
|
684 if (c != 'A')
|
|
685 continue;
|
|
686 c = getc (infile);
|
|
687 if (c != 'R')
|
|
688 continue;
|
|
689 c = getc (infile);
|
|
690 if (c != '_')
|
|
691 continue;
|
|
692
|
|
693 defvarflag = 1;
|
|
694 defunflag = 0;
|
|
695
|
|
696 c = getc (infile);
|
|
697 /* Note that this business doesn't apply under XEmacs.
|
|
698 DEFVAR_BUFFER_LOCAL in XEmacs behaves normally. */
|
|
699 defvarperbufferflag = (c == 'P');
|
|
700
|
|
701 c = getc (infile);
|
|
702 }
|
|
703 else if (c == 'D')
|
|
704 {
|
|
705 c = getc (infile);
|
|
706 if (c != 'E')
|
|
707 continue;
|
|
708 c = getc (infile);
|
|
709 if (c != 'F')
|
|
710 continue;
|
|
711 c = getc (infile);
|
|
712 defunflag = (c == 'U');
|
|
713 defvarflag = 0;
|
930
|
714 c = getc (infile); /* XEmacs addition */
|
428
|
715 }
|
|
716 else continue;
|
|
717
|
|
718 while (c != '(')
|
|
719 {
|
|
720 if (c < 0)
|
|
721 goto eof;
|
|
722 c = getc (infile);
|
|
723 }
|
|
724
|
|
725 c = getc (infile);
|
|
726 if (c != '"')
|
|
727 continue;
|
|
728 c = read_c_string (infile, -1, 0);
|
|
729
|
|
730 if (defunflag)
|
|
731 commas = 4;
|
|
732 else if (defvarperbufferflag)
|
|
733 commas = 2;
|
|
734 else if (defvarflag)
|
|
735 commas = 1;
|
930
|
736 else /* For DEFSIMPLE and DEFPRED ... which now don't exist! */
|
428
|
737 commas = 2;
|
|
738
|
|
739 while (commas)
|
|
740 {
|
|
741 if (c == ',')
|
|
742 {
|
|
743 commas--;
|
|
744 if (defunflag && (commas == 1 || commas == 2))
|
|
745 {
|
|
746 do
|
|
747 c = getc (infile);
|
930
|
748 while (c == ' ' || c == '\n' || c == '\t');
|
428
|
749 if (c < 0)
|
|
750 goto eof;
|
|
751 ungetc (c, infile);
|
|
752 if (commas == 2) /* pick up minargs */
|
|
753 fscanf (infile, "%d", &minargs);
|
930
|
754 else /* pick up maxargs */
|
428
|
755 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */
|
|
756 maxargs = -1;
|
|
757 else
|
|
758 fscanf (infile, "%d", &maxargs);
|
|
759 }
|
|
760 }
|
|
761 if (c < 0)
|
|
762 goto eof;
|
|
763 c = getc (infile);
|
|
764 }
|
|
765 while (c == ' ' || c == '\n' || c == '\t')
|
|
766 c = getc (infile);
|
|
767 if (c == '"')
|
|
768 c = read_c_string (infile, 0, 0);
|
930
|
769 /* XEmacs change */
|
428
|
770 if (defunflag | defvarflag)
|
|
771 {
|
|
772 while (c != '/')
|
853
|
773 {
|
|
774 if (c < 0)
|
|
775 goto eof;
|
930
|
776 if (defunflag && c == '(')
|
1111
|
777 fatal ("Missing doc string for DEFUN %s\n", globalbuf);
|
853
|
778 c = getc (infile);
|
|
779 }
|
428
|
780 c = getc (infile);
|
|
781 while (c == '*')
|
|
782 c = getc (infile);
|
|
783 }
|
|
784 else
|
|
785 {
|
|
786 while (c != ',')
|
853
|
787 {
|
|
788 if (c < 0)
|
|
789 goto eof;
|
|
790 c = getc (infile);
|
|
791 }
|
428
|
792 c = getc (infile);
|
|
793 }
|
930
|
794 /* End XEmacs change */
|
428
|
795 while (c == ' ' || c == '\n' || c == '\t')
|
|
796 c = getc (infile);
|
930
|
797 /* XEmacs addition */
|
428
|
798 if (defunflag | defvarflag)
|
|
799 ungetc (c, infile);
|
930
|
800 /* End XEmacs addition */
|
428
|
801
|
|
802 if (defunflag || defvarflag || c == '"')
|
|
803 {
|
930
|
804 /* XEmacs change: the original code is in the "else" clause */
|
814
|
805 if (ellcc)
|
|
806 fprintf (outfile, " CDOC%s(\"%s\", \"\\\n",
|
1111
|
807 defvarflag ? "SYM" : "SUBR", globalbuf);
|
814
|
808 else
|
|
809 {
|
|
810 putc (037, outfile);
|
|
811 putc (defvarflag ? 'V' : 'F', outfile);
|
1111
|
812 fprintf (outfile, "%s\n", globalbuf);
|
814
|
813 }
|
930
|
814 c = read_c_string (infile, 1, defunflag || defvarflag);
|
428
|
815
|
|
816 /* If this is a defun, find the arguments and print them. If
|
|
817 this function takes MANY or UNEVALLED args, then the C source
|
|
818 won't give the names of the arguments, so we shouldn't bother
|
|
819 trying to find them. */
|
|
820 if (defunflag && maxargs != -1)
|
|
821 {
|
|
822 char argbuf[1024], *p = argbuf;
|
814
|
823 #if 0 /* For old DEFUN's only */
|
428
|
824 while (c != ')')
|
|
825 {
|
|
826 if (c < 0)
|
|
827 goto eof;
|
|
828 c = getc (infile);
|
|
829 }
|
|
830 #endif
|
|
831 /* Skip into arguments. */
|
|
832 while (c != '(')
|
|
833 {
|
|
834 if (c < 0)
|
|
835 goto eof;
|
|
836 c = getc (infile);
|
|
837 }
|
|
838 /* Copy arguments into ARGBUF. */
|
|
839 *p++ = c;
|
|
840 do
|
853
|
841 {
|
|
842 *p++ = c = getc (infile);
|
|
843 if (c < 0)
|
|
844 goto eof;
|
|
845 }
|
428
|
846 while (c != ')');
|
|
847 *p = '\0';
|
|
848 /* Output them. */
|
814
|
849 if (ellcc)
|
|
850 fprintf (outfile, "\\n\\\n\\n\\\n");
|
|
851 else
|
|
852 fprintf (outfile, "\n\n");
|
1111
|
853 write_c_args (outfile, globalbuf, argbuf, minargs, maxargs);
|
428
|
854 }
|
814
|
855 if (ellcc)
|
|
856 fprintf (outfile, "\\n\");\n\n");
|
428
|
857 }
|
|
858 }
|
|
859 eof:
|
|
860 fclose (infile);
|
|
861 return 0;
|
|
862 }
|
|
863
|
|
864 /* Read a file of Lisp code, compiled or interpreted.
|
930
|
865 Looks for
|
|
866 (defun NAME ARGS DOCSTRING ...)
|
|
867 (defmacro NAME ARGS DOCSTRING ...)
|
|
868 (defsubst NAME ARGS DOCSTRING ...)
|
|
869 (autoload (quote NAME) FILE DOCSTRING ...)
|
|
870 (defvar NAME VALUE DOCSTRING)
|
|
871 (defconst NAME VALUE DOCSTRING)
|
|
872 (fset (quote NAME) (make-byte-code ... DOCSTRING ...))
|
|
873 (fset (quote NAME) #[... DOCSTRING ...])
|
|
874 (defalias (quote NAME) #[... DOCSTRING ...])
|
|
875 (custom-declare-variable (quote NAME) VALUE DOCSTRING ...)
|
|
876 starting in column zero.
|
|
877 (quote NAME) may appear as 'NAME as well.
|
428
|
878
|
|
879 We also look for #@LENGTH CONTENTS^_ at the beginning of the line.
|
|
880 When we find that, we save it for the following defining-form,
|
|
881 and we use that instead of reading a doc string within that defining-form.
|
|
882
|
930
|
883 For defvar, defconst, and fset we skip to the docstring with a kludgy
|
428
|
884 formatting convention: all docstrings must appear on the same line as the
|
930
|
885 initial open-paren (the one in column zero) and must contain a backslash
|
|
886 and a newline immediately after the initial double-quote. No newlines
|
428
|
887 must appear between the beginning of the form and the first double-quote.
|
930
|
888 For defun, defmacro, and autoload, we know how to skip over the
|
|
889 arglist, but the doc string must still have a backslash and newline
|
|
890 immediately after the double quote.
|
|
891 The only source files that must follow this convention are preloaded
|
|
892 uncompiled ones like loaddefs.el and bindings.el; aside
|
428
|
893 from that, it is always the .elc file that we look at, and they are no
|
|
894 problem because byte-compiler output follows this convention.
|
|
895 The NAME and DOCSTRING are output.
|
|
896 NAME is preceded by `F' for a function or `V' for a variable.
|
|
897 An entry is output only if DOCSTRING has \ newline just after the opening "
|
|
898 */
|
|
899
|
|
900 static void
|
|
901 skip_white (FILE *infile)
|
|
902 {
|
|
903 char c = ' ';
|
|
904 while (c == ' ' || c == '\t' || c == '\n')
|
|
905 c = getc (infile);
|
|
906 ungetc (c, infile);
|
|
907 }
|
|
908
|
|
909 static void
|
|
910 read_lisp_symbol (FILE *infile, char *buffer)
|
|
911 {
|
|
912 char c;
|
|
913 char *fillp = buffer;
|
|
914
|
|
915 skip_white (infile);
|
|
916 while (1)
|
|
917 {
|
|
918 c = getc (infile);
|
|
919 if (c == '\\')
|
|
920 /* FSF has *(++fillp), which is wrong. */
|
|
921 *fillp++ = getc (infile);
|
|
922 else if (c == ' ' || c == '\t' || c == '\n' || c == '(' || c == ')')
|
|
923 {
|
|
924 ungetc (c, infile);
|
|
925 *fillp = 0;
|
|
926 break;
|
|
927 }
|
|
928 else
|
|
929 *fillp++ = c;
|
|
930 }
|
|
931
|
|
932 if (! buffer[0])
|
|
933 fprintf (stderr, "## expected a symbol, got '%c'\n", c);
|
814
|
934
|
428
|
935 skip_white (infile);
|
|
936 }
|
|
937
|
|
938 static int
|
442
|
939 scan_lisp_file (const char *filename, const char *mode)
|
428
|
940 {
|
|
941 FILE *infile;
|
|
942 register int c;
|
|
943 char *saved_string = 0;
|
|
944
|
|
945 infile = fopen (filename, mode);
|
|
946 if (infile == NULL)
|
|
947 {
|
|
948 perror (filename);
|
930
|
949 return 0; /* No error */
|
428
|
950 }
|
|
951
|
|
952 c = '\n';
|
|
953 while (!feof (infile))
|
|
954 {
|
|
955 char buffer[BUFSIZ];
|
|
956 char type;
|
|
957
|
930
|
958 /* If not at end of line, skip till we get to one. */
|
428
|
959 if (c != '\n')
|
|
960 {
|
814
|
961 c = getc_skipping_iso2022 (infile);
|
428
|
962 continue;
|
|
963 }
|
930
|
964 /* Skip the line break. */
|
|
965 while (c == '\n')
|
|
966 c = getc_skipping_iso2022 (infile);
|
428
|
967 /* Detect a dynamic doc string and save it for the next expression. */
|
|
968 if (c == '#')
|
|
969 {
|
814
|
970 c = getc_skipping_iso2022 (infile);
|
428
|
971 if (c == '@')
|
|
972 {
|
|
973 int length = 0;
|
|
974 int i;
|
|
975
|
|
976 /* Read the length. */
|
814
|
977 while ((c = getc_skipping_iso2022 (infile),
|
428
|
978 c >= '0' && c <= '9'))
|
|
979 {
|
|
980 length *= 10;
|
|
981 length += c - '0';
|
|
982 }
|
|
983
|
|
984 /* The next character is a space that is counted in the length
|
|
985 but not part of the doc string.
|
|
986 We already read it, so just ignore it. */
|
|
987 length--;
|
|
988
|
|
989 /* Read in the contents. */
|
|
990 if (saved_string != 0)
|
|
991 free (saved_string);
|
|
992 saved_string = (char *) xmalloc (length);
|
|
993 for (i = 0; i < length; i++)
|
|
994 saved_string[i] = getc (infile);
|
|
995 /* The last character is a ^_.
|
|
996 That is needed in the .elc file
|
|
997 but it is redundant in DOC. So get rid of it here. */
|
|
998 saved_string[length - 1] = 0;
|
930
|
999 /* Skip the line break. */
|
|
1000 while (c == '\n')
|
|
1001 c = getc_skipping_iso2022 (infile);
|
|
1002 /* Skip the following line. */
|
428
|
1003 while (c != '\n')
|
930
|
1004 c = getc_skipping_iso2022 (infile);
|
428
|
1005 }
|
|
1006 continue;
|
|
1007 }
|
|
1008
|
|
1009 if (c != '(')
|
|
1010 continue;
|
|
1011
|
|
1012 read_lisp_symbol (infile, buffer);
|
|
1013
|
930
|
1014 if (! strcmp (buffer, "defun")
|
|
1015 || ! strcmp (buffer, "defmacro")
|
|
1016 || ! strcmp (buffer, "defsubst"))
|
428
|
1017 {
|
|
1018 type = 'F';
|
|
1019 read_lisp_symbol (infile, buffer);
|
|
1020
|
|
1021 /* Skip the arguments: either "nil" or a list in parens */
|
|
1022
|
814
|
1023 c = getc_skipping_iso2022 (infile);
|
930
|
1024 if (c == 'n') /* nil */
|
428
|
1025 {
|
814
|
1026 if ((c = getc_skipping_iso2022 (infile)) != 'i' ||
|
|
1027 (c = getc_skipping_iso2022 (infile)) != 'l')
|
428
|
1028 {
|
|
1029 fprintf (stderr, "## unparsable arglist in %s (%s)\n",
|
|
1030 buffer, filename);
|
|
1031 continue;
|
|
1032 }
|
|
1033 }
|
|
1034 else if (c != '(')
|
|
1035 {
|
|
1036 fprintf (stderr, "## unparsable arglist in %s (%s)\n",
|
|
1037 buffer, filename);
|
|
1038 continue;
|
|
1039 }
|
|
1040 else
|
|
1041 while (c != ')')
|
853
|
1042 {
|
|
1043 c = getc_skipping_iso2022 (infile);
|
|
1044 if (c < 0)
|
|
1045 continue;
|
|
1046 }
|
428
|
1047 skip_white (infile);
|
|
1048
|
|
1049 /* If the next three characters aren't `dquote bslash newline'
|
|
1050 then we're not reading a docstring.
|
930
|
1051 */
|
814
|
1052 if ((c = getc_skipping_iso2022 (infile)) != '"' ||
|
|
1053 (c = getc_skipping_iso2022 (infile)) != '\\' ||
|
|
1054 (c = getc_skipping_iso2022 (infile)) != '\n')
|
428
|
1055 {
|
|
1056 #ifdef DEBUG
|
|
1057 fprintf (stderr, "## non-docstring in %s (%s)\n",
|
|
1058 buffer, filename);
|
|
1059 #endif
|
|
1060 continue;
|
|
1061 }
|
|
1062 }
|
|
1063
|
930
|
1064 else if (! strcmp (buffer, "defvar")
|
|
1065 || ! strcmp (buffer, "defconst"))
|
428
|
1066 {
|
|
1067 char c1 = 0, c2 = 0;
|
|
1068 type = 'V';
|
|
1069 read_lisp_symbol (infile, buffer);
|
|
1070
|
|
1071 if (saved_string == 0)
|
|
1072 {
|
|
1073
|
930
|
1074 /* Skip until the end of line; remember two previous chars. */
|
428
|
1075 while (c != '\n' && c >= 0)
|
|
1076 {
|
|
1077 c2 = c1;
|
|
1078 c1 = c;
|
814
|
1079 c = getc_skipping_iso2022 (infile);
|
428
|
1080 }
|
930
|
1081
|
|
1082 /* If two previous characters were " and \,
|
|
1083 this is a doc string. Otherwise, there is none. */
|
|
1084 if (c2 != '"' || c1 != '\\')
|
|
1085 {
|
|
1086 #ifdef DEBUG
|
|
1087 fprintf (stderr, "## non-docstring in %s (%s)\n",
|
|
1088 buffer, filename);
|
|
1089 #endif
|
|
1090 continue;
|
|
1091 }
|
|
1092 }
|
|
1093 }
|
428
|
1094
|
930
|
1095 else if (! strcmp (buffer, "custom-declare-variable"))
|
|
1096 {
|
|
1097 char c1 = 0, c2 = 0;
|
|
1098 type = 'V';
|
|
1099
|
|
1100 c = getc (infile);
|
|
1101 if (c == '\'')
|
|
1102 read_lisp_symbol (infile, buffer);
|
|
1103 else
|
|
1104 {
|
|
1105 if (c != '(')
|
|
1106 {
|
|
1107 fprintf (stderr,
|
|
1108 "## unparsable name in custom-declare-variable in %s\n",
|
|
1109 filename);
|
|
1110 continue;
|
|
1111 }
|
|
1112 read_lisp_symbol (infile, buffer);
|
|
1113 if (strcmp (buffer, "quote"))
|
|
1114 {
|
|
1115 fprintf (stderr,
|
|
1116 "## unparsable name in custom-declare-variable in %s\n",
|
|
1117 filename);
|
|
1118 continue;
|
|
1119 }
|
|
1120 read_lisp_symbol (infile, buffer);
|
|
1121 c = getc (infile);
|
|
1122 if (c != ')')
|
|
1123 {
|
|
1124 fprintf (stderr,
|
|
1125 "## unparsable quoted name in custom-declare-variable in %s\n",
|
|
1126 filename);
|
|
1127 continue;
|
|
1128 }
|
|
1129 }
|
|
1130
|
|
1131 if (saved_string == 0)
|
|
1132 {
|
|
1133 /* Skip to end of line; remember the two previous chars. */
|
|
1134 while (c != '\n' && c >= 0)
|
|
1135 {
|
|
1136 c2 = c1;
|
|
1137 c1 = c;
|
|
1138 c = getc_skipping_iso2022 (infile);
|
|
1139 }
|
|
1140
|
428
|
1141 /* If two previous characters were " and \,
|
|
1142 this is a doc string. Otherwise, there is none. */
|
|
1143 if (c2 != '"' || c1 != '\\')
|
|
1144 {
|
|
1145 #ifdef DEBUG
|
|
1146 fprintf (stderr, "## non-docstring in %s (%s)\n",
|
|
1147 buffer, filename);
|
|
1148 #endif
|
|
1149 continue;
|
|
1150 }
|
|
1151 }
|
|
1152 }
|
|
1153
|
|
1154 else if (! strcmp (buffer, "fset") || ! strcmp (buffer, "defalias"))
|
|
1155 {
|
|
1156 char c1 = 0, c2 = 0;
|
|
1157 type = 'F';
|
|
1158
|
814
|
1159 c = getc_skipping_iso2022 (infile);
|
428
|
1160 if (c == '\'')
|
|
1161 read_lisp_symbol (infile, buffer);
|
|
1162 else
|
|
1163 {
|
|
1164 if (c != '(')
|
|
1165 {
|
|
1166 fprintf (stderr, "## unparsable name in fset in %s\n",
|
|
1167 filename);
|
|
1168 continue;
|
|
1169 }
|
|
1170 read_lisp_symbol (infile, buffer);
|
|
1171 if (strcmp (buffer, "quote"))
|
|
1172 {
|
|
1173 fprintf (stderr, "## unparsable name in fset in %s\n",
|
|
1174 filename);
|
|
1175 continue;
|
|
1176 }
|
|
1177 read_lisp_symbol (infile, buffer);
|
814
|
1178 c = getc_skipping_iso2022 (infile);
|
428
|
1179 if (c != ')')
|
|
1180 {
|
|
1181 fprintf (stderr,
|
|
1182 "## unparsable quoted name in fset in %s\n",
|
|
1183 filename);
|
|
1184 continue;
|
|
1185 }
|
|
1186 }
|
|
1187
|
|
1188 if (saved_string == 0)
|
|
1189 {
|
930
|
1190 /* Skip to end of line; remember the two previous chars. */
|
428
|
1191 while (c != '\n' && c >= 0)
|
|
1192 {
|
|
1193 c2 = c1;
|
|
1194 c1 = c;
|
814
|
1195 c = getc_skipping_iso2022 (infile);
|
428
|
1196 }
|
930
|
1197
|
428
|
1198 /* If two previous characters were " and \,
|
|
1199 this is a doc string. Otherwise, there is none. */
|
|
1200 if (c2 != '"' || c1 != '\\')
|
|
1201 {
|
|
1202 #ifdef DEBUG
|
|
1203 fprintf (stderr, "## non-docstring in %s (%s)\n",
|
|
1204 buffer, filename);
|
|
1205 #endif
|
|
1206 continue;
|
|
1207 }
|
|
1208 }
|
|
1209 }
|
|
1210
|
|
1211 else if (! strcmp (buffer, "autoload"))
|
|
1212 {
|
|
1213 type = 'F';
|
814
|
1214 c = getc_skipping_iso2022 (infile);
|
428
|
1215 if (c == '\'')
|
|
1216 read_lisp_symbol (infile, buffer);
|
|
1217 else
|
|
1218 {
|
|
1219 if (c != '(')
|
|
1220 {
|
|
1221 fprintf (stderr, "## unparsable name in autoload in %s\n",
|
|
1222 filename);
|
|
1223 continue;
|
|
1224 }
|
|
1225 read_lisp_symbol (infile, buffer);
|
|
1226 if (strcmp (buffer, "quote"))
|
|
1227 {
|
|
1228 fprintf (stderr, "## unparsable name in autoload in %s\n",
|
|
1229 filename);
|
|
1230 continue;
|
|
1231 }
|
|
1232 read_lisp_symbol (infile, buffer);
|
814
|
1233 c = getc_skipping_iso2022 (infile);
|
428
|
1234 if (c != ')')
|
|
1235 {
|
|
1236 fprintf (stderr,
|
|
1237 "## unparsable quoted name in autoload in %s\n",
|
|
1238 filename);
|
|
1239 continue;
|
|
1240 }
|
|
1241 }
|
|
1242 skip_white (infile);
|
814
|
1243 if ((c = getc_skipping_iso2022 (infile)) != '\"')
|
428
|
1244 {
|
|
1245 fprintf (stderr, "## autoload of %s unparsable (%s)\n",
|
|
1246 buffer, filename);
|
|
1247 continue;
|
|
1248 }
|
|
1249 read_c_string (infile, 0, 0);
|
|
1250 skip_white (infile);
|
|
1251
|
|
1252 if (saved_string == 0)
|
|
1253 {
|
|
1254 /* If the next three characters aren't `dquote bslash newline'
|
|
1255 then we're not reading a docstring. */
|
814
|
1256 if ((c = getc_skipping_iso2022 (infile)) != '"' ||
|
|
1257 (c = getc_skipping_iso2022 (infile)) != '\\' ||
|
|
1258 (c = getc_skipping_iso2022 (infile)) != '\n')
|
428
|
1259 {
|
|
1260 #ifdef DEBUG
|
|
1261 fprintf (stderr, "## non-docstring in %s (%s)\n",
|
|
1262 buffer, filename);
|
|
1263 #endif
|
|
1264 continue;
|
|
1265 }
|
|
1266 }
|
|
1267 }
|
|
1268
|
814
|
1269 #if 0 /* causes crash */
|
930
|
1270 else if (! strcmp (buffer, "if")
|
|
1271 || ! strcmp (buffer, "byte-code"))
|
428
|
1272 ;
|
|
1273 #endif
|
|
1274
|
|
1275 else
|
|
1276 {
|
|
1277 #ifdef DEBUG
|
|
1278 fprintf (stderr, "## unrecognized top-level form, %s (%s)\n",
|
|
1279 buffer, filename);
|
|
1280 #endif
|
|
1281 continue;
|
|
1282 }
|
|
1283
|
|
1284 /* At this point, we should either use the previous
|
|
1285 dynamic doc string in saved_string
|
|
1286 or gobble a doc string from the input file.
|
930
|
1287
|
428
|
1288 In the latter case, the opening quote (and leading
|
|
1289 backslash-newline) have already been read. */
|
930
|
1290
|
814
|
1291 putc ('\n', outfile); /* XEmacs addition */
|
428
|
1292 putc (037, outfile);
|
|
1293 putc (type, outfile);
|
|
1294 fprintf (outfile, "%s\n", buffer);
|
|
1295 if (saved_string)
|
|
1296 {
|
|
1297 fputs (saved_string, outfile);
|
|
1298 /* Don't use one dynamic doc string twice. */
|
|
1299 free (saved_string);
|
|
1300 saved_string = 0;
|
|
1301 }
|
|
1302 else
|
|
1303 read_c_string (infile, 1, 0);
|
|
1304 }
|
|
1305 fclose (infile);
|
|
1306 return 0;
|
|
1307 }
|