Mercurial > emacs
annotate lib-src/make-docfile.c @ 39986:c9411c9fab91
(put_char): New function.
(read_c_string_or_comment): Strip trailing spaces and newlines.
| author | Miles Bader <miles@gnu.org> |
|---|---|
| date | Wed, 17 Oct 2001 02:53:57 +0000 |
| parents | fa2e20b1440c |
| children | 3a1cdf305658 |
| rev | line source |
|---|---|
| 24 | 1 /* Generate doc-string file for GNU Emacs from source files. |
|
35293
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
2 Copyright (C) 1985, 86, 92, 93, 94, 97, 1999, 2000, 2001 |
|
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
3 Free Software Foundation, Inc. |
| 24 | 4 |
| 5 This file is part of GNU Emacs. | |
| 6 | |
| 38 | 7 GNU Emacs is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | |
| 638 | 9 the Free Software Foundation; either version 2, or (at your option) |
| 38 | 10 any later version. |
| 24 | 11 |
| 38 | 12 GNU Emacs is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 GNU General Public License for more details. | |
| 16 | |
| 17 You should have received a copy of the GNU General Public License | |
| 18 along with GNU Emacs; see the file COPYING. If not, write to | |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12351
diff
changeset
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
12351
diff
changeset
|
20 Boston, MA 02111-1307, USA. */ |
| 24 | 21 |
| 22 /* The arguments given to this program are all the C and Lisp source files | |
| 23 of GNU Emacs. .elc and .el and .c files are allowed. | |
| 24 A .o file can also be specified; the .c file it was made from is used. | |
| 25 This helps the makefile pass the correct list of files. | |
| 26 | |
| 27 The results, which go to standard output or to a file | |
| 28 specified with -a or -o (-a to append, -o to start from nothing), | |
| 29 are entries containing function or variable names and their documentation. | |
| 30 Each entry starts with a ^_ character. | |
| 31 Then comes F for a function or V for a variable. | |
| 32 Then comes the function or variable name, terminated with a newline. | |
| 33 Then comes the documentation for that function or variable. | |
| 34 */ | |
| 35 | |
| 11690 | 36 #define NO_SHORTNAMES /* Tell config not to load remap.h */ |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
37 #include <config.h> |
|
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
38 |
|
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
39 /* defined to be emacs_main, sys_fopen, etc. in config.h */ |
|
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
40 #undef main |
|
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
41 #undef fopen |
|
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
42 #undef chdir |
| 11690 | 43 |
| 24 | 44 #include <stdio.h> |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
45 #ifdef MSDOS |
|
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
46 #include <fcntl.h> |
|
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
47 #endif /* MSDOS */ |
|
9772
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
48 #ifdef WINDOWSNT |
|
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
49 #include <stdlib.h> |
|
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
50 #include <fcntl.h> |
|
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
51 #include <direct.h> |
|
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
52 #endif /* WINDOWSNT */ |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
53 |
|
9772
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
54 #ifdef DOS_NT |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
55 #define READ_TEXT "rt" |
|
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
56 #define READ_BINARY "rb" |
|
9772
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
57 #else /* not DOS_NT */ |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
58 #define READ_TEXT "r" |
|
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
59 #define READ_BINARY "r" |
|
9772
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
60 #endif /* not DOS_NT */ |
| 24 | 61 |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
62 int scan_file (); |
|
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
63 int scan_lisp_file (); |
|
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
64 int scan_c_file (); |
|
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
65 |
| 12134 | 66 #ifdef MSDOS |
| 67 /* s/msdos.h defines this as sys_chdir, but we're not linking with the | |
| 68 file where that function is defined. */ | |
| 69 #undef chdir | |
| 70 #endif | |
| 71 | |
|
21783
798a28989dde
Include <unistd.h> for chdir.
Andreas Schwab <schwab@suse.de>
parents:
19636
diff
changeset
|
72 #ifdef HAVE_UNISTD_H |
|
798a28989dde
Include <unistd.h> for chdir.
Andreas Schwab <schwab@suse.de>
parents:
19636
diff
changeset
|
73 #include <unistd.h> |
|
798a28989dde
Include <unistd.h> for chdir.
Andreas Schwab <schwab@suse.de>
parents:
19636
diff
changeset
|
74 #endif |
|
798a28989dde
Include <unistd.h> for chdir.
Andreas Schwab <schwab@suse.de>
parents:
19636
diff
changeset
|
75 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
76 /* Stdio stream for output to the DOC file. */ |
| 24 | 77 FILE *outfile; |
| 78 | |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
79 /* Name this program was invoked with. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
80 char *progname; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
81 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
82 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
83 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
84 /* VARARGS1 */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
85 void |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
86 error (s1, s2) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
87 char *s1, *s2; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
88 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
89 fprintf (stderr, "%s: ", progname); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
90 fprintf (stderr, s1, s2); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
91 fprintf (stderr, "\n"); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
92 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
93 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
94 /* Print error message and exit. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
95 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
96 /* VARARGS1 */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
97 void |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
98 fatal (s1, s2) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
99 char *s1, *s2; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
100 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
101 error (s1, s2); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
102 exit (1); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
103 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
104 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
105 /* Like malloc but get fatal error if memory is exhausted. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
106 |
| 11690 | 107 long * |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
108 xmalloc (size) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
109 unsigned int size; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
110 { |
| 11690 | 111 long *result = (long *) malloc (size); |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
112 if (result == NULL) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
113 fatal ("virtual memory exhausted", 0); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
114 return result; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
115 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
116 |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
117 int |
| 24 | 118 main (argc, argv) |
| 119 int argc; | |
| 120 char **argv; | |
| 121 { | |
| 122 int i; | |
| 123 int err_count = 0; | |
|
9643
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
124 int first_infile; |
| 24 | 125 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
126 progname = argv[0]; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
127 |
|
12328
dbc55496f684
(main): On MSDOS, don't change stdout to binary, and insist on an -o option.
Richard M. Stallman <rms@gnu.org>
parents:
12134
diff
changeset
|
128 outfile = stdout; |
|
dbc55496f684
(main): On MSDOS, don't change stdout to binary, and insist on an -o option.
Richard M. Stallman <rms@gnu.org>
parents:
12134
diff
changeset
|
129 |
|
9772
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
130 /* Don't put CRs in the DOC file. */ |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
131 #ifdef MSDOS |
|
12350
68508136431f
(main) [MSDOS]: Do set _fmode.
Richard M. Stallman <rms@gnu.org>
parents:
12328
diff
changeset
|
132 _fmode = O_BINARY; |
|
12328
dbc55496f684
(main): On MSDOS, don't change stdout to binary, and insist on an -o option.
Richard M. Stallman <rms@gnu.org>
parents:
12134
diff
changeset
|
133 #if 0 /* Suspicion is that this causes hanging. |
|
dbc55496f684
(main): On MSDOS, don't change stdout to binary, and insist on an -o option.
Richard M. Stallman <rms@gnu.org>
parents:
12134
diff
changeset
|
134 So instead we require people to use -o on MSDOS. */ |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
135 (stdout)->_flag &= ~_IOTEXT; |
|
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
136 _setmode (fileno (stdout), O_BINARY); |
|
12328
dbc55496f684
(main): On MSDOS, don't change stdout to binary, and insist on an -o option.
Richard M. Stallman <rms@gnu.org>
parents:
12134
diff
changeset
|
137 #endif |
|
dbc55496f684
(main): On MSDOS, don't change stdout to binary, and insist on an -o option.
Richard M. Stallman <rms@gnu.org>
parents:
12134
diff
changeset
|
138 outfile = 0; |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
139 #endif /* MSDOS */ |
|
9772
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
140 #ifdef WINDOWSNT |
|
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
141 _fmode = O_BINARY; |
|
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
142 _setmode (fileno (stdout), O_BINARY); |
|
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
143 #endif /* WINDOWSNT */ |
|
20652342eb9a
(main) [WINDOWSNT]: Now sets _fmode and stdout to O_BINARY.
Richard M. Stallman <rms@gnu.org>
parents:
9643
diff
changeset
|
144 |
| 24 | 145 /* If first two args are -o FILE, output to FILE. */ |
| 146 i = 1; | |
| 147 if (argc > i + 1 && !strcmp (argv[i], "-o")) | |
| 148 { | |
| 149 outfile = fopen (argv[i + 1], "w"); | |
| 150 i += 2; | |
| 151 } | |
| 152 if (argc > i + 1 && !strcmp (argv[i], "-a")) | |
| 153 { | |
| 154 outfile = fopen (argv[i + 1], "a"); | |
| 155 i += 2; | |
| 156 } | |
|
2814
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
2483
diff
changeset
|
157 if (argc > i + 1 && !strcmp (argv[i], "-d")) |
|
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
2483
diff
changeset
|
158 { |
|
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
2483
diff
changeset
|
159 chdir (argv[i + 1]); |
|
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
2483
diff
changeset
|
160 i += 2; |
|
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
2483
diff
changeset
|
161 } |
| 24 | 162 |
|
12328
dbc55496f684
(main): On MSDOS, don't change stdout to binary, and insist on an -o option.
Richard M. Stallman <rms@gnu.org>
parents:
12134
diff
changeset
|
163 if (outfile == 0) |
|
dbc55496f684
(main): On MSDOS, don't change stdout to binary, and insist on an -o option.
Richard M. Stallman <rms@gnu.org>
parents:
12134
diff
changeset
|
164 fatal ("No output file specified", ""); |
|
dbc55496f684
(main): On MSDOS, don't change stdout to binary, and insist on an -o option.
Richard M. Stallman <rms@gnu.org>
parents:
12134
diff
changeset
|
165 |
|
9643
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
166 first_infile = i; |
| 24 | 167 for (; i < argc; i++) |
|
9643
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
168 { |
|
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
169 int j; |
|
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
170 /* Don't process one file twice. */ |
|
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
171 for (j = first_infile; j < i; j++) |
|
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
172 if (! strcmp (argv[i], argv[j])) |
|
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
173 break; |
|
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
174 if (j == i) |
|
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
175 err_count += scan_file (argv[i]); |
|
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
176 } |
| 24 | 177 #ifndef VMS |
|
9643
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
178 exit (err_count > 0); |
| 3028 | 179 #endif /* VMS */ |
|
9643
5d1e70b22a93
(main): Don't process one input file twice.
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
180 return err_count > 0; |
| 24 | 181 } |
| 182 | |
| 164 | 183 /* Read file FILENAME and output its doc strings to outfile. */ |
| 24 | 184 /* Return 1 if file is not found, 0 if it is found. */ |
| 185 | |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
186 int |
| 24 | 187 scan_file (filename) |
| 188 char *filename; | |
| 189 { | |
| 190 int len = strlen (filename); | |
|
12351
f2e9eb6a8939
(scan_file): Make sure it never looks at filename[-1].
Richard M. Stallman <rms@gnu.org>
parents:
12350
diff
changeset
|
191 if (len > 4 && !strcmp (filename + len - 4, ".elc")) |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
192 return scan_lisp_file (filename, READ_BINARY); |
|
12351
f2e9eb6a8939
(scan_file): Make sure it never looks at filename[-1].
Richard M. Stallman <rms@gnu.org>
parents:
12350
diff
changeset
|
193 else if (len > 3 && !strcmp (filename + len - 3, ".el")) |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
194 return scan_lisp_file (filename, READ_TEXT); |
| 24 | 195 else |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
196 return scan_c_file (filename, READ_TEXT); |
| 24 | 197 } |
| 198 | |
| 199 char buf[128]; | |
| 200 | |
| 39986 | 201 /* Add CH to either outfile, if PRINTFLAG is positive, or to the buffer |
| 202 whose end is pointed to by BUFP, if PRINTFLAG is negative. | |
| 203 If the counters pointed to by PENDING_NEWLINES and PENDING_SPACES are | |
| 204 non-zero, that many newlines and spaces are output before CH, and | |
| 205 the counters are zeroed. */ | |
| 206 | |
| 207 static INLINE void | |
| 208 put_char (ch, printflag, bufp, pending_newlines, pending_spaces) | |
| 209 int ch, printflag; | |
| 210 char **bufp; | |
| 211 unsigned *pending_newlines, *pending_spaces; | |
| 212 { | |
| 213 int out_ch; | |
| 214 do | |
| 215 { | |
| 216 if (*pending_newlines > 0) | |
| 217 { | |
| 218 (*pending_newlines)--; | |
| 219 out_ch = '\n'; | |
| 220 } | |
| 221 else if (*pending_spaces > 0) | |
| 222 { | |
| 223 (*pending_spaces)--; | |
| 224 out_ch = ' '; | |
| 225 } | |
| 226 else | |
| 227 out_ch = ch; | |
| 228 | |
| 229 if (printflag > 0) | |
| 230 putc (out_ch, outfile); | |
| 231 else if (printflag < 0) | |
| 232 *(*bufp)++ = out_ch; | |
| 233 } | |
| 234 while (out_ch != ch); | |
| 235 } | |
| 236 | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
237 /* Skip a C string or C-style comment from INFILE, and return the |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
238 character that follows. COMMENT non-zero means skip a comment. If |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
239 PRINTFLAG is positive, output string contents to outfile. If it is |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
240 negative, store contents in buf. Convert escape sequences \n and |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
241 \t to newline and tab; discard \ followed by newline. */ |
| 24 | 242 |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
243 int |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
244 read_c_string_or_comment (infile, printflag, comment) |
| 24 | 245 FILE *infile; |
| 246 int printflag; | |
| 247 { | |
| 248 register int c; | |
| 39986 | 249 unsigned pending_spaces = 0, pending_newlines = 0; |
| 24 | 250 char *p = buf; |
| 251 | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
252 if (comment) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
253 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
254 while ((c = getc (infile)) != EOF |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
255 && (c == '\n' || c == '\r' || c == '\t' || c == ' ')) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
256 ; |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
257 } |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
258 else |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
259 c = getc (infile); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
260 |
| 24 | 261 while (c != EOF) |
| 262 { | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
263 while (c != EOF && (comment ? c != '*' : c != '"')) |
| 24 | 264 { |
| 265 if (c == '\\') | |
| 266 { | |
| 267 c = getc (infile); | |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
268 if (c == '\n' || c == '\r') |
| 24 | 269 { |
| 270 c = getc (infile); | |
| 271 continue; | |
| 272 } | |
| 273 if (c == 'n') | |
| 274 c = '\n'; | |
| 275 if (c == 't') | |
| 276 c = '\t'; | |
| 277 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
278 |
| 39986 | 279 if (c == ' ') |
| 280 pending_spaces++; | |
| 281 else if (c == '\n') | |
| 282 { | |
| 283 pending_newlines++; | |
| 284 pending_spaces = 0; | |
| 285 } | |
| 286 else | |
| 287 put_char (c, printflag, &p, &pending_newlines, &pending_spaces); | |
| 288 | |
| 24 | 289 c = getc (infile); |
| 290 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
291 |
|
39949
f169b10c8e00
(read_c_string_or_comment): Don't drop a '*'
Gerd Moellmann <gerd@gnu.org>
parents:
39897
diff
changeset
|
292 if (c != EOF) |
|
f169b10c8e00
(read_c_string_or_comment): Don't drop a '*'
Gerd Moellmann <gerd@gnu.org>
parents:
39897
diff
changeset
|
293 c = getc (infile); |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
294 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
295 if (comment) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
296 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
297 if (c == '/') |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
298 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
299 c = getc (infile); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
300 break; |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
301 } |
|
39949
f169b10c8e00
(read_c_string_or_comment): Don't drop a '*'
Gerd Moellmann <gerd@gnu.org>
parents:
39897
diff
changeset
|
302 |
| 39986 | 303 put_char ('*', printflag, &p, &pending_newlines, &pending_spaces); |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
304 } |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
305 else |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
306 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
307 if (c != '"') |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
308 break; |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
309 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
310 /* If we had a "", concatenate the two strings. */ |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
311 c = getc (infile); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
312 } |
| 24 | 313 } |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
314 |
| 24 | 315 if (printflag < 0) |
| 316 *p = 0; | |
| 317 | |
| 318 return c; | |
| 319 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
320 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
321 |
| 24 | 322 |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
323 /* Write to file OUT the argument names of function FUNC, whose text is in BUF. |
| 24 | 324 MINARGS and MAXARGS are the minimum and maximum number of arguments. */ |
| 325 | |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
326 void |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
327 write_c_args (out, func, buf, minargs, maxargs) |
| 24 | 328 FILE *out; |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
329 char *func, *buf; |
| 24 | 330 int minargs, maxargs; |
| 331 { | |
| 1206 | 332 register char *p; |
| 1250 | 333 int in_ident = 0; |
| 334 int just_spaced = 0; | |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
335 int need_space = 1; |
| 24 | 336 |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
337 fprintf (out, "(%s", func); |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
338 |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
339 if (*buf == '(') |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
340 ++buf; |
| 24 | 341 |
| 1206 | 342 for (p = buf; *p; p++) |
| 24 | 343 { |
| 1250 | 344 char c = *p; |
|
2483
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
345 int ident_start = 0; |
| 1250 | 346 |
| 347 /* Notice when we start printing a new identifier. */ | |
| 348 if ((('A' <= c && c <= 'Z') | |
| 349 || ('a' <= c && c <= 'z') | |
| 350 || ('0' <= c && c <= '9') | |
| 351 || c == '_') | |
| 352 != in_ident) | |
| 24 | 353 { |
| 1250 | 354 if (!in_ident) |
| 355 { | |
| 356 in_ident = 1; | |
|
2483
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
357 ident_start = 1; |
| 1206 | 358 |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
359 if (need_space) |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
360 putc (' ', out); |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
361 |
| 1250 | 362 if (minargs == 0 && maxargs > 0) |
| 363 fprintf (out, "&optional "); | |
| 364 just_spaced = 1; | |
| 1206 | 365 |
| 1250 | 366 minargs--; |
| 367 maxargs--; | |
| 368 } | |
| 369 else | |
| 370 in_ident = 0; | |
| 24 | 371 } |
| 638 | 372 |
| 1250 | 373 /* Print the C argument list as it would appear in lisp: |
|
35293
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
374 print underscores as hyphens, and print commas and newlines |
|
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
375 as spaces. Collapse adjacent spaces into one. */ |
|
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
376 if (c == '_') |
|
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
377 c = '-'; |
|
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
378 else if (c == ',' || c == '\n') |
|
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
379 c = ' '; |
| 1250 | 380 |
|
2483
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
381 /* In C code, `default' is a reserved word, so we spell it |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
382 `defalt'; unmangle that here. */ |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
383 if (ident_start |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
384 && strncmp (p, "defalt", 6) == 0 |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
385 && ! (('A' <= p[6] && p[6] <= 'Z') |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
386 || ('a' <= p[6] && p[6] <= 'z') |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
387 || ('0' <= p[6] && p[6] <= '9') |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
388 || p[6] == '_')) |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
389 { |
|
7564
d5d803ffff27
(write_c_args): Put `default' in upper case.
Richard M. Stallman <rms@gnu.org>
parents:
5604
diff
changeset
|
390 fprintf (out, "DEFAULT"); |
|
2483
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
391 p += 5; |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
392 in_ident = 0; |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
393 just_spaced = 0; |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
394 } |
|
35293
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
395 else if (c != ' ' || !just_spaced) |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
396 { |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
397 if (c >= 'a' && c <= 'z') |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
398 /* Upcase the letter. */ |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
399 c += 'A' - 'a'; |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
400 putc (c, out); |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
401 } |
| 1250 | 402 |
|
35293
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
403 just_spaced = c == ' '; |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
404 need_space = 0; |
| 24 | 405 } |
| 406 } | |
| 407 | |
| 408 /* Read through a c file. If a .o file is named, | |
| 409 the corresponding .c file is read instead. | |
| 410 Looks for DEFUN constructs such as are defined in ../src/lisp.h. | |
| 411 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */ | |
| 412 | |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
413 int |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
414 scan_c_file (filename, mode) |
|
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
415 char *filename, *mode; |
| 24 | 416 { |
| 417 FILE *infile; | |
| 418 register int c; | |
| 419 register int commas; | |
| 420 register int defunflag; | |
|
1676
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
421 register int defvarperbufferflag; |
| 24 | 422 register int defvarflag; |
| 423 int minargs, maxargs; | |
|
11413
9cd115f44483
(scan_c_file): At end, restore file name last char to its original value.
Richard M. Stallman <rms@gnu.org>
parents:
10199
diff
changeset
|
424 int extension = filename[strlen (filename) - 1]; |
| 24 | 425 |
|
11413
9cd115f44483
(scan_c_file): At end, restore file name last char to its original value.
Richard M. Stallman <rms@gnu.org>
parents:
10199
diff
changeset
|
426 if (extension == 'o') |
| 24 | 427 filename[strlen (filename) - 1] = 'c'; |
| 428 | |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
429 infile = fopen (filename, mode); |
| 24 | 430 |
| 431 /* No error if non-ex input file */ | |
| 432 if (infile == NULL) | |
| 433 { | |
| 434 perror (filename); | |
| 435 return 0; | |
| 436 } | |
| 437 | |
|
11413
9cd115f44483
(scan_c_file): At end, restore file name last char to its original value.
Richard M. Stallman <rms@gnu.org>
parents:
10199
diff
changeset
|
438 /* Reset extension to be able to detect duplicate files. */ |
|
9cd115f44483
(scan_c_file): At end, restore file name last char to its original value.
Richard M. Stallman <rms@gnu.org>
parents:
10199
diff
changeset
|
439 filename[strlen (filename) - 1] = extension; |
|
9cd115f44483
(scan_c_file): At end, restore file name last char to its original value.
Richard M. Stallman <rms@gnu.org>
parents:
10199
diff
changeset
|
440 |
| 24 | 441 c = '\n'; |
| 442 while (!feof (infile)) | |
| 443 { | |
|
39976
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
444 int doc_keyword = 0; |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
445 |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
446 if (c != '\n' && c != '\r') |
| 24 | 447 { |
| 448 c = getc (infile); | |
| 449 continue; | |
| 450 } | |
| 451 c = getc (infile); | |
| 452 if (c == ' ') | |
| 453 { | |
| 454 while (c == ' ') | |
| 455 c = getc (infile); | |
| 456 if (c != 'D') | |
| 457 continue; | |
| 458 c = getc (infile); | |
| 459 if (c != 'E') | |
| 460 continue; | |
| 461 c = getc (infile); | |
| 462 if (c != 'F') | |
| 463 continue; | |
| 464 c = getc (infile); | |
| 465 if (c != 'V') | |
| 466 continue; | |
|
1676
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
467 c = getc (infile); |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
468 if (c != 'A') |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
469 continue; |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
470 c = getc (infile); |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
471 if (c != 'R') |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
472 continue; |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
473 c = getc (infile); |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
474 if (c != '_') |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
475 continue; |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
476 |
| 24 | 477 defvarflag = 1; |
| 478 defunflag = 0; | |
|
1676
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
479 |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
480 c = getc (infile); |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
481 defvarperbufferflag = (c == 'P'); |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
482 |
| 24 | 483 c = getc (infile); |
| 484 } | |
| 485 else if (c == 'D') | |
| 486 { | |
| 487 c = getc (infile); | |
| 488 if (c != 'E') | |
| 489 continue; | |
| 490 c = getc (infile); | |
| 491 if (c != 'F') | |
| 492 continue; | |
| 493 c = getc (infile); | |
| 494 defunflag = c == 'U'; | |
| 495 defvarflag = 0; | |
| 496 } | |
| 497 else continue; | |
| 498 | |
| 499 while (c != '(') | |
| 500 { | |
| 501 if (c < 0) | |
| 502 goto eof; | |
| 503 c = getc (infile); | |
| 504 } | |
| 505 | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
506 /* Lisp variable or function name. */ |
| 24 | 507 c = getc (infile); |
| 508 if (c != '"') | |
| 509 continue; | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
510 c = read_c_string_or_comment (infile, -1, 0); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
511 |
|
39976
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
512 /* DEFVAR_LISP ("name", addr, "doc") |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
513 DEFVAR_LISP ("name", addr /\* doc *\/) |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
514 DEFVAR_LISP ("name", addr, doc: /\* doc *\/) */ |
| 24 | 515 |
| 516 if (defunflag) | |
| 517 commas = 5; | |
|
1676
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
518 else if (defvarperbufferflag) |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
519 commas = 2; |
| 24 | 520 else if (defvarflag) |
| 521 commas = 1; | |
| 522 else /* For DEFSIMPLE and DEFPRED */ | |
| 523 commas = 2; | |
| 524 | |
| 525 while (commas) | |
| 526 { | |
| 527 if (c == ',') | |
| 528 { | |
| 529 commas--; | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
530 |
| 24 | 531 if (defunflag && (commas == 1 || commas == 2)) |
| 532 { | |
| 533 do | |
| 534 c = getc (infile); | |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
535 while (c == ' ' || c == '\n' || c == '\r' || c == '\t'); |
| 24 | 536 if (c < 0) |
| 537 goto eof; | |
| 538 ungetc (c, infile); | |
| 539 if (commas == 2) /* pick up minargs */ | |
| 540 fscanf (infile, "%d", &minargs); | |
| 541 else /* pick up maxargs */ | |
| 542 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ | |
| 543 maxargs = -1; | |
| 544 else | |
| 545 fscanf (infile, "%d", &maxargs); | |
| 546 } | |
| 547 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
548 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
549 if (c == EOF) |
| 24 | 550 goto eof; |
| 551 c = getc (infile); | |
| 552 } | |
|
39976
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
553 |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
554 while (c == ' ' || c == '\n' || c == '\r' || c == '\t') |
| 24 | 555 c = getc (infile); |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
556 |
| 24 | 557 if (c == '"') |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
558 c = read_c_string_or_comment (infile, 0, 0); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
559 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
560 while (c != EOF && c != ',' && c != '/') |
| 24 | 561 c = getc (infile); |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
562 if (c == ',') |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
563 { |
|
39976
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
564 c = getc (infile); |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
565 while (c == ' ' || c == '\n' || c == '\r' || c == '\t') |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
566 c = getc (infile); |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
567 while ((c >= 'a' && c <= 'z') || (c >= 'Z' && c <= 'Z')) |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
568 c = getc (infile); |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
569 if (c == ':') |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
570 { |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
571 doc_keyword = 1; |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
572 c = getc (infile); |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
573 while (c == ' ' || c == '\n' || c == '\r' || c == '\t') |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
574 c = getc (infile); |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
575 } |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
576 } |
| 24 | 577 |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
578 if (c == '"' |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
579 || (c == '/' |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
580 && (c = getc (infile), |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
581 ungetc (c, infile), |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
582 c == '*'))) |
| 24 | 583 { |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
584 int comment = c != '"'; |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
585 |
| 24 | 586 putc (037, outfile); |
| 587 putc (defvarflag ? 'V' : 'F', outfile); | |
| 588 fprintf (outfile, "%s\n", buf); | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
589 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
590 if (comment) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
591 getc (infile); /* Skip past `*' */ |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
592 c = read_c_string_or_comment (infile, 1, comment); |
| 168 | 593 |
| 594 /* If this is a defun, find the arguments and print them. If | |
| 595 this function takes MANY or UNEVALLED args, then the C source | |
| 596 won't give the names of the arguments, so we shouldn't bother | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
597 trying to find them. |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
598 |
|
39976
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
599 Various doc-string styles: |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
600 0: DEFUN (..., "DOC") (args) [!comment] |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
601 1: DEFUN (..., /\* DOC *\/ (args)) [comment && !doc_keyword] |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
602 2: DEFUN (..., doc: /\* DOC *\/) (args) [comment && doc_keyword] |
|
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
603 */ |
| 168 | 604 if (defunflag && maxargs != -1) |
| 24 | 605 { |
| 606 char argbuf[1024], *p = argbuf; | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
607 |
|
39976
fa2e20b1440c
(scan_c_file): Handle `new style' doc strings in comments [with `doc:'
Miles Bader <miles@gnu.org>
parents:
39949
diff
changeset
|
608 if (!comment || doc_keyword) |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
609 while (c != ')') |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
610 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
611 if (c < 0) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
612 goto eof; |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
613 c = getc (infile); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
614 } |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
615 |
| 24 | 616 /* Skip into arguments. */ |
| 617 while (c != '(') | |
| 618 { | |
| 619 if (c < 0) | |
| 620 goto eof; | |
| 621 c = getc (infile); | |
| 622 } | |
| 623 /* Copy arguments into ARGBUF. */ | |
| 624 *p++ = c; | |
| 625 do | |
| 626 *p++ = c = getc (infile); | |
| 627 while (c != ')'); | |
| 628 *p = '\0'; | |
| 629 /* Output them. */ | |
| 630 fprintf (outfile, "\n\n"); | |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
631 write_c_args (outfile, buf, argbuf, minargs, maxargs); |
| 24 | 632 } |
| 633 } | |
| 634 } | |
| 635 eof: | |
| 636 fclose (infile); | |
| 637 return 0; | |
| 638 } | |
| 639 | |
| 640 /* Read a file of Lisp code, compiled or interpreted. | |
| 641 Looks for | |
| 642 (defun NAME ARGS DOCSTRING ...) | |
| 753 | 643 (defmacro NAME ARGS DOCSTRING ...) |
|
28401
65f19ae2c578
(scan_lisp_file): Also look for `defsubst'.
Andreas Schwab <schwab@suse.de>
parents:
26083
diff
changeset
|
644 (defsubst NAME ARGS DOCSTRING ...) |
| 753 | 645 (autoload (quote NAME) FILE DOCSTRING ...) |
| 24 | 646 (defvar NAME VALUE DOCSTRING) |
| 647 (defconst NAME VALUE DOCSTRING) | |
| 753 | 648 (fset (quote NAME) (make-byte-code ... DOCSTRING ...)) |
| 649 (fset (quote NAME) #[... DOCSTRING ...]) | |
|
2966
e936d56c2354
(scan_lisp_file): Recognize defalias like fset.
Richard M. Stallman <rms@gnu.org>
parents:
2814
diff
changeset
|
650 (defalias (quote NAME) #[... DOCSTRING ...]) |
|
19636
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
651 (custom-declare-variable (quote NAME) VALUE DOCSTRING ...) |
| 24 | 652 starting in column zero. |
| 753 | 653 (quote NAME) may appear as 'NAME as well. |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
654 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
655 We also look for #@LENGTH CONTENTS^_ at the beginning of the line. |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
656 When we find that, we save it for the following defining-form, |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
657 and we use that instead of reading a doc string within that defining-form. |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
658 |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3028
diff
changeset
|
659 For defvar, defconst, and fset we skip to the docstring with a kludgy |
| 753 | 660 formatting convention: all docstrings must appear on the same line as the |
| 661 initial open-paren (the one in column zero) and must contain a backslash | |
|
25536
2cfdaebe325c
Fix comment about conventions for Lisp files.
Dave Love <fx@gnu.org>
parents:
25532
diff
changeset
|
662 and a newline immediately after the initial double-quote. No newlines |
| 753 | 663 must appear between the beginning of the form and the first double-quote. |
|
25536
2cfdaebe325c
Fix comment about conventions for Lisp files.
Dave Love <fx@gnu.org>
parents:
25532
diff
changeset
|
664 For defun, defmacro, and autoload, we know how to skip over the |
|
2cfdaebe325c
Fix comment about conventions for Lisp files.
Dave Love <fx@gnu.org>
parents:
25532
diff
changeset
|
665 arglist, but the doc string must still have a backslash and newline |
|
2cfdaebe325c
Fix comment about conventions for Lisp files.
Dave Love <fx@gnu.org>
parents:
25532
diff
changeset
|
666 immediately after the double quote. |
|
2cfdaebe325c
Fix comment about conventions for Lisp files.
Dave Love <fx@gnu.org>
parents:
25532
diff
changeset
|
667 The only source files that must follow this convention are preloaded |
|
2cfdaebe325c
Fix comment about conventions for Lisp files.
Dave Love <fx@gnu.org>
parents:
25532
diff
changeset
|
668 uncompiled ones like loaddefs.el and bindings.el; aside |
| 753 | 669 from that, it is always the .elc file that we look at, and they are no |
| 670 problem because byte-compiler output follows this convention. | |
| 24 | 671 The NAME and DOCSTRING are output. |
| 672 NAME is preceded by `F' for a function or `V' for a variable. | |
| 673 An entry is output only if DOCSTRING has \ newline just after the opening " | |
| 674 */ | |
| 675 | |
| 753 | 676 void |
| 677 skip_white (infile) | |
| 678 FILE *infile; | |
| 679 { | |
| 680 char c = ' '; | |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
681 while (c == ' ' || c == '\t' || c == '\n' || c == '\r') |
| 753 | 682 c = getc (infile); |
| 683 ungetc (c, infile); | |
| 684 } | |
| 685 | |
| 686 void | |
| 687 read_lisp_symbol (infile, buffer) | |
| 688 FILE *infile; | |
| 689 char *buffer; | |
| 690 { | |
| 691 char c; | |
| 692 char *fillp = buffer; | |
| 693 | |
| 694 skip_white (infile); | |
| 695 while (1) | |
| 696 { | |
| 697 c = getc (infile); | |
| 698 if (c == '\\') | |
| 699 *(++fillp) = getc (infile); | |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
700 else if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '(' || c == ')') |
| 753 | 701 { |
| 702 ungetc (c, infile); | |
| 703 *fillp = 0; | |
| 704 break; | |
| 705 } | |
| 706 else | |
| 707 *fillp++ = c; | |
| 708 } | |
| 709 | |
| 710 if (! buffer[0]) | |
| 711 fprintf (stderr, "## expected a symbol, got '%c'\n", c); | |
| 712 | |
| 713 skip_white (infile); | |
| 714 } | |
| 715 | |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
716 int |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
717 scan_lisp_file (filename, mode) |
|
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
718 char *filename, *mode; |
| 24 | 719 { |
| 720 FILE *infile; | |
| 721 register int c; | |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
722 char *saved_string = 0; |
| 24 | 723 |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
724 infile = fopen (filename, mode); |
| 24 | 725 if (infile == NULL) |
| 726 { | |
| 727 perror (filename); | |
| 728 return 0; /* No error */ | |
| 729 } | |
| 730 | |
| 731 c = '\n'; | |
| 732 while (!feof (infile)) | |
| 733 { | |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
734 char buffer[BUFSIZ]; |
| 753 | 735 char type; |
| 736 | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
737 /* If not at end of line, skip till we get to one. */ |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
738 if (c != '\n' && c != '\r') |
| 24 | 739 { |
| 740 c = getc (infile); | |
| 741 continue; | |
| 742 } | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
743 /* Skip the line break. */ |
|
25821
9a999c51f856
(scan_lisp_file): Fix typo causing infloop.
Dave Love <fx@gnu.org>
parents:
25809
diff
changeset
|
744 while (c == '\n' || c == '\r') |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
745 c = getc (infile); |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
746 /* Detect a dynamic doc string and save it for the next expression. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
747 if (c == '#') |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
748 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
749 c = getc (infile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
750 if (c == '@') |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
751 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
752 int length = 0; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
753 int i; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
754 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
755 /* Read the length. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
756 while ((c = getc (infile), |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
757 c >= '0' && c <= '9')) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
758 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
759 length *= 10; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
760 length += c - '0'; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
761 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
762 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
763 /* The next character is a space that is counted in the length |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
764 but not part of the doc string. |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
765 We already read it, so just ignore it. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
766 length--; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
767 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
768 /* Read in the contents. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
769 if (saved_string != 0) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
770 free (saved_string); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
771 saved_string = (char *) malloc (length); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
772 for (i = 0; i < length; i++) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
773 saved_string[i] = getc (infile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
774 /* The last character is a ^_. |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
775 That is needed in the .elc file |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
776 but it is redundant in DOC. So get rid of it here. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
777 saved_string[length - 1] = 0; |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
778 /* Skip the line break. */ |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
779 while (c == '\n' && c == '\r') |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
780 c = getc (infile); |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
781 /* Skip the following line. */ |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
782 while (c != '\n' && c != '\r') |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
783 c = getc (infile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
784 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
785 continue; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
786 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
787 |
| 24 | 788 if (c != '(') |
| 789 continue; | |
| 164 | 790 |
| 753 | 791 read_lisp_symbol (infile, buffer); |
| 792 | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
793 if (! strcmp (buffer, "defun") |
|
28401
65f19ae2c578
(scan_lisp_file): Also look for `defsubst'.
Andreas Schwab <schwab@suse.de>
parents:
26083
diff
changeset
|
794 || ! strcmp (buffer, "defmacro") |
|
65f19ae2c578
(scan_lisp_file): Also look for `defsubst'.
Andreas Schwab <schwab@suse.de>
parents:
26083
diff
changeset
|
795 || ! strcmp (buffer, "defsubst")) |
| 24 | 796 { |
| 753 | 797 type = 'F'; |
| 798 read_lisp_symbol (infile, buffer); | |
| 799 | |
| 800 /* Skip the arguments: either "nil" or a list in parens */ | |
| 24 | 801 |
| 802 c = getc (infile); | |
| 753 | 803 if (c == 'n') /* nil */ |
| 804 { | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
805 if ((c = getc (infile)) != 'i' |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
806 || (c = getc (infile)) != 'l') |
| 753 | 807 { |
| 808 fprintf (stderr, "## unparsable arglist in %s (%s)\n", | |
| 809 buffer, filename); | |
| 810 continue; | |
| 811 } | |
| 812 } | |
| 813 else if (c != '(') | |
| 814 { | |
| 815 fprintf (stderr, "## unparsable arglist in %s (%s)\n", | |
| 816 buffer, filename); | |
| 817 continue; | |
| 818 } | |
| 819 else | |
| 820 while (c != ')') | |
| 821 c = getc (infile); | |
| 822 skip_white (infile); | |
| 24 | 823 |
| 753 | 824 /* If the next three characters aren't `dquote bslash newline' |
| 825 then we're not reading a docstring. | |
| 826 */ | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
827 if ((c = getc (infile)) != '"' |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
828 || (c = getc (infile)) != '\\' |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
829 || ((c = getc (infile)) != '\n' && c != '\r')) |
| 24 | 830 { |
| 753 | 831 #ifdef DEBUG |
| 832 fprintf (stderr, "## non-docstring in %s (%s)\n", | |
| 833 buffer, filename); | |
| 834 #endif | |
| 835 continue; | |
| 836 } | |
| 837 } | |
| 838 | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
839 else if (! strcmp (buffer, "defvar") |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
840 || ! strcmp (buffer, "defconst")) |
| 753 | 841 { |
| 842 char c1 = 0, c2 = 0; | |
| 843 type = 'V'; | |
| 844 read_lisp_symbol (infile, buffer); | |
| 845 | |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
846 if (saved_string == 0) |
| 753 | 847 { |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
848 |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
849 /* Skip until the end of line; remember two previous chars. */ |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
850 while (c != '\n' && c != '\r' && c >= 0) |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
851 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
852 c2 = c1; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
853 c1 = c; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
854 c = getc (infile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
855 } |
| 753 | 856 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
857 /* If two previous characters were " and \, |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
858 this is a doc string. Otherwise, there is none. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
859 if (c2 != '"' || c1 != '\\') |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
860 { |
| 753 | 861 #ifdef DEBUG |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
862 fprintf (stderr, "## non-docstring in %s (%s)\n", |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
863 buffer, filename); |
| 753 | 864 #endif |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
865 continue; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
866 } |
| 753 | 867 } |
| 868 } | |
| 869 | |
|
19636
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
870 else if (! strcmp (buffer, "custom-declare-variable")) |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
871 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
872 char c1 = 0, c2 = 0; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
873 type = 'V'; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
874 |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
875 c = getc (infile); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
876 if (c == '\'') |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
877 read_lisp_symbol (infile, buffer); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
878 else |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
879 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
880 if (c != '(') |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
881 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
882 fprintf (stderr, |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
883 "## unparsable name in custom-declare-variable in %s\n", |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
884 filename); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
885 continue; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
886 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
887 read_lisp_symbol (infile, buffer); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
888 if (strcmp (buffer, "quote")) |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
889 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
890 fprintf (stderr, |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
891 "## unparsable name in custom-declare-variable in %s\n", |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
892 filename); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
893 continue; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
894 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
895 read_lisp_symbol (infile, buffer); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
896 c = getc (infile); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
897 if (c != ')') |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
898 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
899 fprintf (stderr, |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
900 "## unparsable quoted name in custom-declare-variable in %s\n", |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
901 filename); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
902 continue; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
903 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
904 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
905 |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
906 if (saved_string == 0) |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
907 { |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
908 /* Skip to end of line; remember the two previous chars. */ |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
909 while (c != '\n' && c != '\r' && c >= 0) |
|
19636
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
910 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
911 c2 = c1; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
912 c1 = c; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
913 c = getc (infile); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
914 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
915 |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
916 /* If two previous characters were " and \, |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
917 this is a doc string. Otherwise, there is none. */ |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
918 if (c2 != '"' || c1 != '\\') |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
919 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
920 #ifdef DEBUG |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
921 fprintf (stderr, "## non-docstring in %s (%s)\n", |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
922 buffer, filename); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
923 #endif |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
924 continue; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
925 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
926 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
927 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
928 |
|
2966
e936d56c2354
(scan_lisp_file): Recognize defalias like fset.
Richard M. Stallman <rms@gnu.org>
parents:
2814
diff
changeset
|
929 else if (! strcmp (buffer, "fset") || ! strcmp (buffer, "defalias")) |
| 753 | 930 { |
| 931 char c1 = 0, c2 = 0; | |
| 932 type = 'F'; | |
| 933 | |
| 934 c = getc (infile); | |
| 935 if (c == '\'') | |
| 936 read_lisp_symbol (infile, buffer); | |
| 24 | 937 else |
| 938 { | |
| 939 if (c != '(') | |
| 753 | 940 { |
| 941 fprintf (stderr, "## unparsable name in fset in %s\n", | |
| 942 filename); | |
| 943 continue; | |
| 944 } | |
| 945 read_lisp_symbol (infile, buffer); | |
| 946 if (strcmp (buffer, "quote")) | |
| 947 { | |
| 948 fprintf (stderr, "## unparsable name in fset in %s\n", | |
| 949 filename); | |
| 950 continue; | |
| 951 } | |
| 952 read_lisp_symbol (infile, buffer); | |
| 24 | 953 c = getc (infile); |
| 753 | 954 if (c != ')') |
| 955 { | |
| 956 fprintf (stderr, | |
| 957 "## unparsable quoted name in fset in %s\n", | |
| 958 filename); | |
| 959 continue; | |
| 960 } | |
| 24 | 961 } |
| 164 | 962 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
963 if (saved_string == 0) |
| 24 | 964 { |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
965 /* Skip to end of line; remember the two previous chars. */ |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
966 while (c != '\n' && c != '\r' && c >= 0) |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
967 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
968 c2 = c1; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
969 c1 = c; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
970 c = getc (infile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
971 } |
| 753 | 972 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
973 /* If two previous characters were " and \, |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
974 this is a doc string. Otherwise, there is none. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
975 if (c2 != '"' || c1 != '\\') |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
976 { |
| 753 | 977 #ifdef DEBUG |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
978 fprintf (stderr, "## non-docstring in %s (%s)\n", |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
979 buffer, filename); |
| 753 | 980 #endif |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
981 continue; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
982 } |
| 24 | 983 } |
| 984 } | |
| 753 | 985 |
| 986 else if (! strcmp (buffer, "autoload")) | |
| 164 | 987 { |
| 753 | 988 type = 'F'; |
| 164 | 989 c = getc (infile); |
| 753 | 990 if (c == '\'') |
| 991 read_lisp_symbol (infile, buffer); | |
| 992 else | |
| 993 { | |
| 994 if (c != '(') | |
| 995 { | |
| 996 fprintf (stderr, "## unparsable name in autoload in %s\n", | |
| 997 filename); | |
| 998 continue; | |
| 999 } | |
| 1000 read_lisp_symbol (infile, buffer); | |
| 1001 if (strcmp (buffer, "quote")) | |
| 1002 { | |
| 1003 fprintf (stderr, "## unparsable name in autoload in %s\n", | |
| 1004 filename); | |
| 1005 continue; | |
| 1006 } | |
| 1007 read_lisp_symbol (infile, buffer); | |
| 1008 c = getc (infile); | |
| 1009 if (c != ')') | |
| 1010 { | |
| 1011 fprintf (stderr, | |
| 1012 "## unparsable quoted name in autoload in %s\n", | |
| 1013 filename); | |
| 1014 continue; | |
| 1015 } | |
| 1016 } | |
| 1017 skip_white (infile); | |
| 1018 if ((c = getc (infile)) != '\"') | |
| 1019 { | |
| 1020 fprintf (stderr, "## autoload of %s unparsable (%s)\n", | |
| 1021 buffer, filename); | |
| 1022 continue; | |
| 1023 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
1024 read_c_string_or_comment (infile, 0, 0); |
| 753 | 1025 skip_white (infile); |
| 164 | 1026 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1027 if (saved_string == 0) |
| 753 | 1028 { |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1029 /* If the next three characters aren't `dquote bslash newline' |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1030 then we're not reading a docstring. */ |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
1031 if ((c = getc (infile)) != '"' |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
1032 || (c = getc (infile)) != '\\' |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
1033 || ((c = getc (infile)) != '\n' && c != '\r')) |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1034 { |
| 753 | 1035 #ifdef DEBUG |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1036 fprintf (stderr, "## non-docstring in %s (%s)\n", |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1037 buffer, filename); |
| 753 | 1038 #endif |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1039 continue; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1040 } |
| 753 | 1041 } |
| 164 | 1042 } |
| 24 | 1043 |
| 753 | 1044 #ifdef DEBUG |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
1045 else if (! strcmp (buffer, "if") |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
1046 || ! strcmp (buffer, "byte-code")) |
| 753 | 1047 ; |
| 1048 #endif | |
| 24 | 1049 |
| 753 | 1050 else |
| 1051 { | |
| 1052 #ifdef DEBUG | |
| 1053 fprintf (stderr, "## unrecognised top-level form, %s (%s)\n", | |
| 1054 buffer, filename); | |
| 1055 #endif | |
| 1056 continue; | |
| 1057 } | |
| 24 | 1058 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1059 /* At this point, we should either use the previous |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1060 dynamic doc string in saved_string |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1061 or gobble a doc string from the input file. |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1062 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1063 In the latter case, the opening quote (and leading |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1064 backslash-newline) have already been read. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1065 |
| 24 | 1066 putc (037, outfile); |
| 753 | 1067 putc (type, outfile); |
| 1068 fprintf (outfile, "%s\n", buffer); | |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1069 if (saved_string) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1070 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1071 fputs (saved_string, outfile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1072 /* Don't use one dynamic doc string twice. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1073 free (saved_string); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1074 saved_string = 0; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1075 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1076 else |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
1077 read_c_string_or_comment (infile, 1, 0); |
| 24 | 1078 } |
| 1079 fclose (infile); | |
| 1080 return 0; | |
| 1081 } |
