comparison lib-src/make-docfile.c @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents b39c14581166
children a634e3b7acc8
comparison
equal deleted inserted replaced
770:336a418893b5 771:943eaba38521
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 Copyright (C) 1998, 1999 J. Kean Johnston.
5 Copyright (C) 2001 Ben Wing.
5 6
6 This file is part of XEmacs. 7 This file is part of XEmacs.
7 8
8 XEmacs is free software; you can redistribute it and/or modify it 9 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the 10 under the terms of the GNU General Public License as published by the
22 23
23 /* Synched up with: FSF 19.30. */ 24 /* Synched up with: FSF 19.30. */
24 25
25 /* The arguments given to this program are all the C and Lisp source files 26 /* The arguments given to this program are all the C and Lisp source files
26 of XEmacs. .elc and .el and .c files are allowed. 27 of XEmacs. .elc and .el and .c files are allowed.
27 A .o file can also be specified; the .c file it was made from is used. 28 A .o or .obj file can also be specified; the .c file it was made from is used.
28 This helps the makefile pass the correct list of files. 29 This helps the makefile pass the correct list of files.
29 30
30 The results, which go to standard output or to a file 31 The results, which go to standard output or to a file
31 specified with -a or -o (-a to append, -o to start from nothing), 32 specified with -a or -o (-a to append, -o to start from nothing),
32 are entries containing function or variable names and their documentation. 33 are entries containing function or variable names and their documentation.
37 38
38 Added 19.15/20.1: `-i site-packages' allow installer to dump extra packages 39 Added 19.15/20.1: `-i site-packages' allow installer to dump extra packages
39 without modifying Makefiles, etc. 40 without modifying Makefiles, etc.
40 */ 41 */
41 42
42 #define NO_SHORTNAMES /* Tell config not to load remap.h */
43 #include <config.h> 43 #include <config.h>
44 44
45 #include <stdio.h> 45 #include <stdio.h>
46 #include <errno.h>
47 #if __STDC__ || defined(STDC_HEADERS)
48 #include <stdlib.h> 46 #include <stdlib.h>
49 #ifdef HAVE_UNISTD_H
50 #include <unistd.h>
51 #endif
52 #include <string.h> 47 #include <string.h>
53 #include <ctype.h> 48 #include <ctype.h>
54 #endif 49
55 50 #include "../src/sysfile.h"
56 #ifdef CYGWIN 51
57 #include <fcntl.h> 52 /* From src/lisp.h */
58 #endif 53 #define DO_REALLOC(basevar, sizevar, needed_size, type) do { \
59 #ifdef WIN32_NATIVE 54 size_t do_realloc_needed_size = (needed_size); \
60 #include <direct.h> 55 if ((sizevar) < do_realloc_needed_size) \
61 #include <fcntl.h> 56 { \
62 #include <io.h> 57 if ((sizevar) < 32) \
63 #include <stdlib.h> 58 (sizevar) = 32; \
64 #endif /* WIN32_NATIVE */ 59 while ((sizevar) < do_realloc_needed_size) \
65 60 (sizevar) *= 2; \
66 #ifndef WIN32_NATIVE 61 XREALLOC_ARRAY (basevar, type, (sizevar)); \
67 #include <sys/param.h> 62 } \
68 #endif /* not WIN32_NATIVE */ 63 } while (0)
69
70 #if defined(WIN32_NATIVE) || defined(CYGWIN)
71 #define READ_TEXT "rt"
72 #define READ_BINARY "rb"
73 #define WRITE_BINARY "wb"
74 #define APPEND_BINARY "ab"
75 #else /* not WIN32_NATIVE */
76 #define READ_TEXT "r"
77 #define READ_BINARY "r"
78 #define WRITE_BINARY "w"
79 #define APPEND_BINARY "a"
80 #endif /* not WIN32_NATIVE */
81 64
82 /* Stdio stream for output to the DOC file. */ 65 /* Stdio stream for output to the DOC file. */
83 static FILE *outfile; 66 static FILE *outfile;
84 67
85 enum 68 enum
228 211
229 if (ellcc) 212 if (ellcc)
230 fprintf (outfile, "{\n"); 213 fprintf (outfile, "{\n");
231 214
232 first_infile = i; 215 first_infile = i;
216
233 for (; i < argc; i++) 217 for (; i < argc; i++)
234 { 218 {
235 int j; 219 if (argv[i][0] == '@')
236 /* Don't process one file twice. */ 220 {
237 for (j = first_infile; j < i; j++) 221 /* Allow a file containing files to process, for use w/MS Windows
238 if (! strcmp (argv[i], argv[j])) 222 (where command-line length limits are more problematic) */
239 break; 223 FILE *argfile = fopen (argv[i] + 1, READ_TEXT);
240 if (j == i) 224 char arg[PATH_MAX];
241 /* err_count seems to be {mis,un}used */ 225
242 err_count += scan_file (argv[i]); 226 if (!argfile)
227 fatal ("Unable to open argument file %s", argv[i] + 1);
228 while (fgets (arg, PATH_MAX, argfile))
229 {
230 if (arg[strlen (arg) - 1] == '\n')
231 arg[strlen (arg) - 1] = '\0'; /* chop \n */
232 err_count += scan_file (arg);
233 }
234 }
235 else
236 {
237 int j;
238
239 /* Don't process one file twice. */
240 for (j = first_infile; j < i; j++)
241 if (! strcmp (argv[i], argv[j]))
242 break;
243 if (j == i)
244 /* err_count seems to be {mis,un}used */
245 err_count += scan_file (argv[i]);
246 }
243 } 247 }
244 248
245 if (extra_elcs) { 249 if (extra_elcs) {
246 char *p; 250 char *p;
247 251
492 } 496 }
493 if (!ellcc) 497 if (!ellcc)
494 putc ('\n', out); /* XEmacs addition */ 498 putc ('\n', out); /* XEmacs addition */
495 } 499 }
496 500
497 /* Read through a c file. If a .o file is named, 501 /* Read through a c file. If a .o or .obj file is named,
498 the corresponding .c file is read instead. 502 the corresponding .c file is read instead.
499 Looks for DEFUN constructs such as are defined in ../src/lisp.h. 503 Looks for DEFUN constructs such as are defined in ../src/lisp.h.
500 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */ 504 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */
501 505
502 static int 506 static int
508 register int defunflag; 512 register int defunflag;
509 register int defvarperbufferflag = 0; 513 register int defvarperbufferflag = 0;
510 register int defvarflag; 514 register int defvarflag;
511 int minargs, maxargs; 515 int minargs, maxargs;
512 int l = strlen (filename); 516 int l = strlen (filename);
513 char f[MAXPATHLEN]; 517 char f[PATH_MAX];
514 518
515 if (l > (int) sizeof (f)) 519 if (l > (int) sizeof (f))
516 { 520 {
517 #ifdef ENAMETOOLONG 521 #ifdef ENAMETOOLONG
518 errno = ENAMETOOLONG; 522 errno = ENAMETOOLONG;
521 #endif 525 #endif
522 return (0); 526 return (0);
523 } 527 }
524 528
525 strcpy (f, filename); 529 strcpy (f, filename);
530 if (l > 4 && !strcmp (f + l - 4, ".obj")) /* MS Windows */
531 strcpy (f + l - 4, ".c");
526 if (f[l - 1] == 'o') 532 if (f[l - 1] == 'o')
527 f[l - 1] = 'c'; 533 f[l - 1] = 'c';
528 infile = fopen (f, mode); 534 infile = fopen (f, mode);
529 535
530 /* No error if non-ex input file */ 536 /* No error if non-ex input file */