annotate lib-src/make-docfile.c @ 388:aabb7f5b1c81 r21-2-9

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