annotate src/doc.c @ 210:49f55ca3ba57

Added tag r20-4b3 for changeset 41ff10fd062f
author cvs
date Mon, 13 Aug 2007 10:05:01 +0200
parents 41ff10fd062f
children 78478c60bfcd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Record indices of function doc strings stored in a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: FSF 19.30. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* This file has been Mule-ized except as noted. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include "bytecode.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "insdel.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "keymap.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "sysfile.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 Lisp_Object Vdoc_file_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 /* Read and return doc string from open file descriptor FD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 at position POSITION. Does not close the file. Returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 string; or if error, returns a cons holding the error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 data to pass to Fsignal. NAME_NONRELOC and NAME_RELOC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 are only used for the error messages. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 unparesseuxify_doc_string (int fd, EMACS_INT position,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 char *name_nonreloc, Lisp_Object name_reloc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 char buf[512 * 32 + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 char *buffer = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 int buffer_size = sizeof (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 char *from, *to;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 REGISTER char *p = buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 Lisp_Object return_me;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 if (0 > lseek (fd, position, 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 if (name_nonreloc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 name_reloc = build_string (name_nonreloc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 return_me = list3 (build_string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ("Position out of range in doc string file"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 name_reloc, make_int (position));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 goto done;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 /* Read the doc string into a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 Use the fixed buffer BUF if it is big enough; otherwise allocate one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 We store the buffer in use in BUFFER and its size in BUFFER_SIZE. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 int space_left = buffer_size - (p - buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 int nread;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 /* Switch to a bigger buffer if we need one. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 if (space_left == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 char * old_buffer = buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 if (buffer == buf) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 buffer = (char *) xmalloc (buffer_size *= 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 memcpy (buffer, old_buffer, p - old_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 } else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 buffer = (char *) xrealloc (buffer, buffer_size *= 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 p += buffer - old_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 space_left = buffer_size - (p - buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
89 /* Don't read too much at one go. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 if (space_left > 1024 * 8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 space_left = 1024 * 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 nread = read (fd, p, space_left);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 if (nread < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
95 return_me = list1 (build_string
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ("Read error on documentation file"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 goto done;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 p[nread] = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 if (!nread)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 char *p1 = strchr (p, '\037'); /* End of doc string marker */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 if (p1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 *p1 = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 p = p1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 p += nread;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 /* Scan the text and remove quoting with ^A (char code 1).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 from = to = buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 while (from < p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 if (*from != 1 /*^A*/)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 *to++ = *from++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 int c = *(++from);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
124
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 from++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 case 1: *to++ = c; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 case '0': *to++ = '\0'; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 case '_': *to++ = '\037'; break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 return_me = list2 (build_string
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
133 ("Invalid data in documentation file -- ^A followed by weird code"),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 make_int (c));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 goto done;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 /* #### mrb: following STILL completely broken */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 return_me = make_ext_string ((Bufbyte *) buffer, to - buffer, FORMAT_BINARY);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 done:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 if (buffer != buf) /* We must have allocated buffer above */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 xfree (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 return return_me;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
149 #define string_join(dest, s1, s2) \
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
150 memcpy ((void *) dest, (void *) XSTRING_DATA (s1), XSTRING_LENGTH (s1)); \
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
151 memcpy ((void *) ((Bufbyte *) dest + XSTRING_LENGTH (s1)), \
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
152 (void *) XSTRING_DATA (s2), XSTRING_LENGTH (s2)); \
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
153 dest[XSTRING_LENGTH (s1) + XSTRING_LENGTH (s2)] = '\0'
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
154
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 /* Extract a doc string from a file. FILEPOS says where to get it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (This could actually be byte code instructions/constants instead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 of a doc string.)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
158 If it is an integer, use that position in the standard DOC file.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 If it is (FILE . INTEGER), use FILE as the file name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 and INTEGER as the position in that file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 But if INTEGER is negative, make it positive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (A negative integer is used for user variables, so we can distinguish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 them without actually fetching the doc string.) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 get_doc_string (Lisp_Object filepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 REGISTER int fd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 REGISTER char *name_nonreloc = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 int minsize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 EMACS_INT position;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 Lisp_Object file, tem;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 167
diff changeset
174 Lisp_Object name_reloc = Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 if (INTP (filepos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 file = Vdoc_file_name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 position = XINT (filepos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 else if (CONSP (filepos) && INTP (XCDR (filepos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 file = XCAR (filepos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 position = XINT (XCDR (filepos));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 if (position < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 position = - position;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 if (!STRINGP (file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 return Qnil;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
193
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 /* Put the file name in NAME as a C string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 If it is relative, combine it with Vdoc_directory. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 tem = Ffile_name_absolute_p (file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 if (NILP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 /* XEmacs: Move this check here. OK if called during loadup to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 load byte code instructions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 if (!STRINGP (Vdoc_directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
205 minsize = XSTRING_LENGTH (Vdoc_directory);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 /* sizeof ("../lib-src/") == 12 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 if (minsize < 12)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 minsize = 12;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
209 name_nonreloc = (char *) alloca (minsize + XSTRING_LENGTH (file) + 8);
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
210 string_join (name_nonreloc, Vdoc_directory, file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 name_reloc = file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 fd = open (name_nonreloc ? name_nonreloc :
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
216 (char *) XSTRING_DATA (name_reloc), O_RDONLY, 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 if (fd < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 #ifndef CANNOT_DUMP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 if (purify_flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 /* sizeof ("../lib-src/") == 12 */
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
223 name_nonreloc = (char *) alloca (12 + XSTRING_LENGTH (file) + 8);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 /* Preparing to dump; DOC file is probably not installed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 So check in ../lib-src. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 strcpy (name_nonreloc, "../lib-src/");
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
227 strcat (name_nonreloc, (char *) XSTRING_DATA (file));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 fd = open (name_nonreloc, O_RDONLY, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 }
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
231 #endif /* CANNOT_DUMP */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 if (fd < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 error ("Cannot open doc string file \"%s\"",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 name_nonreloc ? name_nonreloc :
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
236 (char *) XSTRING_DATA (name_reloc));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 tem = unparesseuxify_doc_string (fd, position, name_nonreloc, name_reloc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 close (fd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 if (!STRINGP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 signal_error (Qerror, tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 return tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 /* Get a string from position FILEPOS and pass it through the Lisp reader.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 We use this for fetching the bytecode string and constants vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 of a compiled function from the .elc file. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 read_doc_string (Lisp_Object filepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 Lisp_Object string = get_doc_string (filepos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 if (!STRINGP (string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 signal_simple_error ("loading bytecode failed to return string", string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 return Fread (string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
262 DEFUN ("documentation", Fdocumentation, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 Return the documentation string of FUNCTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 Unless a non-nil second argument is given, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 string is passed through `substitute-command-keys'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
266 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
267 (function, raw))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 Lisp_Object fun;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 Lisp_Object doc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 fun = Findirect_function (function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 if (SUBRP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 if (XSUBR (fun)->doc == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 if ((EMACS_INT) XSUBR (fun)->doc >= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 doc = build_string (XSUBR (fun)->doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 doc = get_doc_string (make_int (- (EMACS_INT) XSUBR (fun)->doc));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 else if (COMPILED_FUNCTIONP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 Lisp_Object tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 struct Lisp_Compiled_Function *b = XCOMPILED_FUNCTION (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 if (! (b->flags.documentationp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 tem = compiled_function_documentation (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 if (STRINGP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 doc = tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 else if (NATNUMP (tem) || CONSP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 doc = get_doc_string (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 else if (KEYMAPP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 return build_translated_string ("Prefix command (definition is a keymap of subcommands).");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 else if (STRINGP (fun) || VECTORP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 return build_translated_string ("Keyboard macro.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 else if (CONSP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 Lisp_Object funcar = Fcar (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 if (!SYMBOLP (funcar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 return Fsignal (Qinvalid_function, list1 (fun));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 else if (EQ (funcar, Qlambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 || EQ (funcar, Qautoload))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 Lisp_Object tem, tem1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 tem1 = Fcdr (Fcdr (fun));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 tem = Fcar (tem1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 if (STRINGP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 doc = tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 /* Handle a doc reference--but these never come last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 in the function body, so reject them if they are last. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 else if ((NATNUMP (tem) || CONSP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 && ! NILP (XCDR (tem1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 doc = get_doc_string (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 else if (EQ (funcar, Qmacro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 return Fdocumentation (Fcdr (fun), raw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 goto oops;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 oops:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 return Fsignal (Qinvalid_function, list1 (fun));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 if (NILP (raw))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 Lisp_Object domain = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 if (COMPILED_FUNCTIONP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 domain = Fcompiled_function_domain (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 if (NILP (domain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 doc = Fgettext (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 doc = Fdgettext (domain, doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 GCPRO1 (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 doc = Fsubstitute_command_keys (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 return doc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
355 DEFUN ("documentation-property", Fdocumentation_property, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 Return the documentation string that is SYMBOL's PROP property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 This is like `get', but it can refer to strings stored in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 `doc-directory/DOC' file; and if the value is a string, it is passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 through `substitute-command-keys'. A non-nil third argument avoids this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 translation.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
361 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
362 (sym, prop, raw))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 /* This function can GC */
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 189
diff changeset
365 REGISTER Lisp_Object doc = Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 REGISTER Lisp_Object domain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 #endif
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 189
diff changeset
369 struct gcpro gcpro1;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 189
diff changeset
370
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 189
diff changeset
371 GCPRO1 (doc);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 doc = Fget (sym, prop, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 if (INTP (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 doc = get_doc_string (XINT (doc) > 0 ? doc : make_int (- XINT (doc)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 else if (CONSP (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 doc = get_doc_string (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 if (!NILP (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 domain = Fget (sym, Qvariable_domain, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 if (NILP (domain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 doc = Fgettext (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 doc = Fdgettext (domain, doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
387 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 if (NILP (raw) && STRINGP (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 doc = Fsubstitute_command_keys (doc);
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 189
diff changeset
390 UNGCPRO;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 return doc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 weird_doc (Lisp_Object sym, CONST char *weirdness, CONST char *type, int pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 {
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 80
diff changeset
397 /*#if defined(ENERGIZE) || defined(SUNPRO)*/ /* hide kludgery... */
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 80
diff changeset
398 /* (for everyone) */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 if (!strcmp (weirdness, GETTEXT ("duplicate"))) return;
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 80
diff changeset
400 /*#endif*/
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 message ("Note: Strange doc (%s) for %s %s @ %d",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 weirdness, type, string_data (XSYMBOL (sym)->name), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
406 DEFUN ("Snarf-documentation", Fsnarf_documentation, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 Used during Emacs initialization, before dumping runnable Emacs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 to find pointers to doc strings stored in `.../lib-src/DOC' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 record them in function definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 One arg, FILENAME, a string which does not include a directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 The file is written to `../lib-src', and later found in `exec-directory'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 when doc strings are referred to in the dumped Emacs.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
413 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
414 (filename))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 int fd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 char buf[1024 + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 REGISTER int filled;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 REGISTER int pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 REGISTER char *p, *end;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 Lisp_Object sym, fun, tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 char *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 #ifndef CANNOT_DUMP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 if (!purify_flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 error ("Snarf-documentation can only be called in an undumped Emacs");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 CHECK_STRING (filename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 #ifndef CANNOT_DUMP
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
433 name = (char *) alloca (XSTRING_LENGTH (filename) + 14);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 strcpy (name, "../lib-src/");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 #else /* CANNOT_DUMP */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 CHECK_STRING (Vdoc_directory);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
437 name = (char *) alloca (XSTRING_LENGTH (filename)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
438 + XSTRING_LENGTH (Vdoc_directory)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 + 1);
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
440 strcpy (name, (char *) XSTRING_DATA (Vdoc_directory));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 #endif /* CANNOT_DUMP */
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
442 strcat (name, (char *) XSTRING_DATA (filename));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 fd = open (name, O_RDONLY, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 if (fd < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 report_file_error ("Opening doc string file",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 Fcons (build_string (name), Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 Vdoc_file_name = filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 filled = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 pos = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 if (filled < 512)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 filled += read (fd, &buf[filled], sizeof buf - 1 - filled);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 if (!filled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 buf[filled] = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 p = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 end = buf + (filled < 512 ? filled : filled - 128);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 while (p != end && *p != '\037') p++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 if (p != end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 end = strchr (p, '\n');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 sym = oblookup (Vobarray, (Bufbyte *) p + 2, end - p - 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 if (SYMBOLP (sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 Lisp_Object offset = make_int (pos + end + 1 - buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 /* Attach a docstring to a variable */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 if (p[1] == 'V')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 /* Install file-position as variable-documentation property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 and make it negative for a user-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (doc starts with a `*'). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 Lisp_Object old = Fget (sym, Qvariable_documentation, Qzero);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 if (!ZEROP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 weird_doc (sym, GETTEXT ("duplicate"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 GETTEXT ("variable"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 /* In the case of duplicate doc file entries, always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 take the later one. But if the doc is not an int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (a string, say) leave it alone. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 if (!INTP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 Fput (sym, Qvariable_documentation,
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
488 ((end[1] == '*')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ? make_int (- XINT (offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 : offset));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 /* Attach a docstring to a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 The type determines where the docstring is stored. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 else if (p[1] == 'F')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 {
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 185
diff changeset
496 fun = indirect_function (sym,0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 fun = XCDR (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 if (UNBOUNDP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 /* May have been #if'ed out or something */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 weird_doc (sym, GETTEXT ("not fboundp"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 GETTEXT ("function"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 else if (SUBRP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 /* Lisp_Subrs have a slot for it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 if (XSUBR (fun)->doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 weird_doc (sym, GETTEXT ("duplicate"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 GETTEXT ("subr"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 XSUBR (fun)->doc = (char *) (- XINT (offset));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 else if (CONSP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 /* If it's a lisp form, stick it in the form. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 tem = XCAR (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 if (EQ (tem, Qlambda) || EQ (tem, Qautoload))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 tem = Fcdr (Fcdr (fun));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 if (CONSP (tem) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 INTP (XCAR (tem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 Lisp_Object old = XCAR (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 if (!ZEROP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 weird_doc (sym, GETTEXT ("duplicate"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (EQ (tem, Qlambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 ? GETTEXT ("lambda")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 : GETTEXT ("autoload")),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 /* In the case of duplicate doc file entries,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 always take the later one. But if the doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 is not an int (a string, say) leave it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 alone. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 if (!INTP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 XCAR (tem) = offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
546 else if (!CONSP (tem))
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
547 {
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
548 weird_doc (sym, GETTEXT ("!CONSP(tem)"),
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
549 GETTEXT ("function"), pos);
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
550 goto cont;
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
551 }
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
552 else
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
553 {
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
554 /* DOC string is a string not integer 0 */
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
555 #if 0
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
556 weird_doc (sym, GETTEXT ("!INTP(XCAR(tem))"),
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
557 GETTEXT ("function"), pos);
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
558 #endif
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
559 goto cont;
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
560 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
562 else
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
563 {
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
564 weird_doc (sym, GETTEXT ("not lambda or autoload"),
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
565 GETTEXT ("function"), pos);
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
566 goto cont;
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
567 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 else if (COMPILED_FUNCTIONP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 /* Compiled-Function objects sometimes have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 slots for it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 struct Lisp_Compiled_Function *b =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 XCOMPILED_FUNCTION (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 /* This compiled-function object must have a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 slot for the docstring, since we've found a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 docstring for it. Unless there were multiple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 definitions of it, and the latter one didn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 have any doc, which is a legal if slightly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 bogus situation, so don't blow up. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 if (! (b->flags.documentationp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 weird_doc (sym, GETTEXT ("no doc slot"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 GETTEXT ("bytecode"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 Lisp_Object old =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 compiled_function_documentation (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 if (!ZEROP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 weird_doc (sym, GETTEXT ("duplicate"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 GETTEXT ("bytecode"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 /* In the case of duplicate doc file entries,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 always take the later one. But if the doc is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 not an int (a string, say) leave it alone. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 if (!INTP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 set_compiled_function_documentation (b, offset);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 /* Otherwise the function is undefined or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 otherwise weird. Ignore it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 weird_function:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 weird_doc (sym, GETTEXT ("weird function"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 GETTEXT ("function"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 /* lose: */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 error ("DOC file invalid at position %d", pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 weird:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 /* goto lose */;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 173
diff changeset
625 cont:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 pos += end - buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 filled -= end - buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 memmove (buf, end, filled);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 close (fd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 #if 1 /* Don't warn about functions whose doc was lost because they were
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 wrapped by advice-freeze.el... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 kludgily_ignore_lost_doc_p (Lisp_Object sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 # define kludge_prefix "ad-Orig-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 return (string_length (XSYMBOL (sym)->name) > sizeof (kludge_prefix) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 !strncmp ((char *) string_data (XSYMBOL (sym)->name), kludge_prefix,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 sizeof (kludge_prefix) - 1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 # undef kludge_prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 # define kludgily_ignore_lost_doc_p(sym) 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 verify_doc_mapper (Lisp_Object sym, Lisp_Object closure)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 if (!NILP (Ffboundp (sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 int doc = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 Lisp_Object fun = XSYMBOL (sym)->function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 if (CONSP (fun) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 EQ (XCAR (fun), Qmacro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 fun = XCDR (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 if (SUBRP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 doc = (EMACS_INT) XSUBR (fun)->doc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 else if (SYMBOLP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 doc = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 else if (KEYMAPP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 doc = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 else if (CONSP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 Lisp_Object tem = XCAR (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 if (EQ (tem, Qlambda) || EQ (tem, Qautoload))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 doc = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 tem = Fcdr (Fcdr (fun));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 if (CONSP (tem) &&
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
676 INTP (XCAR (tem)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 doc = XINT (XCAR (tem));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 else if (COMPILED_FUNCTIONP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 struct Lisp_Compiled_Function *b = XCOMPILED_FUNCTION (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 if (! (b->flags.documentationp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 doc = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 Lisp_Object tem = compiled_function_documentation (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 if (INTP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 doc = XINT (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 if (doc == 0 && !kludgily_ignore_lost_doc_p (sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 message ("Warning: doc lost for function %s.",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 string_data (XSYMBOL (sym)->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 XCDR (closure) = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 if (!NILP (Fboundp (sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 Lisp_Object doc = Fget (sym, Qvariable_documentation, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 if (ZEROP (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 message ("Warning: doc lost for variable %s.",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 string_data (XSYMBOL (sym)->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 XCDR (closure) = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
712 DEFUN ("Verify-documentation", Fverify_documentation, 0, 0, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 Used to make sure everything went well with Snarf-documentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 Writes to stderr if not.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
715 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
716 ())
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 Lisp_Object closure = Fcons (Qnil, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 GCPRO1 (closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 map_obarray (Vobarray, verify_doc_mapper, closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 if (!NILP (Fcdr (closure)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 message ("\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 "This is usually because some files were preloaded by loaddefs.el or\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 "site-load.el, but were not passed to make-docfile by Makefile.\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 UNGCPRO;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 167
diff changeset
727 return NILP (Fcdr (closure)) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
731 DEFUN ("substitute-command-keys", Fsubstitute_command_keys, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 Substitute key descriptions for command names in STRING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 Return a new string which is STRING with substrings of the form \\=\\[COMMAND]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 replaced by either: a keystroke sequence that will invoke COMMAND,
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
735 or "M-x COMMAND" if COMMAND is not on any keys.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 Substrings of the form \\=\\{MAPVAR} are replaced by summaries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 \(made by describe-bindings) of the value of MAPVAR, taken as a keymap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 as the keymap for future \\=\\[COMMAND] substrings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 \\=\\= quotes the following character and is discarded;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
742 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
743 (str))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 Bufbyte *buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 int changed = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 REGISTER Bufbyte *strdata;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 REGISTER Bufbyte *bufp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 Bytecount strlength;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 Bytecount idx;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 Bytecount bsize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 Bufbyte *new;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 Lisp_Object tem = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 Lisp_Object keymap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 Bufbyte *start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 Bytecount length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 Lisp_Object name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 if (NILP (str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 CHECK_STRING (str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 tem = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 keymap = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 GCPRO4 (str, tem, keymap, name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 /* There is the possibility that the string is not destined for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 translating stream, and it could be argued that we should do the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 same thing here as in Fformat(), but there are very few times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 when this will be the case and many calls to this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 would have to have `gettext' calls added. (I18N3) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 str = LISP_GETTEXT (str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 /* KEYMAP is either nil (which means search all the active keymaps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 or a specified local map (which means search just that and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 global map). If non-nil, it might come from Voverriding_local_map,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 or from a \\<mapname> construct in STR itself.. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 #if 0 /* FSFmacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 /* This is really weird and garbagey. If keymap is nil and there's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 an overriding-local-map, `where-is-internal' will correctly note
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 this, so there's no reason to do it here. Maybe FSFmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 `where-is-internal' is broken. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 keymap = current_kboard->Voverriding_terminal_local_map;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 if (NILP (keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 keymap = Voverriding_local_map;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
791 strlength = XSTRING_LENGTH (str);
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 189
diff changeset
792 bsize = 1 + strlength;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 buf = (Bufbyte *) xmalloc (bsize);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 bufp = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 /* Have to reset strdata every time GC might be called */
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
797 strdata = XSTRING_DATA (str);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 for (idx = 0; idx < strlength; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 Bufbyte *strp = strdata + idx;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
801
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 if (strp[0] != '\\')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 /* just copy other chars */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 /* As it happens, this will work with Mule even if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 character quoted is multi-byte; the remaining multi-byte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 characters will just be copied by this loop. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 *bufp++ = *strp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 idx++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 else switch (strp[1])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 /* just copy unknown escape sequences */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 *bufp++ = *strp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 idx++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 case '=':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 /* \= quotes the next character;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 thus, to put in \[ without its special meaning, use \=\[. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 /* As it happens, this will work with Mule even if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 character quoted is multi-byte; the remaining multi-byte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 characters will just be copied by this loop. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 changed = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 *bufp++ = strp[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 idx += 3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 case '[':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 changed = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 idx += 2; /* skip \[ */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 strp += 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 start = strp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 while ((idx < strlength)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 && *strp != ']')
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
841 {
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
842 strp++;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
843 idx++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 length = strp - start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 idx++; /* skip ] */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 tem = Fintern (make_string (start, length), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 #if 0 /* FSFmacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 /* Disregard menu bar bindings; it is positively annoying to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 mention them when there's no menu bar, and it isn't terribly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 useful even when there is a menu bar. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 if (!NILP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 firstkey = Faref (tem, Qzero);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 if (EQ (firstkey, Qmenu_bar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 tem = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 if (NILP (tem)) /* but not on any keys */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 new = (Bufbyte *) xrealloc (buf, bsize += 4);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 bufp += new - buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 buf = new;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 memcpy (bufp, "M-x ", 4);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 bufp += 4;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 goto subst;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 { /* function is on a key */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 tem = Fkey_description (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 goto subst_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 case '{':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 case '<':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 /* \{foo} is replaced with a summary of keymap (symbol-value foo).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 \<foo> just sets the keymap used for \[cmd]. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 struct buffer *oldbuf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 changed = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 idx += 2; /* skip \{ or \< */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 strp += 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 start = strp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 while ((idx < strlength)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 && *strp != '}' && *strp != '>')
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
892 {
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
893 strp++;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
894 idx++;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 length = strp - start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 idx++; /* skip } or > */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 /* Get the value of the keymap in TEM, or nil if undefined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 Do this while still in the user's current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 in case it is a local variable. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 name = Fintern (make_string (start, length), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 tem = Fboundp (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 if (! NILP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 tem = Fsymbol_value (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 if (! NILP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 tem = get_keymap (tem, 0, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 /* Now switch to a temp buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 oldbuf = current_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 if (NILP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 char boof[255], *b = boof;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 *b++ = '\n';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 sprintf (b, GETTEXT (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 "Uses keymap \"%s\", which is not currently defined."),
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
921 (char *) XSTRING_DATA (Fsymbol_name (name)));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 b += strlen (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 *b++ = '\n';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 *b++ = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 buffer_insert_c_string (current_buffer, boof);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 if (start[-1] == '<') keymap = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 else if (start[-1] == '<')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 keymap = tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 describe_map_tree (tem, 1, Qnil, Qnil, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 tem = Fbuffer_substring (Qnil, Qnil, Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 Ferase_buffer (Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 set_buffer_internal (oldbuf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 goto subst_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 subst_string:
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
939 start = XSTRING_DATA (tem);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
940 length = XSTRING_LENGTH (tem);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 subst:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 bsize += length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 new = (Bufbyte *) xrealloc (buf, bsize);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 bufp += new - buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 buf = new;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 memcpy (bufp, start, length);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 bufp += length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 /* Reset STRDATA in case gc relocated it. */
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
950 strdata = XSTRING_DATA (str);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 if (changed) /* don't bother if nothing substituted */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 tem = make_string (buf, bufp - buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 tem = str;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 xfree (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 UNGCPRO;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 167
diff changeset
963 return tem;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 syms_of_doc (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 {
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
974 DEFSUBR (Fdocumentation);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
975 DEFSUBR (Fdocumentation_property);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
976 DEFSUBR (Fsnarf_documentation);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
977 DEFSUBR (Fverify_documentation);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
978 DEFSUBR (Fsubstitute_command_keys);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 vars_of_doc (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 DEFVAR_LISP ("internal-doc-file-name", &Vdoc_file_name /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 Name of file containing documentation strings of built-in symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 Vdoc_file_name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 }