annotate src/doc.c @ 14:9ee227acff29 r19-15b90

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