Mercurial > hg > xemacs-beta
comparison lib-src/make-docfile.c @ 388:aabb7f5b1c81 r21-2-9
Import from CVS: tag r21-2-9
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:09:42 +0200 |
parents | 8626e4521993 |
children | 74fd4e045ea6 |
comparison
equal
deleted
inserted
replaced
387:f892a9d0bb8d | 388:aabb7f5b1c81 |
---|---|
1 /* Generate doc-string file for XEmacs from source files. | 1 /* Generate doc-string file for XEmacs from source files. |
2 Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc. | 2 Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc. |
3 Copyright (C) 1995 Board of Trustees, University of Illinois | 3 Copyright (C) 1995 Board of Trustees, University of Illinois. |
4 Copyright (C) 1998, 1999 J. Kean Johnston. | |
4 | 5 |
5 This file is part of XEmacs. | 6 This file is part of XEmacs. |
6 | 7 |
7 XEmacs is free software; you can redistribute it and/or modify it | 8 XEmacs is free software; you can redistribute it and/or modify it |
8 under the terms of the GNU General Public License as published by the | 9 under the terms of the GNU General Public License as published by the |
105 ('0' <= c && c <= '9') || \ | 106 ('0' <= c && c <= '9') || \ |
106 (c == '_')) | 107 (c == '_')) |
107 | 108 |
108 /* Name this program was invoked with. */ | 109 /* Name this program was invoked with. */ |
109 char *progname; | 110 char *progname; |
111 | |
112 /* Set to 1 if this was invoked by ellcc */ | |
113 int ellcc = 0; | |
110 | 114 |
111 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ | 115 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ |
112 | 116 |
113 static void | 117 static void |
114 error (CONST char *s1, CONST char *s2) | 118 error (CONST char *s1, CONST char *s2) |
211 if (argc > i + 1 && !strcmp (argv[i], "-a")) | 215 if (argc > i + 1 && !strcmp (argv[i], "-a")) |
212 { | 216 { |
213 outfile = fopen (argv[i + 1], APPEND_BINARY); | 217 outfile = fopen (argv[i + 1], APPEND_BINARY); |
214 i += 2; | 218 i += 2; |
215 } | 219 } |
220 if (argc > i + 1 && !strcmp (argv[i], "-E")) | |
221 { | |
222 outfile = fopen (argv[i + 1], APPEND_BINARY); | |
223 i += 2; | |
224 ellcc = 1; | |
225 } | |
216 if (argc > i + 1 && !strcmp (argv[i], "-d")) | 226 if (argc > i + 1 && !strcmp (argv[i], "-d")) |
217 { | 227 { |
218 chdir (argv[i + 1]); | 228 chdir (argv[i + 1]); |
219 i += 2; | 229 i += 2; |
220 } | 230 } |
224 i += 2; | 234 i += 2; |
225 } | 235 } |
226 | 236 |
227 if (outfile == 0) | 237 if (outfile == 0) |
228 fatal ("No output file specified", ""); | 238 fatal ("No output file specified", ""); |
239 | |
240 if (ellcc) | |
241 fprintf (outfile, "{\n"); | |
229 | 242 |
230 first_infile = i; | 243 first_infile = i; |
231 for (; i < argc; i++) | 244 for (; i < argc; i++) |
232 { | 245 { |
233 int j; | 246 int j; |
247 err_count += scan_file(p); | 260 err_count += scan_file(p); |
248 } | 261 } |
249 } | 262 } |
250 | 263 |
251 putc ('\n', outfile); | 264 putc ('\n', outfile); |
265 if (ellcc) | |
266 fprintf (outfile, "}\n\n"); | |
252 #ifndef VMS | 267 #ifndef VMS |
253 exit (err_count > 0); | 268 exit (err_count > 0); |
254 #endif /* VMS */ | 269 #endif /* VMS */ |
255 return err_count > 0; | 270 return err_count > 0; |
256 } | 271 } |
260 | 275 |
261 static int | 276 static int |
262 scan_file (CONST char *filename) | 277 scan_file (CONST char *filename) |
263 { | 278 { |
264 int len = strlen (filename); | 279 int len = strlen (filename); |
265 if (len > 4 && !strcmp (filename + len - 4, ".elc")) | 280 if (ellcc == 0 && len > 4 && !strcmp (filename + len - 4, ".elc")) |
266 { | 281 { |
267 Current_file_type = elc_file; | 282 Current_file_type = elc_file; |
268 return scan_lisp_file (filename, READ_BINARY); | 283 return scan_lisp_file (filename, READ_BINARY); |
269 } | 284 } |
270 else if (len > 3 && !strcmp (filename + len - 3, ".el")) | 285 else if (ellcc == 0 && len > 3 && !strcmp (filename + len - 3, ".el")) |
271 { | 286 { |
272 Current_file_type = el_file; | 287 Current_file_type = el_file; |
273 return scan_lisp_file (filename, READ_TEXT); | 288 return scan_lisp_file (filename, READ_TEXT); |
274 } | 289 } |
275 else | 290 else |
312 } | 327 } |
313 | 328 |
314 if (start != -1) | 329 if (start != -1) |
315 { | 330 { |
316 if (printflag > 0) | 331 if (printflag > 0) |
317 putc ('\n', outfile); | 332 { |
333 if (ellcc) | |
334 fprintf (outfile, "\\n\\"); | |
335 putc ('\n', outfile); | |
336 } | |
318 else if (printflag < 0) | 337 else if (printflag < 0) |
319 *p++ = '\n'; | 338 *p++ = '\n'; |
320 } | 339 } |
321 } | 340 } |
322 | 341 |
337 if (c == '\n') | 356 if (c == '\n') |
338 start = 1; | 357 start = 1; |
339 else | 358 else |
340 { | 359 { |
341 start = 0; | 360 start = 0; |
342 if (printflag > 0) | 361 if (printflag > 0) { |
362 if (ellcc && c == '"') | |
363 putc ('\\', outfile); | |
343 putc (c, outfile); | 364 putc (c, outfile); |
365 } | |
344 else if (printflag < 0) | 366 else if (printflag < 0) |
345 *p++ = c; | 367 *p++ = c; |
346 } | 368 } |
347 c = getc (infile); | 369 c = getc (infile); |
348 } | 370 } |
462 just_spaced = (c == ' '); | 484 just_spaced = (c == ' '); |
463 #if 0 | 485 #if 0 |
464 need_space = 0; | 486 need_space = 0; |
465 #endif | 487 #endif |
466 } | 488 } |
467 putc ('\n', out); /* XEmacs addition */ | 489 if (!ellcc) |
490 putc ('\n', out); /* XEmacs addition */ | |
468 } | 491 } |
469 | 492 |
470 /* Read through a c file. If a .o file is named, | 493 /* Read through a c file. If a .o file is named, |
471 the corresponding .c file is read instead. | 494 the corresponding .c file is read instead. |
472 Looks for DEFUN constructs such as are defined in ../src/lisp.h. | 495 Looks for DEFUN constructs such as are defined in ../src/lisp.h. |
637 if (defunflag | defvarflag) | 660 if (defunflag | defvarflag) |
638 ungetc (c, infile); | 661 ungetc (c, infile); |
639 | 662 |
640 if (defunflag || defvarflag || c == '"') | 663 if (defunflag || defvarflag || c == '"') |
641 { | 664 { |
642 putc (037, outfile); | 665 if (ellcc) |
643 putc (defvarflag ? 'V' : 'F', outfile); | 666 fprintf (outfile, " CDOC%s(\"%s\", \"\\\n", |
644 fprintf (outfile, "%s\n", buf); | 667 defvarflag ? "SYM" : "SUBR", buf); |
668 else | |
669 { | |
670 putc (037, outfile); | |
671 putc (defvarflag ? 'V' : 'F', outfile); | |
672 fprintf (outfile, "%s\n", buf); | |
673 } | |
645 c = read_c_string (infile, 1, (defunflag || defvarflag)); | 674 c = read_c_string (infile, 1, (defunflag || defvarflag)); |
646 | 675 |
647 /* If this is a defun, find the arguments and print them. If | 676 /* If this is a defun, find the arguments and print them. If |
648 this function takes MANY or UNEVALLED args, then the C source | 677 this function takes MANY or UNEVALLED args, then the C source |
649 won't give the names of the arguments, so we shouldn't bother | 678 won't give the names of the arguments, so we shouldn't bother |
671 do | 700 do |
672 *p++ = c = getc (infile); | 701 *p++ = c = getc (infile); |
673 while (c != ')'); | 702 while (c != ')'); |
674 *p = '\0'; | 703 *p = '\0'; |
675 /* Output them. */ | 704 /* Output them. */ |
676 fprintf (outfile, "\n\n"); | 705 if (ellcc) |
706 fprintf (outfile, "\\n\\\n\\n\\\n"); | |
707 else | |
708 fprintf (outfile, "\n\n"); | |
677 write_c_args (outfile, buf, argbuf, minargs, maxargs); | 709 write_c_args (outfile, buf, argbuf, minargs, maxargs); |
678 } | 710 } |
711 if (ellcc) | |
712 fprintf (outfile, "\\n\");\n\n"); | |
679 } | 713 } |
680 } | 714 } |
681 eof: | 715 eof: |
682 fclose (infile); | 716 fclose (infile); |
683 return 0; | 717 return 0; |