annotate lib-src/make-docfile.c @ 841:44478bd99873

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