annotate lib-src/make-docfile.c @ 1111:184461bc8de4

[xemacs-hg @ 2002-11-18 06:52:23 by ben] warning fixes, etc. * s/cygwin32.h: -fvtable-thunks is obsolete in GCC 3 and generates warnings. * s/mingw32.h: * s/windowsnt.h: Comment fixes. * emodules.h: Fix warnings from redefining symbols. * eval.c: Fix C++ errors -- no automatic casting between function pointers and void *, function declarations inside of functions not allowed. * event-Xt.c (emacs_Xt_enqueue_focus_event): Warning fixes. * fileio.c (Ffile_truename): Warning fixes. Use LOCAL_TO_WIN32_FILE_FORMAT rather than duplicating it. * glyphs-x.c: Fix style. * intl-auto-encap-win32.c: * intl-auto-encap-win32.h: * intl-encap-win32.c: * intl-encap-win32.c (qxeRegConnectRegistry): * syswindows.h (RegConnectRegistry): DdeCreateStringHandle needs to be manual due to new Cygwin bug. * intl-win32.c: wcslen/wcscmp don't seem to exist under G++ 3, Cygwin. * lisp.h: * lisp-union.h: * lisp-disunion.h: * process-unix.c (unix_send_process): Ugh, C needs volatile and C++ must not have volatile. Remove previous volatile hacks, which don't seem to be working any more. * sheap.c (STATIC_HEAP_SLOP): Try to get a working Cygwin build with old unexec. * sheap.c (more_static_core): No NL's in literals allowed. * symbols.c (Fset): Fix C++ errors. * syswindows.h: Fix Cygwin complaints now that some missing structs have been added. aclocal.m4: Disable shared library modules under Cygwin for the moment, since we need some more tricky coding done and I don't have the time right now. configure.in, configure.usage: code-files.el, loadhist.el: Fix warnings. package-get.el: Fix warnings. NOTE: This was already fixed awhile ago, but reverted by Steve Y. Please be careful. postgresql/Makefile.in.in: Removed. Move common stuff into modues/common/Makefile.common. (Also add extraclean target and a couple of other fixes in that file.) postgresql/configure.ac: Extract out common configure stuff into modules/common/configure-{pre,post}.ac. postgresql/postgresql.c: Fix warning. ldap/Makefile.in.in: Removed. Move common stuff into modues/common/Makefile.common. (Also add extraclean target and a couple of other fixes in that file.) ldap/configure.ac: Extract out common configure stuff into modules/common/configure-{pre,post}.ac. common/Makefile.common: Common stuff is here.
author ben
date Mon, 18 Nov 2002 06:53:08 +0000
parents eaedf30d9d76
children 1038bc1b8cb9
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.
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
6 Copyright (C) 2001, 2002 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
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
10 XEmacs is free software; you can redistribute it and/or modify
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
11 it under the terms of the GNU General Public License as published by
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
12 the Free Software Foundation; either version 2, or (at your option)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
13 any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
15 XEmacs is distributed in the hope that it will be useful,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
18 GNU General Public License for more details.
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
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
21 along with XEmacs; see the file COPYING. If not, write to
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
23 Boston, MA 02111-1307, USA. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
24
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
25 /* Synched up with: FSF 21.2. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 /* 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
28 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
29 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
30 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
31
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
32 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
33 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
34 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
35 Each entry starts with a ^_ character.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
36 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
37 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
38 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
39
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
40 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
41 without modifying Makefiles, etc.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
44 #include <config.h>
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
45 #include <sysfile.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 #include <ctype.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
52 /* XEmacs addition */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
53 #define C_IDENTIFIER_CHAR_P(c) \
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
54 (('A' <= c && c <= 'Z') || \
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 ('0' <= c && c <= '9') || \
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
57 (c == '_'))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
59 static int scan_file (const char *filename);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 static int read_c_string (FILE *, int, int);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
61 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
62 int maxargs);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
63 static int scan_c_file (const char *filename, const char *mode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 static void skip_white (FILE *);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 static void read_lisp_symbol (FILE *, char *);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
66 static int scan_lisp_file (const char *filename, const char *mode);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
68 /* Stdio stream for output to the DOC file. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
69 static FILE *outfile;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
70
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
71 /* XEmacs addition */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
72 enum
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
73 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
74 el_file,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
75 elc_file,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
76 c_file
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
77 } Current_file_type;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 /* Name this program was invoked with. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 char *progname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
82 /* XEmacs addition: set to 1 if this was invoked by ellcc */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 int ellcc = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 /* 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
86
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
88 error (const char *s1, const char *s2)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 fprintf (stderr, "%s: ", progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 fprintf (stderr, s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 fprintf (stderr, "\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 /* Print error message and exit. */
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 static void
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
98 fatal (const char *s1, const char *s2)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 error (s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 exit (1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 /* Like malloc but get fatal error if memory is exhausted. */
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 static long *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 xmalloc (unsigned int size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 long *result = (long *) malloc (size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 fatal ("virtual memory exhausted", 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
115 /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 static char *
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
117 next_extra_elc (char *extra_elcs)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 static FILE *fp = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 static char line_buf[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 char *p = line_buf+1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
123 if (!fp)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
124 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
125 if (!extra_elcs)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
126 return NULL;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
127 else if (!(fp = fopen (extra_elcs, READ_BINARY)))
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
128 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
129 /* 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
130 /*fatal ("error opening site package file list", 0);*/
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
131 return NULL;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
132 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
133 fgets (line_buf, BUFSIZ, fp);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
134 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
135
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
136 do
814
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 if (!fgets (line_buf, BUFSIZ, fp))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
139 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
140 fclose (fp);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
141 fp = NULL;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
142 return NULL;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
143 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
144 line_buf[0] = '\0';
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
145 /* reject too short or too long lines */
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
146 } while (strlen (p) <= 2 || strlen (p) >= (BUFSIZ - 5));
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
147
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
148 p[strlen (p) - 2] = '\0';
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
149 strcat (p, ".elc");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 return p;
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
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 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 main (int argc, char **argv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 int err_count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 int first_infile;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
161 char *extra_elcs = NULL; /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 progname = argv[0];
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 outfile = stdout;
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 /* Don't put CRs in the DOC file. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
168 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 _fmode = O_BINARY;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 _setmode (fileno (stdout), O_BINARY);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
171 #endif /* WIN32_NATIVE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 /* If first two args are -o FILE, output to FILE. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 i = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 if (argc > i + 1 && !strcmp (argv[i], "-o"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 outfile = fopen (argv[i + 1], WRITE_BINARY);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 i += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 if (argc > i + 1 && !strcmp (argv[i], "-a"))
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 outfile = fopen (argv[i + 1], APPEND_BINARY);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 i += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
185 if (argc > i + 1 && !strcmp (argv[i], "-d"))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
186 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
187 chdir (argv[i + 1]);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
188 i += 2;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
189 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
190
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
191 /* Additional command line arguments for XEmacs */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 if (argc > i + 1 && !strcmp (argv[i], "-E"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 outfile = fopen (argv[i + 1], APPEND_BINARY);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 i += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 ellcc = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 }
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
198 if (argc > (i + 1) && !strcmp (argv[i], "-i"))
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
199 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
200 extra_elcs = argv[i + 1];
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
201 i += 2;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
202 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 if (outfile == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 fatal ("No output file specified", "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
207 /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 if (ellcc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 fprintf (outfile, "{\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 first_infile = i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 for (; i < argc; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 {
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
214 /* 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
215 original FSF Emacs code */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
216 if (argv[i][0] == '@')
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
217 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
218 /* 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
219 (where command-line length limits are more problematic) */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
220 FILE *argfile = fopen (argv[i] + 1, READ_TEXT);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
221 char arg[PATH_MAX];
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
222
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
223 if (!argfile)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
224 fatal ("Unable to open argument file %s", argv[i] + 1);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
225 while (fgets (arg, PATH_MAX, argfile))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
226 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
227 if (arg[strlen (arg) - 1] == '\n')
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
228 arg[strlen (arg) - 1] = '\0'; /* chop \n */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
229 err_count += scan_file (arg);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
230 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
231 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
232 else
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
233 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
234 int j;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
235 /* Don't process one file twice. */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
236 for (j = first_infile; j < i; j++)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
237 if (! strcmp (argv[i], argv[j]))
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
238 break;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
239 if (j == i)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
240 err_count += scan_file (argv[i]);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
241 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
244 /* XEmacs addition */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
245 if (extra_elcs)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
246 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
247 char *p;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
249 while ((p = next_extra_elc (extra_elcs)) != NULL)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
250 err_count += scan_file (p);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 putc ('\n', outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 if (ellcc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 fprintf (outfile, "}\n\n");
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
256 /* End XEmacs addition */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
257
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 #ifndef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 exit (err_count > 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 #endif /* VMS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 return err_count > 0;
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 /* Read file FILENAME and output its doc strings to outfile. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 /* Return 1 if file is not found, 0 if it is found. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
268 scan_file (const char *filename)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 int len = strlen (filename);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
271
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
272 /* 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
273 if (ellcc == 0 && len > 4 && !strcmp (filename + len - 4, ".elc"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 Current_file_type = elc_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 return scan_lisp_file (filename, READ_BINARY);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 else if (ellcc == 0 && len > 3 && !strcmp (filename + len - 3, ".el"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 Current_file_type = el_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 return scan_lisp_file (filename, READ_TEXT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 Current_file_type = c_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 return scan_c_file (filename, READ_TEXT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
289
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
290 /* XEmacs addition: ISO 2022 handling */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
291 static int
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
292 getc_skipping_iso2022 (FILE *file)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
293 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
294 register int c;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
295 /* #### Kludge -- Ignore any ISO2022 sequences */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
296 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
297 while (c == 27)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
298 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
299 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
300 if (c == '$')
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
301 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
302 if (c >= '(' && c <= '/')
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
303 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
304 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
305 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
306 return c;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
307 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
308
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
309 enum iso2022_state
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
310 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
311 ISO_NOTHING,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
312 ISO_ESC,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
313 ISO_DOLLAR,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
314 ISO_FINAL_IS_NEXT,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
315 ISO_DOLLAR_AND_FINAL_IS_NEXT
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
316 };
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
317
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
318 static int non_ascii_p;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
319
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
320 static int
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
321 getc_iso2022 (FILE *file)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
322 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
323 /* #### Kludge -- Parse ISO2022 sequences (more or less) */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
324 static enum iso2022_state state;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
325 static int prevc;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
326 register int c;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
327 c = getc (file);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
328 switch (state)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
329 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
330 case ISO_NOTHING:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
331 if (c == 27)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
332 state = ISO_ESC;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
333 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
334
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
335 case ISO_ESC:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
336 if (c == '$')
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
337 state = ISO_DOLLAR;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
338 else if (c >= '(' && c <= '/')
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
339 state = ISO_FINAL_IS_NEXT;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
340 else
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
341 state = ISO_NOTHING;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
342 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
343
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
344 case ISO_DOLLAR:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
345 if (c >= '(' && c <= '/')
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
346 state = ISO_DOLLAR_AND_FINAL_IS_NEXT;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
347 else if (c >= '@' && c <= 'B') /* ESC $ @ etc */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
348 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
349 non_ascii_p = 1;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
350 state = ISO_NOTHING;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
351 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
352 else
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
353 state = ISO_NOTHING;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
354 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
355
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
356 case ISO_FINAL_IS_NEXT:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
357 if (prevc == '(' && c == 'B') /* ESC ( B, invoke ASCII */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
358 non_ascii_p = 0;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
359 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
360 non_ascii_p = 1;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
361 state = ISO_NOTHING;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
362 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
363
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
364 case ISO_DOLLAR_AND_FINAL_IS_NEXT:
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
365 if (prevc == '(' || prevc == ',') /* ESC $ ( x or ESC $ , x */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
366 non_ascii_p = 1;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
367 state = ISO_NOTHING;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
368 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
369 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
370
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
371 prevc = c;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
372 return c;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
373 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
374
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
376 char globalbuf[128];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 /* Skip a C string from INFILE,
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
379 and return the character that follows the closing ".
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 If printflag is positive, output string contents to outfile.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 If it is negative, store contents in buf.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 Convert escape sequences \n and \t to newline and tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 discard \ followed by newline. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
385 #define MDGET do { prevc = c; c = getc_iso2022 (infile); } while (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 read_c_string (FILE *infile, int printflag, int c_docstring)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
389 register int prevc = 0, c = 0;
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
390 char *p = globalbuf;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
391 int start = -1; /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
393 MDGET;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 while (c != EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
396 while ((c_docstring || c != '"' || non_ascii_p) && c != EOF)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 {
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
398 /* 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
399 if (c == '*' && !non_ascii_p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
401 int cc = getc (infile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
402 if (cc == '/')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
404 if (prevc != '\n')
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
405 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
406 if (printflag > 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
407 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
408 if (ellcc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
409 fprintf (outfile, "\\n\\");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
410 putc ('\n', outfile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
411 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
412 else if (printflag < 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
413 *p++ = '\n';
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
414 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
415 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
417 else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
418 ungetc (cc, infile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
419 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
421 if (start == 1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
422 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
423 if (printflag > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
425 if (ellcc)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
426 fprintf (outfile, "\\n\\");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
427 putc ('\n', outfile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
429 else if (printflag < 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
430 *p++ = '\n';
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
432 /* End XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
434 if (c == '\\' && !non_ascii_p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
436 MDGET;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
439 MDGET;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 start = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 if (!c_docstring && c == 'n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 c = '\n';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 if (c == 't')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 c = '\t';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
448
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
449 /* 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
450 mostly the original FSF Emacs code */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 start = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 start = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
456 if (printflag > 0)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
457 {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
458 if (ellcc && c == '"' && !non_ascii_p)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
459 putc ('\\', outfile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
460 putc (c, outfile);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
461 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 else if (printflag < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 *p++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
465 MDGET;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
467 /* XEmacs change: look for continuation of string */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 if (Current_file_type == c_file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
470 do
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
471 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
472 MDGET;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474 while (isspace (c));
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
475 if (c != '"' || non_ascii_p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 MDGET;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
481 if (c != '"' || non_ascii_p)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 /* If we had a "", concatenate the two strings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
485 MDGET;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
487
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 if (printflag < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 *p = 0;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
490
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 return c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 /* 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
495 MINARGS and MAXARGS are the minimum and maximum number of arguments. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 static void
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
498 write_c_args (FILE *out, const char *func, char *buf, int minargs, int maxargs)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 register char *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 int in_ident = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 int just_spaced = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 int need_space = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 fprintf (out, "(%s", func);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 /* XEmacs - "arguments:" is for parsing the docstring. FSF's help system
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 doesn't parse the docstring for arguments like we do, so we're also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 going to omit the function name to preserve compatibility with elisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 that parses the docstring. Finally, not prefixing the arglist with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 anything is asking for trouble because it's not uncommon to have an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 unescaped parenthesis at the beginning of a line. --Stig */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 fprintf (out, "arguments: (");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
517 if (*buf == '(')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
518 ++buf;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
520 for (p = buf; *p; p++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 char c = *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 int ident_start = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
525 /* XEmacs addition: add support for ANSI prototypes. Hop over
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 "Lisp_Object" string (the only C type allowed in DEFUNs) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 static char lo[] = "Lisp_Object";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 if ((C_IDENTIFIER_CHAR_P (c) != in_ident) && !in_ident &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 (strncmp (p, lo, sizeof (lo) - 1) == 0) &&
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
530 isspace ((unsigned char) p[sizeof (lo) - 1]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 p += (sizeof (lo) - 1);
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
533 while (isspace ((unsigned char) (*p)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 p++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 c = *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 /* Notice when we start printing a new identifier. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 if (C_IDENTIFIER_CHAR_P (c) != in_ident)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 if (!in_ident)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 in_ident = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 ident_start = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 /* XEmacs - This goes along with the change above. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 if (need_space)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 putc (' ', out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 if (minargs == 0 && maxargs > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 fprintf (out, "&optional ");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 just_spaced = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 minargs--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 maxargs--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 in_ident = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 /* Print the C argument list as it would appear in lisp:
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
562 print underscores as hyphens, and print commas and newlines
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
563 as spaces. Collapse adjacent spaces into one. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
564 if (c == '_')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
565 c = '-';
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
566 else if (c == ',' || c == '\n')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
567 c = ' ';
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
569 #if 0
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
570 /* 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
571 `defalt'; unmangle that here. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
572 if (ident_start
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
573 && strncmp (p, "defalt", 6) == 0
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
574 && ! (('A' <= p[6] && p[6] <= 'Z')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
575 || ('a' <= p[6] && p[6] <= 'z')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
576 || ('0' <= p[6] && p[6] <= '9')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
577 || p[6] == '_'))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
578 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
579 fprintf (out, "DEFAULT");
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
580 p += 5;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
581 in_ident = 0;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
582 just_spaced = 0;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
583 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
584 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 /* If the C argument name ends with `_', change it to ' ',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 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
587 if (c == '-' && ! C_IDENTIFIER_CHAR_P (p[1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 in_ident = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 just_spaced = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
592 else if (c != ' ' || !just_spaced)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 if (c >= 'a' && c <= 'z')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 /* Upcase the letter. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 c += 'A' - 'a';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 putc (c, out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 just_spaced = (c == ' ');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 need_space = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
605 /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 if (!ellcc)
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
607 putc ('\n', out);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
610 /* 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
611 the corresponding .c file is read instead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 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
613 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
614 which don't exist anymore! */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
617 scan_c_file (const char *filename, const char *mode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 FILE *infile;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 register int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 register int commas;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 register int defunflag;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 register int defvarperbufferflag = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 register int defvarflag;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 int minargs, maxargs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 int l = strlen (filename);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
627 char f[PATH_MAX];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
629 /* XEmacs change: different method for checking filename extension */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
630 if (l > PATH_MAX - 1)
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
631 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 #ifdef ENAMETOOLONG
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
633 errno = ENAMETOOLONG;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 #else
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
635 errno = EINVAL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 #endif
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
637 return 0;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
638 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 strcpy (f, filename);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 647
diff changeset
641 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
642 strcpy (f + l - 4, ".c");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 if (f[l - 1] == 'o')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 f[l - 1] = 'c';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 infile = fopen (f, mode);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 /* No error if non-ex input file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 if (infile == NULL)
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 perror (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
654 #if 0
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
655 /* 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
656 filename[strlen (filename) - 1] = extension;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
657 #endif
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
658
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 c = '\n';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 while (!feof (infile))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 if (c != '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 if (c == ' ')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 while (c == ' ')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 if (c != 'D')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 if (c != 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 if (c != 'F')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 if (c != 'V')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 if (c != 'A')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 if (c != 'R')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 if (c != '_')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 defvarflag = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 defunflag = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 /* Note that this business doesn't apply under XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 DEFVAR_BUFFER_LOCAL in XEmacs behaves normally. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 defvarperbufferflag = (c == 'P');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 else if (c == 'D')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 if (c != 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 if (c != 'F')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 defunflag = (c == 'U');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 defvarflag = 0;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
714 c = getc (infile); /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 else continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 while (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 if (c < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 goto eof;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 if (c != '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 c = read_c_string (infile, -1, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 if (defunflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 commas = 4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 else if (defvarperbufferflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 commas = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 else if (defvarflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 commas = 1;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
736 else /* For DEFSIMPLE and DEFPRED ... which now don't exist! */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 commas = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 while (commas)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 if (c == ',')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 commas--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 if (defunflag && (commas == 1 || commas == 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 c = getc (infile);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
748 while (c == ' ' || c == '\n' || c == '\t');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 if (c < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 goto eof;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 ungetc (c, infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 if (commas == 2) /* pick up minargs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 fscanf (infile, "%d", &minargs);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
754 else /* pick up maxargs */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 maxargs = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 fscanf (infile, "%d", &maxargs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 if (c < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 goto eof;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 c = getc (infile);
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 while (c == ' ' || c == '\n' || c == '\t')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 if (c == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 c = read_c_string (infile, 0, 0);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
769 /* XEmacs change */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 if (defunflag | defvarflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 while (c != '/')
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
773 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
774 if (c < 0)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
775 goto eof;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
776 if (defunflag && c == '(')
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
777 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
778 c = getc (infile);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
779 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 while (c == '*')
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 while (c != ',')
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
787 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
788 if (c < 0)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
789 goto eof;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
790 c = getc (infile);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
791 }
428
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 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
794 /* End XEmacs change */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 while (c == ' ' || c == '\n' || c == '\t')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 c = getc (infile);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
797 /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 if (defunflag | defvarflag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 ungetc (c, infile);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
800 /* End XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 if (defunflag || defvarflag || c == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 {
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
804 /* XEmacs change: the original code is in the "else" clause */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
805 if (ellcc)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
806 fprintf (outfile, " CDOC%s(\"%s\", \"\\\n",
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
807 defvarflag ? "SYM" : "SUBR", globalbuf);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
808 else
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
809 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
810 putc (037, outfile);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
811 putc (defvarflag ? 'V' : 'F', outfile);
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
812 fprintf (outfile, "%s\n", globalbuf);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
813 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
814 c = read_c_string (infile, 1, defunflag || defvarflag);
428
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 /* If this is a defun, find the arguments and print them. If
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 this function takes MANY or UNEVALLED args, then the C source
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 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
819 trying to find them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 if (defunflag && maxargs != -1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 char argbuf[1024], *p = argbuf;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
823 #if 0 /* For old DEFUN's only */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 while (c != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 if (c < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 goto eof;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 /* Skip into arguments. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 while (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 if (c < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 goto eof;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 /* Copy arguments into ARGBUF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 *p++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 do
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
841 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
842 *p++ = c = getc (infile);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
843 if (c < 0)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
844 goto eof;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
845 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 while (c != ')');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 /* Output them. */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
849 if (ellcc)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
850 fprintf (outfile, "\\n\\\n\\n\\\n");
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
851 else
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
852 fprintf (outfile, "\n\n");
1111
184461bc8de4 [xemacs-hg @ 2002-11-18 06:52:23 by ben]
ben
parents: 930
diff changeset
853 write_c_args (outfile, globalbuf, argbuf, minargs, maxargs);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 }
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
855 if (ellcc)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
856 fprintf (outfile, "\\n\");\n\n");
428
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 eof:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 fclose (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 /* 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
865 Looks for
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
866 (defun NAME ARGS DOCSTRING ...)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
867 (defmacro NAME ARGS DOCSTRING ...)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
868 (defsubst NAME ARGS DOCSTRING ...)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
869 (autoload (quote NAME) FILE DOCSTRING ...)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
870 (defvar NAME VALUE DOCSTRING)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
871 (defconst NAME VALUE DOCSTRING)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
872 (fset (quote NAME) (make-byte-code ... DOCSTRING ...))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
873 (fset (quote NAME) #[... DOCSTRING ...])
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
874 (defalias (quote NAME) #[... DOCSTRING ...])
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
875 (custom-declare-variable (quote NAME) VALUE DOCSTRING ...)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
876 starting in column zero.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
877 (quote NAME) may appear as 'NAME as well.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 We also look for #@LENGTH CONTENTS^_ at the beginning of the line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 When we find that, we save it for the following defining-form,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 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
882
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
883 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
884 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
885 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
886 and a newline immediately after the initial double-quote. No newlines
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 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
888 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
889 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
890 immediately after the double quote.
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
891 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
892 uncompiled ones like loaddefs.el and bindings.el; aside
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 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
894 problem because byte-compiler output follows this convention.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 The NAME and DOCSTRING are output.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 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
897 An entry is output only if DOCSTRING has \ newline just after the opening "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 skip_white (FILE *infile)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 char c = ' ';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 while (c == ' ' || c == '\t' || c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 ungetc (c, infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 read_lisp_symbol (FILE *infile, char *buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 char c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 char *fillp = buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 skip_white (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 c = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 if (c == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 /* FSF has *(++fillp), which is wrong. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 *fillp++ = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 else if (c == ' ' || c == '\t' || c == '\n' || c == '(' || c == ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 ungetc (c, infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 *fillp = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 *fillp++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 if (! buffer[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 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
934
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 skip_white (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
939 scan_lisp_file (const char *filename, const char *mode)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 FILE *infile;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 register int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 char *saved_string = 0;
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 infile = fopen (filename, mode);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 if (infile == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 perror (filename);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
949 return 0; /* No error */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 c = '\n';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 while (!feof (infile))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 char buffer[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 char type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
958 /* 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
959 if (c != '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
961 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
964 /* Skip the line break. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
965 while (c == '\n')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
966 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 /* Detect a dynamic doc string and save it for the next expression. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 if (c == '#')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
970 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 if (c == '@')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 int length = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 /* Read the length. */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
977 while ((c = getc_skipping_iso2022 (infile),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 c >= '0' && c <= '9'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 length *= 10;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 length += c - '0';
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 /* The next character is a space that is counted in the length
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 but not part of the doc string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 We already read it, so just ignore it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 length--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 /* Read in the contents. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 if (saved_string != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 free (saved_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 saved_string = (char *) xmalloc (length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 for (i = 0; i < length; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 saved_string[i] = getc (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 /* The last character is a ^_.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 That is needed in the .elc file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 but it is redundant in DOC. So get rid of it here. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 saved_string[length - 1] = 0;
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
999 /* Skip the line break. */
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1000 while (c == '\n')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1001 c = getc_skipping_iso2022 (infile);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1002 /* Skip the following line. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 while (c != '\n')
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1004 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 if (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1014 if (! strcmp (buffer, "defun")
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1015 || ! strcmp (buffer, "defmacro")
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1016 || ! strcmp (buffer, "defsubst"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 type = 'F';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 /* Skip the arguments: either "nil" or a list in parens */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1023 c = getc_skipping_iso2022 (infile);
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1024 if (c == 'n') /* nil */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 {
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1026 if ((c = getc_skipping_iso2022 (infile)) != 'i' ||
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1027 (c = getc_skipping_iso2022 (infile)) != 'l')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 fprintf (stderr, "## unparsable arglist in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 else if (c != '(')
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 fprintf (stderr, "## unparsable arglist in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 continue;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 while (c != ')')
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
1042 {
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
1043 c = getc_skipping_iso2022 (infile);
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
1044 if (c < 0)
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
1045 continue;
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 814
diff changeset
1046 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 skip_white (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 /* If the next three characters aren't `dquote bslash newline'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 then we're not reading a docstring.
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1051 */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1052 if ((c = getc_skipping_iso2022 (infile)) != '"' ||
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1053 (c = getc_skipping_iso2022 (infile)) != '\\' ||
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1054 (c = getc_skipping_iso2022 (infile)) != '\n')
428
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 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 fprintf (stderr, "## non-docstring in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1064 else if (! strcmp (buffer, "defvar")
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1065 || ! strcmp (buffer, "defconst"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 char c1 = 0, c2 = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 type = 'V';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 if (saved_string == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1074 /* Skip until the end of line; remember two previous chars. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 while (c != '\n' && c >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 c2 = c1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 c1 = c;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1079 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1081
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1082 /* If two previous characters were " and \,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1083 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
1084 if (c2 != '"' || c1 != '\\')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1085 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1086 #ifdef DEBUG
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1087 fprintf (stderr, "## non-docstring in %s (%s)\n",
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1088 buffer, filename);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1089 #endif
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1090 continue;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1091 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1092 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1093 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1095 else if (! strcmp (buffer, "custom-declare-variable"))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1096 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1097 char c1 = 0, c2 = 0;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1098 type = 'V';
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1099
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1100 c = getc (infile);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1101 if (c == '\'')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1102 read_lisp_symbol (infile, buffer);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1103 else
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1104 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1105 if (c != '(')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1106 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1107 fprintf (stderr,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1108 "## 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
1109 filename);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1110 continue;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1111 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1112 read_lisp_symbol (infile, buffer);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1113 if (strcmp (buffer, "quote"))
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1114 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1115 fprintf (stderr,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1116 "## 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
1117 filename);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1118 continue;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1119 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1120 read_lisp_symbol (infile, buffer);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1121 c = getc (infile);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1122 if (c != ')')
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1123 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1124 fprintf (stderr,
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1125 "## 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
1126 filename);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1127 continue;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1128 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1129 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1130
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1131 if (saved_string == 0)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1132 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1133 /* 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
1134 while (c != '\n' && c >= 0)
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1135 {
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1136 c2 = c1;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1137 c1 = c;
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1138 c = getc_skipping_iso2022 (infile);
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1139 }
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1140
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 /* If two previous characters were " and \,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 this is a doc string. Otherwise, there is none. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 if (c2 != '"' || c1 != '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 fprintf (stderr, "## non-docstring in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 else if (! strcmp (buffer, "fset") || ! strcmp (buffer, "defalias"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 char c1 = 0, c2 = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 type = 'F';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1159 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 if (c == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 if (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 fprintf (stderr, "## unparsable name in fset in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 if (strcmp (buffer, "quote"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 fprintf (stderr, "## unparsable name in fset in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 read_lisp_symbol (infile, buffer);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1178 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 if (c != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 fprintf (stderr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 "## unparsable quoted name in fset in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 if (saved_string == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 {
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1190 /* Skip to end of line; remember the two previous chars. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 while (c != '\n' && c >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 c2 = c1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 c1 = c;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1195 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 }
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1197
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 /* If two previous characters were " and \,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 this is a doc string. Otherwise, there is none. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 if (c2 != '"' || c1 != '\\')
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 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 fprintf (stderr, "## non-docstring in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 else if (! strcmp (buffer, "autoload"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 type = 'F';
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1214 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 if (c == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 if (c != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 fprintf (stderr, "## unparsable name in autoload in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 read_lisp_symbol (infile, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 if (strcmp (buffer, "quote"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 fprintf (stderr, "## unparsable name in autoload in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 read_lisp_symbol (infile, buffer);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1233 c = getc_skipping_iso2022 (infile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 if (c != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 fprintf (stderr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 "## unparsable quoted name in autoload in %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 skip_white (infile);
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1243 if ((c = getc_skipping_iso2022 (infile)) != '\"')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 fprintf (stderr, "## autoload of %s unparsable (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 read_c_string (infile, 0, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 skip_white (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 if (saved_string == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 /* If the next three characters aren't `dquote bslash newline'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 then we're not reading a docstring. */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1256 if ((c = getc_skipping_iso2022 (infile)) != '"' ||
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1257 (c = getc_skipping_iso2022 (infile)) != '\\' ||
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1258 (c = getc_skipping_iso2022 (infile)) != '\n')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 fprintf (stderr, "## non-docstring in %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1269 #if 0 /* causes crash */
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1270 else if (! strcmp (buffer, "if")
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1271 || ! strcmp (buffer, "byte-code"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 #ifdef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 fprintf (stderr, "## unrecognized top-level form, %s (%s)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 buffer, filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 continue;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 /* At this point, we should either use the previous
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 dynamic doc string in saved_string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 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
1287
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 In the latter case, the opening quote (and leading
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 backslash-newline) have already been read. */
930
eaedf30d9d76 [xemacs-hg @ 2002-07-23 08:34:59 by youngs]
youngs
parents: 853
diff changeset
1290
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 771
diff changeset
1291 putc ('\n', outfile); /* XEmacs addition */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 putc (037, outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 putc (type, outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 fprintf (outfile, "%s\n", buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 if (saved_string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 fputs (saved_string, outfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 /* Don't use one dynamic doc string twice. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 free (saved_string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 saved_string = 0;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 read_c_string (infile, 1, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 fclose (infile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 }