annotate lib-src/make-docfile.c @ 5935:d5eb0914ca1f cygwin

trial of E1 and UE1
author Henry Thompson <ht@markup.co.uk>
date Sat, 12 Dec 2015 21:49:31 +0000
parents 308d34e9f07d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Generate doc-string file for XEmacs from source files.
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
2 Copyright (C) 1985, 86, 92, 93, 94, 97, 1999, 2000, 2001
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
3 Free Software Foundation, Inc.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 Copyright (C) 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 Copyright (C) 1998, 1999 J. Kean Johnston.
5076
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
6 Copyright (C) 2001, 2002, 2010 Ben Wing.
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
7
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
8 This file is part of XEmacs.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
9
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
10 XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
11 under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
12 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
13 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
18 for more details.
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
19
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
20 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
21 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
22
1618
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
23 /* Synched up with: FSF 21.3. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /* The arguments given to this program are all the C and Lisp source files
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
26 of XEmacs. .elc and .el and .c files are allowed.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
27 A .o or .obj file can also be specified; the .c file it was made from is used.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
28 This helps the makefile pass the correct list of files.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
29
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
30 The results, which go to standard output or to a file
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
31 specified with -a or -o (-a to append, -o to start from nothing),
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
32 are entries containing function or variable names and their documentation.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
33 Each entry starts with a ^_ character.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
34 Then comes F for a function or V for a variable.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
35 Then comes the function or variable name, terminated with a newline.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
36 Then comes the documentation for that function or variable.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
37
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
38 Added 19.15/20.1: `-i site-packages' allow installer to dump extra packages
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
39 without modifying Makefiles, etc.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
42 #include <config.h>
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
43 #include <sysfile.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
45 #include <assert.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #include <ctype.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1618
diff changeset
51 #include "compiler.h"
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1618
diff changeset
52
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
53 /* XEmacs addition */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
54 #define C_IDENTIFIER_CHAR_P(c) \
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
55 (('A' <= c && c <= 'Z') || \
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
56 ('a' <= c && c <= 'z') || \
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
57 ('0' <= c && c <= '9') || \
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
58 (c == '_'))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
60 static void put_filename (const char *filename);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
61 static int scan_file (const char *filename);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 static int read_c_string (FILE *, int, int);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
63 static void write_c_args (FILE *out, const char *func, char *buf, int minargs,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 int maxargs);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
65 static int scan_c_file (const char *filename, const char *mode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 static void skip_white (FILE *);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 static void read_lisp_symbol (FILE *, char *);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
68 static int scan_lisp_file (const char *filename, const char *mode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
70 /* Stdio stream for output to the DOC file. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
71 static FILE *outfile;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
72
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
73 /* XEmacs addition */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
74 enum
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
75 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
76 el_file,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
77 elc_file,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
78 c_file
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
79 } Current_file_type;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 /* Name this program was invoked with. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 char *progname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
84 /* XEmacs addition: set to 1 if this was invoked by ellcc */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 int ellcc = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
90 error (const char *s1, const char *s2)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 fprintf (stderr, "%s: ", progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 fprintf (stderr, s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 fprintf (stderr, "\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 /* Print error message and exit. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
100 fatal (const char *s1, const char *s2)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 error (s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 exit (1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 /* Like malloc but get fatal error if memory is exhausted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 static long *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 xmalloc (unsigned int size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 long *result = (long *) malloc (size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 fatal ("virtual memory exhausted", 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
117 /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 static char *
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
119 next_extra_elc (char *extra_elcs)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 static FILE *fp = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 static char line_buf[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 char *p = line_buf+1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
125 if (!fp)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
126 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
127 if (!extra_elcs)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
128 return NULL;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
129 else if (!(fp = fopen (extra_elcs, READ_BINARY)))
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
130 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
131 /* It is not an error if this file doesn't exist. */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
132 /*fatal ("error opening site package file list", 0);*/
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
133 return NULL;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
134 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
135 fgets (line_buf, BUFSIZ, fp);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
136 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
137
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
138 do
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
139 {
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
140 if (!fgets (line_buf, BUFSIZ, fp))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
141 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
142 fclose (fp);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
143 fp = NULL;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
144 return NULL;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
145 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
146 line_buf[0] = '\0';
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
147 /* reject too short or too long lines */
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
148 } while (strlen (p) <= 2 || strlen (p) >= (BUFSIZ - 5));
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
149
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
150 p[strlen (p) - 2] = '\0';
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
151 strcat (p, ".elc");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 return p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 main (int argc, char **argv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 int err_count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 int first_infile;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
163 char *extra_elcs = NULL; /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 progname = argv[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 outfile = stdout;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 /* Don't put CRs in the DOC file. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
170 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 _fmode = O_BINARY;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 _setmode (fileno (stdout), O_BINARY);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
173 #endif /* WIN32_NATIVE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 /* If first two args are -o FILE, output to FILE. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 i = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 if (argc > i + 1 && !strcmp (argv[i], "-o"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 outfile = fopen (argv[i + 1], WRITE_BINARY);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 i += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 if (argc > i + 1 && !strcmp (argv[i], "-a"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 outfile = fopen (argv[i + 1], APPEND_BINARY);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 i += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
187 if (argc > i + 1 && !strcmp (argv[i], "-d"))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
188 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
189 chdir (argv[i + 1]);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
190 i += 2;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
191 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
192
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
193 /* Additional command line arguments for XEmacs */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 if (argc > i + 1 && !strcmp (argv[i], "-E"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 outfile = fopen (argv[i + 1], APPEND_BINARY);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 i += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 ellcc = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 }
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
200 if (argc > (i + 1) && !strcmp (argv[i], "-i"))
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
201 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
202 extra_elcs = argv[i + 1];
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
203 i += 2;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
204 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 if (outfile == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 fatal ("No output file specified", "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
209 /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 if (ellcc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 fprintf (outfile, "{\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 first_infile = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 for (; i < argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 {
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
216 /* XEmacs addition: the "if" clause is new; the "else" clause is the
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
217 original FSF Emacs code */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
218 if (argv[i][0] == '@')
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
219 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
220 /* Allow a file containing files to process, for use w/MS Windows
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
221 (where command-line length limits are more problematic) */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
222 FILE *argfile = fopen (argv[i] + 1, READ_TEXT);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2286
diff changeset
223 char arg[QXE_PATH_MAX];
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
224
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
225 if (!argfile)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
226 fatal ("Unable to open argument file %s", argv[i] + 1);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2286
diff changeset
227 while (fgets (arg, QXE_PATH_MAX, argfile))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
228 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
229 if (arg[strlen (arg) - 1] == '\n')
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
230 arg[strlen (arg) - 1] = '\0'; /* chop \n */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
231 err_count += scan_file (arg);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
232 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
233 }
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
234 else if (argc > i + 1 && !strcmp (argv[i], "-d"))
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
235 {
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
236 /* XEmacs change; allow more than one chdir.
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
237 The idea is that the second chdir is to source-lisp, and that
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
238 any Lisp files not under there have the full path specified. */
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
239 i += 1;
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
240 chdir (argv[i]);
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
241 continue;
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
242 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
243 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
244 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
245 int j;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
246 /* Don't process one file twice. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
247 for (j = first_infile; j < i; j++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
248 if (! strcmp (argv[i], argv[j]))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
249 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
250 if (j == i)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
251 err_count += scan_file (argv[i]);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
252 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
255 /* XEmacs addition */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
256 if (extra_elcs)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
257 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
258 char *p;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
260 while ((p = next_extra_elc (extra_elcs)) != NULL)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
261 err_count += scan_file (p);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 putc ('\n', outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 if (ellcc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 fprintf (outfile, "}\n\n");
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
267 /* End XEmacs addition */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
268
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 #ifndef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 exit (err_count > 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 #endif /* VMS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 return err_count > 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
275 /* Add a source file name boundary in the output file. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
276 static void
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
277 put_filename (const char *filename)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
278 {
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
279 /* XEmacs change; don't strip directory information. */
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
280 #if 0
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
281 const char *tmp;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
282
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
283 for (tmp = filename; *tmp; tmp++)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
284 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
285 if (IS_DIRECTORY_SEP(*tmp))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
286 filename = tmp + 1;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
287 }
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4456
diff changeset
288 #endif
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
289
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
290 /* <= because sizeof includes the nul byte at the end. Not quite right,
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
291 because it should include the length of the symbol + "\037[VF]" instead
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
292 of simply 10. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
293 assert(sizeof("\037S\n") + strlen(filename) + 10
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
294 <= DOC_MAX_FILENAME_LENGTH);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
295
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
296 putc (037, outfile);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
297 putc ('S', outfile);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
298 fprintf (outfile, "%s\n", filename);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
299 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
300
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 /* Read file FILENAME and output its doc strings to outfile. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 /* Return 1 if file is not found, 0 if it is found. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
305 scan_file (const char *filename)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 int len = strlen (filename);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
308
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
309 /* XEmacs change: test ellcc and set Current_file_type in each case */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 if (ellcc == 0 && len > 4 && !strcmp (filename + len - 4, ".elc"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 Current_file_type = elc_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 return scan_lisp_file (filename, READ_BINARY);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 else if (ellcc == 0 && len > 3 && !strcmp (filename + len - 3, ".el"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 Current_file_type = el_file;
4456
c785f98c6737 Pass READ_BINARY to scan_lisp_file, scan_c_file in make-docfile.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 3368
diff changeset
318 return scan_lisp_file (filename, READ_BINARY);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 Current_file_type = c_file;
4456
c785f98c6737 Pass READ_BINARY to scan_lisp_file, scan_c_file in make-docfile.c
Aidan Kehoe <kehoea@parhasard.net>
parents: 3368
diff changeset
323 return scan_c_file (filename, READ_BINARY);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
326
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
327 /* XEmacs addition: ISO 2022 handling */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
328 static int
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
329 getc_skipping_iso2022 (FILE *file)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
330 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
331 register int c;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
332 /* #### Kludge -- Ignore any ISO2022 sequences */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
333 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
334 while (c == 27)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
335 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
336 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
337 if (c == '$')
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
338 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
339 if (c >= '(' && c <= '/')
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
340 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
341 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
342 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
343 return c;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
344 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
345
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
346 enum iso2022_state
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
347 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
348 ISO_NOTHING,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
349 ISO_ESC,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
350 ISO_DOLLAR,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
351 ISO_FINAL_IS_NEXT,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
352 ISO_DOLLAR_AND_FINAL_IS_NEXT
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
353 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
354
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
355 static int non_ascii_p;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
356
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
357 static int
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
358 getc_iso2022 (FILE *file)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
359 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
360 /* #### Kludge -- Parse ISO2022 sequences (more or less) */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
361 static enum iso2022_state state;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
362 static int prevc;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
363 register int c;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
364 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
365 switch (state)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
366 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
367 case ISO_NOTHING:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
368 if (c == 27)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
369 state = ISO_ESC;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
370 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
371
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
372 case ISO_ESC:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
373 if (c == '$')
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
374 state = ISO_DOLLAR;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
375 else if (c >= '(' && c <= '/')
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
376 state = ISO_FINAL_IS_NEXT;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
377 else
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
378 state = ISO_NOTHING;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
379 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
380
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
381 case ISO_DOLLAR:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
382 if (c >= '(' && c <= '/')
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
383 state = ISO_DOLLAR_AND_FINAL_IS_NEXT;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
384 else if (c >= '@' && c <= 'B') /* ESC $ @ etc */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
385 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
386 non_ascii_p = 1;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
387 state = ISO_NOTHING;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
388 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
389 else
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
390 state = ISO_NOTHING;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
391 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
392
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
393 case ISO_FINAL_IS_NEXT:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
394 if (prevc == '(' && c == 'B') /* ESC ( B, invoke ASCII */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
395 non_ascii_p = 0;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
396 else if (prevc == '(' || prevc == ',') /* ESC ( x or ESC , x */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
397 non_ascii_p = 1;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
398 state = ISO_NOTHING;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
399 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
400
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
401 case ISO_DOLLAR_AND_FINAL_IS_NEXT:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
402 if (prevc == '(' || prevc == ',') /* ESC $ ( x or ESC $ , x */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
403 non_ascii_p = 1;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
404 state = ISO_NOTHING;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
405 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
406 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
407
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
408 prevc = c;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
409 return c;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
410 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
411
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
413 char globalbuf[128];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 /* Skip a C string from INFILE,
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
416 and return the character that follows the closing ".
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 If printflag is positive, output string contents to outfile.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 If it is negative, store contents in buf.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 Convert escape sequences \n and \t to newline and tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 discard \ followed by newline. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
422 #define MDGET do { prevc = c; c = getc_iso2022 (infile); } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 read_c_string (FILE *infile, int printflag, int c_docstring)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
426 register int prevc = 0, c = 0;
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
427 char *p = globalbuf;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
428 int start = -1; /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
430 MDGET;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 while (c != EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
433 while ((c_docstring || c != '"' || non_ascii_p) && c != EOF)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 {
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
435 /* XEmacs addition: the first two "if" clauses are new */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
436 if (c == '*' && !non_ascii_p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
438 int cc = getc (infile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
439 if (cc == '/')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
441 if (prevc != '\n')
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
442 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
443 if (printflag > 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
444 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
445 if (ellcc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
446 fprintf (outfile, "\\n\\");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
447 putc ('\n', outfile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
448 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 else if (printflag < 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
450 *p++ = '\n';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
451 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
452 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
454 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
455 ungetc (cc, infile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
456 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
458 if (start == 1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
459 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
460 if (printflag > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
462 if (ellcc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
463 fprintf (outfile, "\\n\\");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
464 putc ('\n', outfile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
466 else if (printflag < 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
467 *p++ = '\n';
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
469 /* End XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
471 if (c == '\\' && !non_ascii_p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 MDGET;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 MDGET;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 start = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 if (!c_docstring && c == 'n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 c = '\n';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 if (c == 't')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 c = '\t';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
485
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
486 /* XEmacs change: the "if" clause is new; the "else" clause is
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
487 mostly the original FSF Emacs code */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 start = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 start = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
493 if (printflag > 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
494 {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
495 if (ellcc && c == '"' && !non_ascii_p)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
496 putc ('\\', outfile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
497 putc (c, outfile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
498 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 else if (printflag < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 *p++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
502 MDGET;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
504 /* XEmacs change: look for continuation of string */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 if (Current_file_type == c_file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
507 do
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
508 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
509 MDGET;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
510 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
511 while (isspace (c));
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
512 if (c != '"' || non_ascii_p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
517 MDGET;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
518 if (c != '"' || non_ascii_p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 /* If we had a "", concatenate the two strings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
522 MDGET;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
524
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 if (printflag < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 *p = 0;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
527
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 return c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 /* Write to file OUT the argument names of function FUNC, whose text is in BUF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 MINARGS and MAXARGS are the minimum and maximum number of arguments. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
534 #define SKIPWHITE do { while (isspace ((unsigned char) (*p))) p++; } while (0)
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
535
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1618
diff changeset
537 write_c_args (FILE *out, const char *UNUSED (func), char *buf,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1618
diff changeset
538 int minargs, int maxargs)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 register char *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 int in_ident = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 int just_spaced = 0;
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
543 int need_paren = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 int need_space = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 fprintf (out, "(%s", func);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 /* XEmacs - "arguments:" is for parsing the docstring. FSF's help system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 doesn't parse the docstring for arguments like we do, so we're also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 going to omit the function name to preserve compatibility with elisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 that parses the docstring. Finally, not prefixing the arglist with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 anything is asking for trouble because it's not uncommon to have an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 unescaped parenthesis at the beginning of a line. --Stig */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 fprintf (out, "arguments: (");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
558 if (*buf == '(')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
559 ++buf;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
561 for (p = buf; *p; p++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 char c = *p;
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
564 #if 0
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 int ident_start = 0;
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
566 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
568 /* XEmacs addition: used for ANSI prototypes and UNUSED macros. */
2603
43ba9e13ee82 [xemacs-hg @ 2005-02-22 08:05:58 by stephent]
stephent
parents: 2421
diff changeset
569 static char uu [] = "UNUSED";
43ba9e13ee82 [xemacs-hg @ 2005-02-22 08:05:58 by stephent]
stephent
parents: 2421
diff changeset
570 static char ui [] = "USED_IF_";
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
571 static char lo [] = "Lisp_Object";
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
573 /* Notice when we enter or leave an identifier. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 if (C_IDENTIFIER_CHAR_P (c) != in_ident)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 if (!in_ident)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 {
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
578 /* Entering identifier. Print as we parse. */
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
579 char *here; /* Target for backtracking. */
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
580
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
581 /* XEmacs addition: add support for ANSI prototypes and the
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
582 UNUSED macros. Hop over them. "Lisp_Object" is the only
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
583 C type allowed in DEFUNs. For the UNUSED macros we need
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
584 to eat parens, too. */
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
585 /* Aren't these all vulnerable to buffer overrun? I guess that
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
586 means that the .c is busted, so we may as well just die ... */
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
587
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
588 /* Skip over "Lisp_Object". */
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
589 if ((strncmp (p, lo, sizeof (lo) - 1) == 0) &&
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
590 isspace ((unsigned char) p[sizeof (lo) - 1]))
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
591 {
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
592 p += (sizeof (lo) - 1);
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
593 SKIPWHITE;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
594 }
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
595 /* Skip over "UNUSED" or "USED_IF_*" invocation. */
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
596 need_paren = 1;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
597 here = p;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
598 if (strncmp (p, uu, sizeof (uu) - 1) == 0)
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
599 p += (sizeof (uu) - 1);
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
600 else if (strncmp (p, ui, sizeof (ui) - 1) == 0)
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
601 p += (sizeof (ui) - 1);
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
602 else
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
603 need_paren = 0;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
604
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
605 if (need_paren)
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
606 {
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
607 /* Skip rest of macro name, open paren, whitespace. */
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
608 while (*p && C_IDENTIFIER_CHAR_P (*p))
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
609 p++;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
610 SKIPWHITE;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
611 if (*p++ == '(')
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
612 SKIPWHITE;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
613 else
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
614 {
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
615 need_paren = 0;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
616 p = here;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
617 }
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
618 }
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
619 c = *p;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
620
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
621 /* Do bookkeeping. Maybe output lambda keywords. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 in_ident = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 /* XEmacs - This goes along with the change above. */
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
625 ident_start = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 if (need_space)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 putc (' ', out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 if (minargs == 0 && maxargs > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 fprintf (out, "&optional ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 just_spaced = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 minargs--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 maxargs--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 else
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
637 {
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
638 /* Leaving identifier. */
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
639 in_ident = 0;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
640 if (need_paren)
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
641 {
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
642 SKIPWHITE;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
643 if (*p == ')')
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
644 p++;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
645 c = *p;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
646 need_paren = 0;
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
647 }
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
648 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 /* Print the C argument list as it would appear in lisp:
5076
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
652 print underscores as hyphens, and print commas, tabs and newlines
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
653 as spaces. Collapse adjacent spaces into one. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
654 if (c == '_')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
655 c = '-';
5076
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
656 else if (c == ',' || c == '\n' || c == '\t')
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
657 c = ' ';
1618
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
658 /* XEmacs change: handle \n below for readability */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
660 #if 0
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
661 /* In C code, `default' is a reserved word, so we spell it
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
662 `defalt'; unmangle that here. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
663 if (ident_start
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
664 && strncmp (p, "defalt", 6) == 0
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
665 && ! (('A' <= p[6] && p[6] <= 'Z')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
666 || ('a' <= p[6] && p[6] <= 'z')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
667 || ('0' <= p[6] && p[6] <= '9')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
668 || p[6] == '_'))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
669 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
670 fprintf (out, "DEFAULT");
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
671 p += 5;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
672 in_ident = 0;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
673 just_spaced = 0;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
674 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
675 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 /* If the C argument name ends with `_', change it to ' ',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 to allow use of C reserved words or global symbols as Lisp args. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 if (c == '-' && ! C_IDENTIFIER_CHAR_P (p[1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 in_ident = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 just_spaced = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 }
5076
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
683 #if 0
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
684 /* [[ XEmacs change: if the character is carriage return or linefeed,
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
685 escape it for the compiler ]] I doubt the clause with '\r' ever
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
686 worked right, and outputting newlines now screws up the regexp
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
687 in function-documentation-1, so don't do this; instead, we treat
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
688 newlines like spaces. --ben */
1618
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
689 else if (c == '\n')
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
690 {
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
691 putc('\\', out);
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
692 putc('\n', out);
5076
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
693 c = ' ';
1618
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
694 }
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
695 else if (c == '\r')
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
696 {
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
697 putc('\\', out);
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
698 putc('\r', out);
1038bc1b8cb9 [xemacs-hg @ 2003-08-12 14:47:07 by james]
james
parents: 1111
diff changeset
699 }
5076
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
700 #else
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
701 else if (c == '\r') /* Just eat it, since we expect a newline to
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
702 follow */
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
703 ;
d555581e3cba fix issues with display of argument docstrings
Ben Wing <ben@xemacs.org>
parents: 4665
diff changeset
704 #endif /* (not) 0 */
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
705 else if (c != ' ' || !just_spaced)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 if (c >= 'a' && c <= 'z')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 /* Upcase the letter. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 c += 'A' - 'a';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 putc (c, out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 just_spaced = (c == ' ');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 need_space = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
718 /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 if (!ellcc)
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
720 putc ('\n', out);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 }
4665
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
722 #undef SKIPWHITE
f3a65dff1912 Fix UNUSED and USED_IF parsing in make-docfile.c.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4539
diff changeset
723
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
725 /* Read through a c file. If a .o or .obj file is named,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 the corresponding .c file is read instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 Looks for DEFUN constructs such as are defined in ../src/lisp.h.
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
728 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED ...
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
729 which don't exist anymore! */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
732 scan_c_file (const char *filename, const char *mode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 FILE *infile;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 register int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 register int commas;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 register int defunflag;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 register int defvarperbufferflag = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 register int defvarflag;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 int minargs, maxargs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 int l = strlen (filename);
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2286
diff changeset
742 char f[QXE_PATH_MAX];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
744 /* XEmacs change: different method for checking filename extension */
2421
ab71ad6ff3dd [xemacs-hg @ 2004-12-06 03:50:53 by ben]
ben
parents: 2286
diff changeset
745 if (l > QXE_PATH_MAX - 1)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
746 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 #ifdef ENAMETOOLONG
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
748 errno = ENAMETOOLONG;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 #else
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
750 errno = EINVAL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 #endif
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
752 return 0;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
753 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 strcpy (f, filename);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
756 if (l > 4 && !strcmp (f + l - 4, ".obj")) /* MS Windows */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
757 strcpy (f + l - 4, ".c");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 if (f[l - 1] == 'o')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 f[l - 1] = 'c';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 infile = fopen (f, mode);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 /* No error if non-ex input file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 if (infile == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 perror (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
769 #if 0
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
770 /* Reset extension to be able to detect duplicate files. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
771 filename[strlen (filename) - 1] = extension;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
772 #endif
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
773
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 c = '\n';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 while (!feof (infile))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 if (c != '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 if (c == ' ')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 while (c == ' ')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 if (c != 'D')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 if (c != 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 if (c != 'F')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 if (c != 'V')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 if (c != 'A')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 if (c != 'R')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 if (c != '_')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 defvarflag = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 defunflag = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 /* Note that this business doesn't apply under XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 DEFVAR_BUFFER_LOCAL in XEmacs behaves normally. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 defvarperbufferflag = (c == 'P');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 else if (c == 'D')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 if (c != 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 if (c != 'F')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 defunflag = (c == 'U');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 defvarflag = 0;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
829 c = getc (infile); /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 else continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 while (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 if (c < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 goto eof;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 if (c != '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 c = read_c_string (infile, -1, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 if (defunflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 commas = 4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 else if (defvarperbufferflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 commas = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 else if (defvarflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 commas = 1;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
851 else /* For DEFSIMPLE and DEFPRED ... which now don't exist! */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 commas = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 while (commas)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 if (c == ',')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 commas--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 if (defunflag && (commas == 1 || commas == 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 c = getc (infile);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
863 while (c == ' ' || c == '\n' || c == '\t');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 if (c < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 goto eof;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 ungetc (c, infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 if (commas == 2) /* pick up minargs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 fscanf (infile, "%d", &minargs);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
869 else /* pick up maxargs */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 maxargs = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 fscanf (infile, "%d", &maxargs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 if (c < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 goto eof;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 while (c == ' ' || c == '\n' || c == '\t')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 if (c == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 c = read_c_string (infile, 0, 0);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
884 /* XEmacs change */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 if (defunflag | defvarflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 while (c != '/')
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
888 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
889 if (c < 0)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
890 goto eof;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
891 if (defunflag && c == '(')
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
892 fatal ("Missing doc string for DEFUN %s\n", globalbuf);
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
893 c = getc (infile);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
894 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 while (c == '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 while (c != ',')
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
902 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
903 if (c < 0)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
904 goto eof;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
905 c = getc (infile);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
906 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
909 /* End XEmacs change */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 while (c == ' ' || c == '\n' || c == '\t')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 c = getc (infile);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
912 /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 if (defunflag | defvarflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 ungetc (c, infile);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
915 /* End XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 if (defunflag || defvarflag || c == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 {
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
919 /* XEmacs change: the original code is in the "else" clause */
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
920 /* XXX Must modify the documentation file name code to handle
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
921 ELLCCs */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
922 if (ellcc)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
923 fprintf (outfile, " CDOC%s(\"%s\", \"\\\n",
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
924 defvarflag ? "SYM" : "SUBR", globalbuf);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
925 else
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
926 {
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
927 put_filename (filename); /* XEmacs addition */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
928 putc (037, outfile);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
929 putc (defvarflag ? 'V' : 'F', outfile);
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
930 fprintf (outfile, "%s\n", globalbuf);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
931 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
932 c = read_c_string (infile, 1, defunflag || defvarflag);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 /* If this is a defun, find the arguments and print them. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 this function takes MANY or UNEVALLED args, then the C source
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 won't give the names of the arguments, so we shouldn't bother
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 trying to find them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 if (defunflag && maxargs != -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 char argbuf[1024], *p = argbuf;
2603
43ba9e13ee82 [xemacs-hg @ 2005-02-22 08:05:58 by stephent]
stephent
parents: 2421
diff changeset
941 int paren_level = 1;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
942 #if 0 /* For old DEFUN's only */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 while (c != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 if (c < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 goto eof;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 /* Skip into arguments. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 while (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 if (c < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 goto eof;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 /* Copy arguments into ARGBUF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 *p++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 do
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
960 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
961 *p++ = c = getc (infile);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
962 if (c < 0)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
963 goto eof;
2603
43ba9e13ee82 [xemacs-hg @ 2005-02-22 08:05:58 by stephent]
stephent
parents: 2421
diff changeset
964 /* XEmacs change: handle macros with args (eg, UNUSED) */
43ba9e13ee82 [xemacs-hg @ 2005-02-22 08:05:58 by stephent]
stephent
parents: 2421
diff changeset
965 if (c == ')')
43ba9e13ee82 [xemacs-hg @ 2005-02-22 08:05:58 by stephent]
stephent
parents: 2421
diff changeset
966 paren_level--;
43ba9e13ee82 [xemacs-hg @ 2005-02-22 08:05:58 by stephent]
stephent
parents: 2421
diff changeset
967 if (c == '(')
43ba9e13ee82 [xemacs-hg @ 2005-02-22 08:05:58 by stephent]
stephent
parents: 2421
diff changeset
968 paren_level++;
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
969 }
2603
43ba9e13ee82 [xemacs-hg @ 2005-02-22 08:05:58 by stephent]
stephent
parents: 2421
diff changeset
970 while (paren_level > 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 /* Output them. */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
973 if (ellcc)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
974 fprintf (outfile, "\\n\\\n\\n\\\n");
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
975 else
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
976 fprintf (outfile, "\n\n");
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
977 write_c_args (outfile, globalbuf, argbuf, minargs, maxargs);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 }
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
979 if (ellcc)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
980 fprintf (outfile, "\\n\");\n\n");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 eof:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 fclose (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 /* Read a file of Lisp code, compiled or interpreted.
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
989 Looks for
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
990 (defun NAME ARGS DOCSTRING ...)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
991 (defmacro NAME ARGS DOCSTRING ...)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
992 (defsubst NAME ARGS DOCSTRING ...)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
993 (autoload (quote NAME) FILE DOCSTRING ...)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
994 (defvar NAME VALUE DOCSTRING)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
995 (defconst NAME VALUE DOCSTRING)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
996 (fset (quote NAME) (make-byte-code ... DOCSTRING ...))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
997 (fset (quote NAME) #[... DOCSTRING ...])
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
998 (defalias (quote NAME) #[... DOCSTRING ...])
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
999 (custom-declare-variable (quote NAME) VALUE DOCSTRING ...)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1000 starting in column zero.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1001 (quote NAME) may appear as 'NAME as well.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 We also look for #@LENGTH CONTENTS^_ at the beginning of the line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 When we find that, we save it for the following defining-form,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 and we use that instead of reading a doc string within that defining-form.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1007 For defvar, defconst, and fset we skip to the docstring with a kludgy
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 formatting convention: all docstrings must appear on the same line as the
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1009 initial open-paren (the one in column zero) and must contain a backslash
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1010 and a newline immediately after the initial double-quote. No newlines
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 must appear between the beginning of the form and the first double-quote.
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1012 For defun, defmacro, and autoload, we know how to skip over the
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1013 arglist, but the doc string must still have a backslash and newline
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1014 immediately after the double quote.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1015 The only source files that must follow this convention are preloaded
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1016 uncompiled ones like loaddefs.el and bindings.el; aside
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 from that, it is always the .elc file that we look at, and they are no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 problem because byte-compiler output follows this convention.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 The NAME and DOCSTRING are output.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 NAME is preceded by `F' for a function or `V' for a variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 An entry is output only if DOCSTRING has \ newline just after the opening "
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
1022
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
1023 Adds the filename a symbol or function was found in before its docstring;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
1024 there's no need for this with the load-history available, but we do it for
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
1025 consistency with the C parsing code.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 skip_white (FILE *infile)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 char c = ' ';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 while (c == ' ' || c == '\t' || c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 ungetc (c, infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 read_lisp_symbol (FILE *infile, char *buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 char c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 char *fillp = buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 skip_white (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 if (c == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 /* FSF has *(++fillp), which is wrong. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 *fillp++ = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 else if (c == ' ' || c == '\t' || c == '\n' || c == '(' || c == ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 ungetc (c, infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 *fillp = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 *fillp++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 if (! buffer[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 fprintf (stderr, "## expected a symbol, got '%c'\n", c);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1062
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 skip_white (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1067 scan_lisp_file (const char *filename, const char *mode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 FILE *infile;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 register int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 char *saved_string = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 infile = fopen (filename, mode);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 if (infile == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 perror (filename);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1077 return 0; /* No error */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 c = '\n';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 while (!feof (infile))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 char buffer[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 char type;
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1085 int no_docstring = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1087 /* If not at end of line, skip till we get to one. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 if (c != '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1090 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1093 /* Skip the line break. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1094 while (c == '\n')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1095 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 /* Detect a dynamic doc string and save it for the next expression. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 if (c == '#')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1099 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 if (c == '@')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 int length = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 /* Read the length. */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1106 while ((c = getc_skipping_iso2022 (infile),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 c >= '0' && c <= '9'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 length *= 10;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 length += c - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 /* The next character is a space that is counted in the length
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 but not part of the doc string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 We already read it, so just ignore it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 length--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 /* Read in the contents. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 if (saved_string != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 free (saved_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 saved_string = (char *) xmalloc (length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 for (i = 0; i < length; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 saved_string[i] = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 /* The last character is a ^_.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 That is needed in the .elc file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 but it is redundant in DOC. So get rid of it here. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 saved_string[length - 1] = 0;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1128 /* Skip the line break. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1129 while (c == '\n')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1130 c = getc_skipping_iso2022 (infile);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1131 /* Skip the following line. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 while (c != '\n')
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1133 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 if (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1143 if (! strcmp (buffer, "defun")
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1144 || ! strcmp (buffer, "defmacro")
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1145 || ! strcmp (buffer, "defsubst"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 type = 'F';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 /* Skip the arguments: either "nil" or a list in parens */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1152 c = getc_skipping_iso2022 (infile);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1153 if (c == 'n') /* nil */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1155 if ((c = getc_skipping_iso2022 (infile)) != 'i' ||
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1156 (c = getc_skipping_iso2022 (infile)) != 'l')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 fprintf (stderr, "## unparsable arglist in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 else if (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 fprintf (stderr, "## unparsable arglist in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 while (c != ')')
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
1171 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
1172 c = getc_skipping_iso2022 (infile);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
1173 if (c < 0)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
1174 continue;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
1175 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 skip_white (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 /* If the next three characters aren't `dquote bslash newline'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 then we're not reading a docstring.
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1180 */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1181 if ((c = getc_skipping_iso2022 (infile)) != '"' ||
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1182 (c = getc_skipping_iso2022 (infile)) != '\\' ||
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1183 (c = getc_skipping_iso2022 (infile)) != '\n')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 fprintf (stderr, "## non-docstring in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 #endif
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1189 no_docstring = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1193 else if (! strcmp (buffer, "defvar")
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1194 || ! strcmp (buffer, "defconst"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 char c1 = 0, c2 = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 type = 'V';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 if (saved_string == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1203 /* Skip until the end of line; remember two previous chars. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 while (c != '\n' && c >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 c2 = c1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 c1 = c;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1208 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1210
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1211 /* If two previous characters were " and \,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1212 this is a doc string. Otherwise, there is none. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1213 if (c2 != '"' || c1 != '\\')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1214 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1215 #ifdef DEBUG
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1216 fprintf (stderr, "## non-docstring in %s (%s)\n",
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1217 buffer, filename);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1218 #endif
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1219 no_docstring = 1;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1220 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1221 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1222 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1224 else if (! strcmp (buffer, "custom-declare-variable"))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1225 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1226 char c1 = 0, c2 = 0;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1227 type = 'V';
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1228
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1229 c = getc (infile);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1230 if (c == '\'')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1231 read_lisp_symbol (infile, buffer);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1232 else
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1233 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1234 if (c != '(')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1235 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1236 fprintf (stderr,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1237 "## unparsable name in custom-declare-variable in %s\n",
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1238 filename);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1239 continue;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1240 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1241 read_lisp_symbol (infile, buffer);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1242 if (strcmp (buffer, "quote"))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1243 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1244 fprintf (stderr,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1245 "## unparsable name in custom-declare-variable in %s\n",
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1246 filename);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1247 continue;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1248 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1249 read_lisp_symbol (infile, buffer);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1250 c = getc (infile);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1251 if (c != ')')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1252 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1253 fprintf (stderr,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1254 "## unparsable quoted name in custom-declare-variable in %s\n",
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1255 filename);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1256 continue;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1257 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1258 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1259
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1260 if (saved_string == 0)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1261 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1262 /* Skip to end of line; remember the two previous chars. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1263 while (c != '\n' && c >= 0)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1264 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1265 c2 = c1;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1266 c1 = c;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1267 c = getc_skipping_iso2022 (infile);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1268 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1269
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 /* If two previous characters were " and \,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 this is a doc string. Otherwise, there is none. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 if (c2 != '"' || c1 != '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 fprintf (stderr, "## non-docstring in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 #endif
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1278 no_docstring = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 else if (! strcmp (buffer, "fset") || ! strcmp (buffer, "defalias"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 char c1 = 0, c2 = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 type = 'F';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1288 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 if (c == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 if (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 fprintf (stderr, "## unparsable name in fset in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 if (strcmp (buffer, "quote"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 fprintf (stderr, "## unparsable name in fset in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 read_lisp_symbol (infile, buffer);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1307 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 if (c != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 fprintf (stderr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 "## unparsable quoted name in fset in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 if (saved_string == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 {
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1319 /* Skip to end of line; remember the two previous chars. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 while (c != '\n' && c >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 c2 = c1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 c1 = c;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1324 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1326
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 /* If two previous characters were " and \,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 this is a doc string. Otherwise, there is none. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 if (c2 != '"' || c1 != '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 fprintf (stderr, "## non-docstring in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 #endif
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1335 no_docstring = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 else if (! strcmp (buffer, "autoload"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 type = 'F';
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1343 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 if (c == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 if (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 fprintf (stderr, "## unparsable name in autoload in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 if (strcmp (buffer, "quote"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 fprintf (stderr, "## unparsable name in autoload in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 read_lisp_symbol (infile, buffer);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1362 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 if (c != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 fprintf (stderr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 "## unparsable quoted name in autoload in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 skip_white (infile);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1372 if ((c = getc_skipping_iso2022 (infile)) != '\"')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 fprintf (stderr, "## autoload of %s unparsable (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 read_c_string (infile, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 skip_white (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 if (saved_string == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 /* If the next three characters aren't `dquote bslash newline'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 then we're not reading a docstring. */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1385 if ((c = getc_skipping_iso2022 (infile)) != '"' ||
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1386 (c = getc_skipping_iso2022 (infile)) != '\\' ||
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1387 (c = getc_skipping_iso2022 (infile)) != '\n')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 fprintf (stderr, "## non-docstring in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 #endif
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1393 no_docstring = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1398 #if 0 /* causes crash */
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1399 else if (! strcmp (buffer, "if")
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1400 || ! strcmp (buffer, "byte-code"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 fprintf (stderr, "## unrecognized top-level form, %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 /* At this point, we should either use the previous
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 dynamic doc string in saved_string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 or gobble a doc string from the input file.
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1416
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 In the latter case, the opening quote (and leading
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 backslash-newline) have already been read. */
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1419
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 2603
diff changeset
1420 put_filename (filename); /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 putc (037, outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 putc (type, outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 fprintf (outfile, "%s\n", buffer);
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1424 if (!no_docstring)
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1425 {
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1426 if (saved_string)
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1427 {
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1428 fputs (saved_string, outfile);
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1429 /* Don't use one dynamic doc string twice. */
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1430 free (saved_string);
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1431 saved_string = 0;
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1432 }
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1433 else
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1434 read_c_string (infile, 1, 0);
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5076
diff changeset
1435 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 fclose (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 }