Mercurial > emacs
annotate lib-src/make-docfile.c @ 39897:3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
read_c_string. Add parameter COMMENT. Read C-style comments.
(scan_c_file): Handle doc strings in C comments.
| author | Gerd Moellmann <gerd@gnu.org> |
|---|---|
| date | Sat, 13 Oct 2001 20:41:25 +0000 |
| parents | 39b2af5f7ee2 |
| children | f169b10c8e00 |
| 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 | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
201 /* 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
|
202 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
|
203 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
|
204 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
|
205 \t to newline and tab; discard \ followed by newline. */ |
| 24 | 206 |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
207 int |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
208 read_c_string_or_comment (infile, printflag, comment) |
| 24 | 209 FILE *infile; |
| 210 int printflag; | |
| 211 { | |
| 212 register int c; | |
| 213 char *p = buf; | |
| 214 | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
215 if (comment) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
216 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
217 while ((c = getc (infile)) != EOF |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
218 && (c == '\n' || c == '\r' || c == '\t' || c == ' ')) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
219 ; |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
220 } |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
221 else |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
222 c = getc (infile); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
223 |
| 24 | 224 while (c != EOF) |
| 225 { | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
226 while (c != EOF && (comment ? c != '*' : c != '"')) |
| 24 | 227 { |
| 228 if (c == '\\') | |
| 229 { | |
| 230 c = getc (infile); | |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
231 if (c == '\n' || c == '\r') |
| 24 | 232 { |
| 233 c = getc (infile); | |
| 234 continue; | |
| 235 } | |
| 236 if (c == 'n') | |
| 237 c = '\n'; | |
| 238 if (c == 't') | |
| 239 c = '\t'; | |
| 240 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
241 |
| 24 | 242 if (printflag > 0) |
| 243 putc (c, outfile); | |
| 244 else if (printflag < 0) | |
| 245 *p++ = c; | |
| 246 c = getc (infile); | |
| 247 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
248 |
| 24 | 249 c = getc (infile); |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
250 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
251 if (comment) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
252 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
253 if (c == '/') |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
254 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
255 c = getc (infile); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
256 break; |
|
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 } |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
259 else |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
260 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
261 if (c != '"') |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
262 break; |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
263 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
264 /* 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
|
265 c = getc (infile); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
266 } |
| 24 | 267 } |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
268 |
| 24 | 269 if (printflag < 0) |
| 270 *p = 0; | |
| 271 | |
| 272 return c; | |
| 273 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
274 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
275 |
| 24 | 276 |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
277 /* Write to file OUT the argument names of function FUNC, whose text is in BUF. |
| 24 | 278 MINARGS and MAXARGS are the minimum and maximum number of arguments. */ |
| 279 | |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
280 void |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
281 write_c_args (out, func, buf, minargs, maxargs) |
| 24 | 282 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
|
283 char *func, *buf; |
| 24 | 284 int minargs, maxargs; |
| 285 { | |
| 1206 | 286 register char *p; |
| 1250 | 287 int in_ident = 0; |
| 288 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
|
289 int need_space = 1; |
| 24 | 290 |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
291 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
|
292 |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
293 if (*buf == '(') |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
294 ++buf; |
| 24 | 295 |
| 1206 | 296 for (p = buf; *p; p++) |
| 24 | 297 { |
| 1250 | 298 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
|
299 int ident_start = 0; |
| 1250 | 300 |
| 301 /* Notice when we start printing a new identifier. */ | |
| 302 if ((('A' <= c && c <= 'Z') | |
| 303 || ('a' <= c && c <= 'z') | |
| 304 || ('0' <= c && c <= '9') | |
| 305 || c == '_') | |
| 306 != in_ident) | |
| 24 | 307 { |
| 1250 | 308 if (!in_ident) |
| 309 { | |
| 310 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
|
311 ident_start = 1; |
| 1206 | 312 |
|
5604
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
313 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
|
314 putc (' ', out); |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
315 |
| 1250 | 316 if (minargs == 0 && maxargs > 0) |
| 317 fprintf (out, "&optional "); | |
| 318 just_spaced = 1; | |
| 1206 | 319 |
| 1250 | 320 minargs--; |
| 321 maxargs--; | |
| 322 } | |
| 323 else | |
| 324 in_ident = 0; | |
| 24 | 325 } |
| 638 | 326 |
| 1250 | 327 /* 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
|
328 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
|
329 as spaces. Collapse adjacent spaces into one. */ |
|
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
330 if (c == '_') |
|
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
331 c = '-'; |
|
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
332 else if (c == ',' || c == '\n') |
|
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
333 c = ' '; |
| 1250 | 334 |
|
2483
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
335 /* 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
|
336 `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
|
337 if (ident_start |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
338 && 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
|
339 && ! (('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
|
340 || ('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
|
341 || ('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
|
342 || p[6] == '_')) |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
343 { |
|
7564
d5d803ffff27
(write_c_args): Put `default' in upper case.
Richard M. Stallman <rms@gnu.org>
parents:
5604
diff
changeset
|
344 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
|
345 p += 5; |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
346 in_ident = 0; |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
347 just_spaced = 0; |
|
b4145a12422d
* make-docfile.c (write_c_args): Print an argument named "defalt"
Jim Blandy <jimb@redhat.com>
parents:
1676
diff
changeset
|
348 } |
|
35293
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
349 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
|
350 { |
|
32ac07bd58ef
Make the argument list output look more like the Lisp docstrings do.
Roland McGrath <roland@gnu.org>
parents:
5449
diff
changeset
|
351 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
|
352 /* 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
|
353 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
|
354 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
|
355 } |
| 1250 | 356 |
|
35293
39b2af5f7ee2
(write_c_args): Print newlines as spaces.
Gerd Moellmann <gerd@gnu.org>
parents:
28401
diff
changeset
|
357 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
|
358 need_space = 0; |
| 24 | 359 } |
| 360 } | |
| 361 | |
| 362 /* Read through a c file. If a .o file is named, | |
| 363 the corresponding .c file is read instead. | |
| 364 Looks for DEFUN constructs such as are defined in ../src/lisp.h. | |
| 365 Accepts any word starting DEF... so it finds DEFSIMPLE and DEFPRED. */ | |
| 366 | |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
367 int |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
368 scan_c_file (filename, mode) |
|
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
369 char *filename, *mode; |
| 24 | 370 { |
| 371 FILE *infile; | |
| 372 register int c; | |
| 373 register int commas; | |
| 374 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
|
375 register int defvarperbufferflag; |
| 24 | 376 register int defvarflag; |
| 377 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
|
378 int extension = filename[strlen (filename) - 1]; |
| 24 | 379 |
|
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
|
380 if (extension == 'o') |
| 24 | 381 filename[strlen (filename) - 1] = 'c'; |
| 382 | |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
383 infile = fopen (filename, mode); |
| 24 | 384 |
| 385 /* No error if non-ex input file */ | |
| 386 if (infile == NULL) | |
| 387 { | |
| 388 perror (filename); | |
| 389 return 0; | |
| 390 } | |
| 391 | |
|
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
|
392 /* 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
|
393 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
|
394 |
| 24 | 395 c = '\n'; |
| 396 while (!feof (infile)) | |
| 397 { | |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
398 if (c != '\n' && c != '\r') |
| 24 | 399 { |
| 400 c = getc (infile); | |
| 401 continue; | |
| 402 } | |
| 403 c = getc (infile); | |
| 404 if (c == ' ') | |
| 405 { | |
| 406 while (c == ' ') | |
| 407 c = getc (infile); | |
| 408 if (c != 'D') | |
| 409 continue; | |
| 410 c = getc (infile); | |
| 411 if (c != 'E') | |
| 412 continue; | |
| 413 c = getc (infile); | |
| 414 if (c != 'F') | |
| 415 continue; | |
| 416 c = getc (infile); | |
| 417 if (c != 'V') | |
| 418 continue; | |
|
1676
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
419 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
|
420 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
|
421 continue; |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
422 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
|
423 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
|
424 continue; |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
425 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
|
426 if (c != '_') |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
427 continue; |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
428 |
| 24 | 429 defvarflag = 1; |
| 430 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
|
431 |
|
e8b3c6b52c1e
* make-docfile.c (scan_c_file): Since DEFVAR_PER_BUFFER now takes
Jim Blandy <jimb@redhat.com>
parents:
1250
diff
changeset
|
432 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
|
433 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
|
434 |
| 24 | 435 c = getc (infile); |
| 436 } | |
| 437 else if (c == 'D') | |
| 438 { | |
| 439 c = getc (infile); | |
| 440 if (c != 'E') | |
| 441 continue; | |
| 442 c = getc (infile); | |
| 443 if (c != 'F') | |
| 444 continue; | |
| 445 c = getc (infile); | |
| 446 defunflag = c == 'U'; | |
| 447 defvarflag = 0; | |
| 448 } | |
| 449 else continue; | |
| 450 | |
| 451 while (c != '(') | |
| 452 { | |
| 453 if (c < 0) | |
| 454 goto eof; | |
| 455 c = getc (infile); | |
| 456 } | |
| 457 | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
458 /* Lisp variable or function name. */ |
| 24 | 459 c = getc (infile); |
| 460 if (c != '"') | |
| 461 continue; | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
462 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
|
463 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
464 /* DEFVAR_LISP ("name", addr /\* doc *\/) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
465 DEFVAR_LISP ("name", addr, doc) */ |
| 24 | 466 |
| 467 if (defunflag) | |
| 468 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
|
469 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
|
470 commas = 2; |
| 24 | 471 else if (defvarflag) |
| 472 commas = 1; | |
| 473 else /* For DEFSIMPLE and DEFPRED */ | |
| 474 commas = 2; | |
| 475 | |
| 476 while (commas) | |
| 477 { | |
| 478 if (c == ',') | |
| 479 { | |
| 480 commas--; | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
481 |
| 24 | 482 if (defunflag && (commas == 1 || commas == 2)) |
| 483 { | |
| 484 do | |
| 485 c = getc (infile); | |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
486 while (c == ' ' || c == '\n' || c == '\r' || c == '\t'); |
| 24 | 487 if (c < 0) |
| 488 goto eof; | |
| 489 ungetc (c, infile); | |
| 490 if (commas == 2) /* pick up minargs */ | |
| 491 fscanf (infile, "%d", &minargs); | |
| 492 else /* pick up maxargs */ | |
| 493 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ | |
| 494 maxargs = -1; | |
| 495 else | |
| 496 fscanf (infile, "%d", &maxargs); | |
| 497 } | |
| 498 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
499 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
500 if (c == EOF) |
| 24 | 501 goto eof; |
| 502 c = getc (infile); | |
| 503 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
504 |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
505 while (c == ' ' || c == '\n' || c == '\r' || c == '\t') |
| 24 | 506 c = getc (infile); |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
507 |
| 24 | 508 if (c == '"') |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
509 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
|
510 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
511 while (c != EOF && c != ',' && c != '/') |
| 24 | 512 c = getc (infile); |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
513 if (c == ',') |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
514 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
515 c = getc (infile); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
516 while (c == ' ' || c == '\n' || c == '\r' || c == '\t') |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
517 c = getc (infile); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
518 } |
| 24 | 519 |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
520 if (c == '"' |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
521 || (c == '/' |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
522 && (c = getc (infile), |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
523 ungetc (c, infile), |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
524 c == '*'))) |
| 24 | 525 { |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
526 int comment = c != '"'; |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
527 |
| 24 | 528 putc (037, outfile); |
| 529 putc (defvarflag ? 'V' : 'F', outfile); | |
| 530 fprintf (outfile, "%s\n", buf); | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
531 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
532 if (comment) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
533 getc (infile); /* Skip past `*' */ |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
534 c = read_c_string_or_comment (infile, 1, comment); |
| 168 | 535 |
| 536 /* If this is a defun, find the arguments and print them. If | |
| 537 this function takes MANY or UNEVALLED args, then the C source | |
| 538 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
|
539 trying to find them. |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
540 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
541 Old: DEFUN (..., "DOC") (args) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
542 New: DEFUN (..., /\* DOC *\/ (args)) */ |
| 168 | 543 if (defunflag && maxargs != -1) |
| 24 | 544 { |
| 545 char argbuf[1024], *p = argbuf; | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
546 |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
547 if (!comment) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
548 while (c != ')') |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
549 { |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
550 if (c < 0) |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
551 goto eof; |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
552 c = getc (infile); |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
553 } |
|
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
554 |
| 24 | 555 /* Skip into arguments. */ |
| 556 while (c != '(') | |
| 557 { | |
| 558 if (c < 0) | |
| 559 goto eof; | |
| 560 c = getc (infile); | |
| 561 } | |
| 562 /* Copy arguments into ARGBUF. */ | |
| 563 *p++ = c; | |
| 564 do | |
| 565 *p++ = c = getc (infile); | |
| 566 while (c != ')'); | |
| 567 *p = '\0'; | |
| 568 /* Output them. */ | |
| 569 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
|
570 write_c_args (outfile, buf, argbuf, minargs, maxargs); |
| 24 | 571 } |
| 572 } | |
| 573 } | |
| 574 eof: | |
| 575 fclose (infile); | |
| 576 return 0; | |
| 577 } | |
| 578 | |
| 579 /* Read a file of Lisp code, compiled or interpreted. | |
| 580 Looks for | |
| 581 (defun NAME ARGS DOCSTRING ...) | |
| 753 | 582 (defmacro NAME ARGS DOCSTRING ...) |
|
28401
65f19ae2c578
(scan_lisp_file): Also look for `defsubst'.
Andreas Schwab <schwab@suse.de>
parents:
26083
diff
changeset
|
583 (defsubst NAME ARGS DOCSTRING ...) |
| 753 | 584 (autoload (quote NAME) FILE DOCSTRING ...) |
| 24 | 585 (defvar NAME VALUE DOCSTRING) |
| 586 (defconst NAME VALUE DOCSTRING) | |
| 753 | 587 (fset (quote NAME) (make-byte-code ... DOCSTRING ...)) |
| 588 (fset (quote NAME) #[... DOCSTRING ...]) | |
|
2966
e936d56c2354
(scan_lisp_file): Recognize defalias like fset.
Richard M. Stallman <rms@gnu.org>
parents:
2814
diff
changeset
|
589 (defalias (quote NAME) #[... DOCSTRING ...]) |
|
19636
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
590 (custom-declare-variable (quote NAME) VALUE DOCSTRING ...) |
| 24 | 591 starting in column zero. |
| 753 | 592 (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
|
593 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
594 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
|
595 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
|
596 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
|
597 |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3028
diff
changeset
|
598 For defvar, defconst, and fset we skip to the docstring with a kludgy |
| 753 | 599 formatting convention: all docstrings must appear on the same line as the |
| 600 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
|
601 and a newline immediately after the initial double-quote. No newlines |
| 753 | 602 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
|
603 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
|
604 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
|
605 immediately after the double quote. |
|
2cfdaebe325c
Fix comment about conventions for Lisp files.
Dave Love <fx@gnu.org>
parents:
25532
diff
changeset
|
606 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
|
607 uncompiled ones like loaddefs.el and bindings.el; aside |
| 753 | 608 from that, it is always the .elc file that we look at, and they are no |
| 609 problem because byte-compiler output follows this convention. | |
| 24 | 610 The NAME and DOCSTRING are output. |
| 611 NAME is preceded by `F' for a function or `V' for a variable. | |
| 612 An entry is output only if DOCSTRING has \ newline just after the opening " | |
| 613 */ | |
| 614 | |
| 753 | 615 void |
| 616 skip_white (infile) | |
| 617 FILE *infile; | |
| 618 { | |
| 619 char c = ' '; | |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
620 while (c == ' ' || c == '\t' || c == '\n' || c == '\r') |
| 753 | 621 c = getc (infile); |
| 622 ungetc (c, infile); | |
| 623 } | |
| 624 | |
| 625 void | |
| 626 read_lisp_symbol (infile, buffer) | |
| 627 FILE *infile; | |
| 628 char *buffer; | |
| 629 { | |
| 630 char c; | |
| 631 char *fillp = buffer; | |
| 632 | |
| 633 skip_white (infile); | |
| 634 while (1) | |
| 635 { | |
| 636 c = getc (infile); | |
| 637 if (c == '\\') | |
| 638 *(++fillp) = getc (infile); | |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
639 else if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '(' || c == ')') |
| 753 | 640 { |
| 641 ungetc (c, infile); | |
| 642 *fillp = 0; | |
| 643 break; | |
| 644 } | |
| 645 else | |
| 646 *fillp++ = c; | |
| 647 } | |
| 648 | |
| 649 if (! buffer[0]) | |
| 650 fprintf (stderr, "## expected a symbol, got '%c'\n", c); | |
| 651 | |
| 652 skip_white (infile); | |
| 653 } | |
| 654 | |
|
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
7564
diff
changeset
|
655 int |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
656 scan_lisp_file (filename, mode) |
|
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
657 char *filename, *mode; |
| 24 | 658 { |
| 659 FILE *infile; | |
| 660 register int c; | |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
661 char *saved_string = 0; |
| 24 | 662 |
|
5449
296db649863d
[MSDOS]: Use text/binary mode as appropriate.
Richard M. Stallman <rms@gnu.org>
parents:
5317
diff
changeset
|
663 infile = fopen (filename, mode); |
| 24 | 664 if (infile == NULL) |
| 665 { | |
| 666 perror (filename); | |
| 667 return 0; /* No error */ | |
| 668 } | |
| 669 | |
| 670 c = '\n'; | |
| 671 while (!feof (infile)) | |
| 672 { | |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
673 char buffer[BUFSIZ]; |
| 753 | 674 char type; |
| 675 | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
676 /* 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
|
677 if (c != '\n' && c != '\r') |
| 24 | 678 { |
| 679 c = getc (infile); | |
| 680 continue; | |
| 681 } | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
682 /* Skip the line break. */ |
|
25821
9a999c51f856
(scan_lisp_file): Fix typo causing infloop.
Dave Love <fx@gnu.org>
parents:
25809
diff
changeset
|
683 while (c == '\n' || c == '\r') |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
684 c = getc (infile); |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
685 /* 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
|
686 if (c == '#') |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
687 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
688 c = getc (infile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
689 if (c == '@') |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
690 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
691 int length = 0; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
692 int i; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
693 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
694 /* Read the length. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
695 while ((c = getc (infile), |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
696 c >= '0' && c <= '9')) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
697 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
698 length *= 10; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
699 length += c - '0'; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
700 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
701 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
702 /* 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
|
703 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
|
704 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
|
705 length--; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
706 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
707 /* Read in the contents. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
708 if (saved_string != 0) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
709 free (saved_string); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
710 saved_string = (char *) malloc (length); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
711 for (i = 0; i < length; i++) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
712 saved_string[i] = getc (infile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
713 /* The last character is a ^_. |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
714 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
|
715 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
|
716 saved_string[length - 1] = 0; |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
717 /* Skip the line break. */ |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
718 while (c == '\n' && c == '\r') |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
719 c = getc (infile); |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
720 /* Skip the following line. */ |
|
25532
9ed9cbc425fe
Include config.h not ../src/config.h.
Richard M. Stallman <rms@gnu.org>
parents:
25449
diff
changeset
|
721 while (c != '\n' && c != '\r') |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
722 c = getc (infile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
723 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
724 continue; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
725 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
726 |
| 24 | 727 if (c != '(') |
| 728 continue; | |
| 164 | 729 |
| 753 | 730 read_lisp_symbol (infile, buffer); |
| 731 | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
732 if (! strcmp (buffer, "defun") |
|
28401
65f19ae2c578
(scan_lisp_file): Also look for `defsubst'.
Andreas Schwab <schwab@suse.de>
parents:
26083
diff
changeset
|
733 || ! strcmp (buffer, "defmacro") |
|
65f19ae2c578
(scan_lisp_file): Also look for `defsubst'.
Andreas Schwab <schwab@suse.de>
parents:
26083
diff
changeset
|
734 || ! strcmp (buffer, "defsubst")) |
| 24 | 735 { |
| 753 | 736 type = 'F'; |
| 737 read_lisp_symbol (infile, buffer); | |
| 738 | |
| 739 /* Skip the arguments: either "nil" or a list in parens */ | |
| 24 | 740 |
| 741 c = getc (infile); | |
| 753 | 742 if (c == 'n') /* nil */ |
| 743 { | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
744 if ((c = getc (infile)) != 'i' |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
745 || (c = getc (infile)) != 'l') |
| 753 | 746 { |
| 747 fprintf (stderr, "## unparsable arglist in %s (%s)\n", | |
| 748 buffer, filename); | |
| 749 continue; | |
| 750 } | |
| 751 } | |
| 752 else if (c != '(') | |
| 753 { | |
| 754 fprintf (stderr, "## unparsable arglist in %s (%s)\n", | |
| 755 buffer, filename); | |
| 756 continue; | |
| 757 } | |
| 758 else | |
| 759 while (c != ')') | |
| 760 c = getc (infile); | |
| 761 skip_white (infile); | |
| 24 | 762 |
| 753 | 763 /* If the next three characters aren't `dquote bslash newline' |
| 764 then we're not reading a docstring. | |
| 765 */ | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
766 if ((c = getc (infile)) != '"' |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
767 || (c = getc (infile)) != '\\' |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
768 || ((c = getc (infile)) != '\n' && c != '\r')) |
| 24 | 769 { |
| 753 | 770 #ifdef DEBUG |
| 771 fprintf (stderr, "## non-docstring in %s (%s)\n", | |
| 772 buffer, filename); | |
| 773 #endif | |
| 774 continue; | |
| 775 } | |
| 776 } | |
| 777 | |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
778 else if (! strcmp (buffer, "defvar") |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
779 || ! strcmp (buffer, "defconst")) |
| 753 | 780 { |
| 781 char c1 = 0, c2 = 0; | |
| 782 type = 'V'; | |
| 783 read_lisp_symbol (infile, buffer); | |
| 784 | |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
785 if (saved_string == 0) |
| 753 | 786 { |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
787 |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
788 /* 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
|
789 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
|
790 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
791 c2 = c1; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
792 c1 = c; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
793 c = getc (infile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
794 } |
| 753 | 795 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
796 /* If two previous characters were " and \, |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
797 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
|
798 if (c2 != '"' || c1 != '\\') |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
799 { |
| 753 | 800 #ifdef DEBUG |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
801 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
|
802 buffer, filename); |
| 753 | 803 #endif |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
804 continue; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
805 } |
| 753 | 806 } |
| 807 } | |
| 808 | |
|
19636
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
809 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
|
810 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
811 char c1 = 0, c2 = 0; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
812 type = 'V'; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
813 |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
814 c = getc (infile); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
815 if (c == '\'') |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
816 read_lisp_symbol (infile, buffer); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
817 else |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
818 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
819 if (c != '(') |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
820 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
821 fprintf (stderr, |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
822 "## 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
|
823 filename); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
824 continue; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
825 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
826 read_lisp_symbol (infile, buffer); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
827 if (strcmp (buffer, "quote")) |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
828 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
829 fprintf (stderr, |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
830 "## 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
|
831 filename); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
832 continue; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
833 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
834 read_lisp_symbol (infile, buffer); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
835 c = getc (infile); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
836 if (c != ')') |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
837 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
838 fprintf (stderr, |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
839 "## 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
|
840 filename); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
841 continue; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
842 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
843 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
844 |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
845 if (saved_string == 0) |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
846 { |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
847 /* 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
|
848 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
|
849 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
850 c2 = c1; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
851 c1 = c; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
852 c = getc (infile); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
853 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
854 |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
855 /* If two previous characters were " and \, |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
856 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
|
857 if (c2 != '"' || c1 != '\\') |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
858 { |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
859 #ifdef DEBUG |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
860 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
|
861 buffer, filename); |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
862 #endif |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
863 continue; |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
864 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
865 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
866 } |
|
77fa90ed939d
(scan_lisp_file): Handle custom-declare-variable.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
867 |
|
2966
e936d56c2354
(scan_lisp_file): Recognize defalias like fset.
Richard M. Stallman <rms@gnu.org>
parents:
2814
diff
changeset
|
868 else if (! strcmp (buffer, "fset") || ! strcmp (buffer, "defalias")) |
| 753 | 869 { |
| 870 char c1 = 0, c2 = 0; | |
| 871 type = 'F'; | |
| 872 | |
| 873 c = getc (infile); | |
| 874 if (c == '\'') | |
| 875 read_lisp_symbol (infile, buffer); | |
| 24 | 876 else |
| 877 { | |
| 878 if (c != '(') | |
| 753 | 879 { |
| 880 fprintf (stderr, "## unparsable name in fset in %s\n", | |
| 881 filename); | |
| 882 continue; | |
| 883 } | |
| 884 read_lisp_symbol (infile, buffer); | |
| 885 if (strcmp (buffer, "quote")) | |
| 886 { | |
| 887 fprintf (stderr, "## unparsable name in fset in %s\n", | |
| 888 filename); | |
| 889 continue; | |
| 890 } | |
| 891 read_lisp_symbol (infile, buffer); | |
| 24 | 892 c = getc (infile); |
| 753 | 893 if (c != ')') |
| 894 { | |
| 895 fprintf (stderr, | |
| 896 "## unparsable quoted name in fset in %s\n", | |
| 897 filename); | |
| 898 continue; | |
| 899 } | |
| 24 | 900 } |
| 164 | 901 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
902 if (saved_string == 0) |
| 24 | 903 { |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
904 /* 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
|
905 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
|
906 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
907 c2 = c1; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
908 c1 = c; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
909 c = getc (infile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
910 } |
| 753 | 911 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
912 /* If two previous characters were " and \, |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
913 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
|
914 if (c2 != '"' || c1 != '\\') |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
915 { |
| 753 | 916 #ifdef DEBUG |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
917 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
|
918 buffer, filename); |
| 753 | 919 #endif |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
920 continue; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
921 } |
| 24 | 922 } |
| 923 } | |
| 753 | 924 |
| 925 else if (! strcmp (buffer, "autoload")) | |
| 164 | 926 { |
| 753 | 927 type = 'F'; |
| 164 | 928 c = getc (infile); |
| 753 | 929 if (c == '\'') |
| 930 read_lisp_symbol (infile, buffer); | |
| 931 else | |
| 932 { | |
| 933 if (c != '(') | |
| 934 { | |
| 935 fprintf (stderr, "## unparsable name in autoload in %s\n", | |
| 936 filename); | |
| 937 continue; | |
| 938 } | |
| 939 read_lisp_symbol (infile, buffer); | |
| 940 if (strcmp (buffer, "quote")) | |
| 941 { | |
| 942 fprintf (stderr, "## unparsable name in autoload in %s\n", | |
| 943 filename); | |
| 944 continue; | |
| 945 } | |
| 946 read_lisp_symbol (infile, buffer); | |
| 947 c = getc (infile); | |
| 948 if (c != ')') | |
| 949 { | |
| 950 fprintf (stderr, | |
| 951 "## unparsable quoted name in autoload in %s\n", | |
| 952 filename); | |
| 953 continue; | |
| 954 } | |
| 955 } | |
| 956 skip_white (infile); | |
| 957 if ((c = getc (infile)) != '\"') | |
| 958 { | |
| 959 fprintf (stderr, "## autoload of %s unparsable (%s)\n", | |
| 960 buffer, filename); | |
| 961 continue; | |
| 962 } | |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
963 read_c_string_or_comment (infile, 0, 0); |
| 753 | 964 skip_white (infile); |
| 164 | 965 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
966 if (saved_string == 0) |
| 753 | 967 { |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
968 /* 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
|
969 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
|
970 if ((c = getc (infile)) != '"' |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
971 || (c = getc (infile)) != '\\' |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
972 || ((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
|
973 { |
| 753 | 974 #ifdef DEBUG |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
975 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
|
976 buffer, filename); |
| 753 | 977 #endif |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
978 continue; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
979 } |
| 753 | 980 } |
| 164 | 981 } |
| 24 | 982 |
| 753 | 983 #ifdef DEBUG |
|
25809
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
984 else if (! strcmp (buffer, "if") |
|
89230444d638
patched by pjr from diff by rms
Phillip Rulon <pjr@gnu.org>
parents:
25536
diff
changeset
|
985 || ! strcmp (buffer, "byte-code")) |
| 753 | 986 ; |
| 987 #endif | |
| 24 | 988 |
| 753 | 989 else |
| 990 { | |
| 991 #ifdef DEBUG | |
| 992 fprintf (stderr, "## unrecognised top-level form, %s (%s)\n", | |
| 993 buffer, filename); | |
| 994 #endif | |
| 995 continue; | |
| 996 } | |
| 24 | 997 |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
998 /* 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
|
999 dynamic doc string in saved_string |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1000 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
|
1001 |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1002 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
|
1003 backslash-newline) have already been read. */ |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1004 |
| 24 | 1005 putc (037, outfile); |
| 753 | 1006 putc (type, outfile); |
| 1007 fprintf (outfile, "%s\n", buffer); | |
|
10199
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1008 if (saved_string) |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1009 { |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1010 fputs (saved_string, outfile); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1011 /* 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
|
1012 free (saved_string); |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1013 saved_string = 0; |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1014 } |
|
3e2571e22b61
(scan_lisp_file): Handle dynamic doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
9772
diff
changeset
|
1015 else |
|
39897
3e6f2f2a0a62
(read_c_string_or_comment): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35293
diff
changeset
|
1016 read_c_string_or_comment (infile, 1, 0); |
| 24 | 1017 } |
| 1018 fclose (infile); | |
| 1019 return 0; | |
| 1020 } |
