annotate lib-src/make-docfile.c @ 410:de805c49cfc1 r21-2-35

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