annotate src/doc.c @ 165:5a88923fcbfe r20-3b9

Import from CVS: tag r20-3b9
author cvs
date Mon, 13 Aug 2007 09:44:42 +0200
parents 25f70ba0133c
children 85ec50267440
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
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
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.)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
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 }
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
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
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
289 DEFUN ("documentation", Fdocumentation, 1, 2, 0, /*
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'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
293 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
294 (function, raw))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 Lisp_Object fun;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 Lisp_Object doc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 fun = Findirect_function (function);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 if (SUBRP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 if (XSUBR (fun)->doc == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 if ((EMACS_INT) XSUBR (fun)->doc >= 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 doc = build_string (XSUBR (fun)->doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 doc = get_doc_string (make_int (- (EMACS_INT) XSUBR (fun)->doc));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 else if (COMPILED_FUNCTIONP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 Lisp_Object tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 struct Lisp_Compiled_Function *b = XCOMPILED_FUNCTION (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 if (! (b->flags.documentationp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 tem = compiled_function_documentation (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 if (STRINGP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 doc = tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 else if (NATNUMP (tem) || CONSP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 doc = get_doc_string (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 else if (KEYMAPP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 return build_translated_string ("Prefix command (definition is a keymap of subcommands).");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 else if (STRINGP (fun) || VECTORP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 return build_translated_string ("Keyboard macro.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 else if (CONSP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 Lisp_Object funcar = Fcar (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 if (!SYMBOLP (funcar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 return Fsignal (Qinvalid_function, list1 (fun));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 else if (EQ (funcar, Qlambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 || EQ (funcar, Qautoload))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 Lisp_Object tem, tem1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 tem1 = Fcdr (Fcdr (fun));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 tem = Fcar (tem1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 if (STRINGP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 doc = tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 /* Handle a doc reference--but these never come last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 in the function body, so reject them if they are last. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 else if ((NATNUMP (tem) || CONSP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 && ! NILP (XCDR (tem1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 doc = get_doc_string (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 else if (EQ (funcar, Qmacro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 return Fdocumentation (Fcdr (fun), raw);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 goto oops;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 oops:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 return Fsignal (Qinvalid_function, list1 (fun));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 if (NILP (raw))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 Lisp_Object domain = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 if (COMPILED_FUNCTIONP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 domain = Fcompiled_function_domain (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 if (NILP (domain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 doc = Fgettext (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 doc = Fdgettext (domain, doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 GCPRO1 (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 doc = Fsubstitute_command_keys (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 return doc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
382 DEFUN ("documentation-property", Fdocumentation_property, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 Return the documentation string that is SYMBOL's PROP property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 This is like `get', but it can refer to strings stored in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 `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
386 through `substitute-command-keys'. A non-nil third argument avoids this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 translation.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
388 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
389 (sym, prop, raw))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 REGISTER Lisp_Object doc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 REGISTER Lisp_Object domain;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 doc = Fget (sym, prop, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 if (INTP (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 doc = get_doc_string (XINT (doc) > 0 ? doc : make_int (- XINT (doc)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 else if (CONSP (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 doc = get_doc_string (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 #ifdef I18N3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 if (!NILP (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 domain = Fget (sym, Qvariable_domain, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 if (NILP (domain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 doc = Fgettext (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 doc = Fdgettext (domain, doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 if (NILP (raw) && STRINGP (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 doc = Fsubstitute_command_keys (doc);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 return doc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 weird_doc (Lisp_Object sym, CONST char *weirdness, CONST char *type, int pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 {
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 80
diff changeset
420 /*#if defined(ENERGIZE) || defined(SUNPRO)*/ /* hide kludgery... */
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 80
diff changeset
421 /* (for everyone) */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 if (!strcmp (weirdness, GETTEXT ("duplicate"))) return;
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 80
diff changeset
423 /*#endif*/
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 message ("Note: Strange doc (%s) for %s %s @ %d",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 weirdness, type, string_data (XSYMBOL (sym)->name), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
429 DEFUN ("Snarf-documentation", Fsnarf_documentation, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 Used during Emacs initialization, before dumping runnable Emacs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 to find pointers to doc strings stored in `.../lib-src/DOC' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 record them in function definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 One arg, FILENAME, a string which does not include a directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 The file is written to `../lib-src', and later found in `exec-directory'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 when doc strings are referred to in the dumped Emacs.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
436 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
437 (filename))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 int fd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 char buf[1024 + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 REGISTER int filled;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 REGISTER int pos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 REGISTER char *p, *end;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 Lisp_Object sym, fun, tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 char *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 #ifndef CANNOT_DUMP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 if (!purify_flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 error ("Snarf-documentation can only be called in an undumped Emacs");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 CHECK_STRING (filename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 #ifndef CANNOT_DUMP
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
456 name = (char *) alloca (XSTRING_LENGTH (filename) + 14);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 strcpy (name, "../lib-src/");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 #else /* CANNOT_DUMP */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 CHECK_STRING (Vdoc_directory);
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
460 name = (char *) alloca (XSTRING_LENGTH (filename)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
461 + XSTRING_LENGTH (Vdoc_directory)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 + 1);
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
463 strcpy (name, (char *) XSTRING_DATA (Vdoc_directory));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 #endif /* CANNOT_DUMP */
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
465 strcat (name, (char *) XSTRING_DATA (filename));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 #ifdef VMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 #ifndef VMS4_4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 /* For VMS versions with limited file name syntax,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 convert the name to something VMS will allow. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 p = name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 while (*p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 if (*p == '-')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 *p = '_';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 p++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 #endif /* not VMS4_4 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 #ifdef VMS4_4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 strcpy (name, sys_translate_unix (name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 #endif /* VMS4_4 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 #endif /* VMS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 fd = open (name, O_RDONLY, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 if (fd < 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 report_file_error ("Opening doc string file",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 Fcons (build_string (name), Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 Vdoc_file_name = filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 filled = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 pos = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 if (filled < 512)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 filled += read (fd, &buf[filled], sizeof buf - 1 - filled);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 if (!filled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 buf[filled] = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 p = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 end = buf + (filled < 512 ? filled : filled - 128);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 while (p != end && *p != '\037') p++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 if (p != end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 end = strchr (p, '\n');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 sym = oblookup (Vobarray, (Bufbyte *) p + 2, end - p - 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 if (SYMBOLP (sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 Lisp_Object offset = make_int (pos + end + 1 - buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 /* Attach a docstring to a variable */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 if (p[1] == 'V')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 /* Install file-position as variable-documentation property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 and make it negative for a user-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (doc starts with a `*'). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 Lisp_Object old = Fget (sym, Qvariable_documentation, Qzero);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 if (!ZEROP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 weird_doc (sym, GETTEXT ("duplicate"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 GETTEXT ("variable"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 /* In the case of duplicate doc file entries, always
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 take the later one. But if the doc is not an int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (a string, say) leave it alone. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 if (!INTP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 Fput (sym, Qvariable_documentation,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ((end[1] == '*')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ? make_int (- XINT (offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 : offset));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 /* Attach a docstring to a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 The type determines where the docstring is stored. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 else if (p[1] == 'F')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 fun = XSYMBOL (sym)->function;/*indirect_function (sym,0);*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 fun = XCDR (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 if (UNBOUNDP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 /* May have been #if'ed out or something */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 weird_doc (sym, GETTEXT ("not fboundp"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 GETTEXT ("function"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 else if (SUBRP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 /* Lisp_Subrs have a slot for it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 if (XSUBR (fun)->doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 weird_doc (sym, GETTEXT ("duplicate"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 GETTEXT ("subr"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 XSUBR (fun)->doc = (char *) (- XINT (offset));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 else if (CONSP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 /* If it's a lisp form, stick it in the form. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 tem = XCAR (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 if (EQ (tem, Qlambda) || EQ (tem, Qautoload))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 tem = Fcdr (Fcdr (fun));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 if (CONSP (tem) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 INTP (XCAR (tem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 Lisp_Object old = XCAR (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 if (!ZEROP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 weird_doc (sym, GETTEXT ("duplicate"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (EQ (tem, Qlambda)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ? GETTEXT ("lambda")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 : GETTEXT ("autoload")),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 /* In the case of duplicate doc file entries,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 always take the later one. But if the doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 is not an int (a string, say) leave it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 alone. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 if (!INTP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 XCAR (tem) = offset;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 else goto weird_function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 else goto weird_function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 else if (COMPILED_FUNCTIONP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 /* Compiled-Function objects sometimes have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 slots for it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 struct Lisp_Compiled_Function *b =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 XCOMPILED_FUNCTION (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 /* This compiled-function object must have a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 slot for the docstring, since we've found a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 docstring for it. Unless there were multiple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 definitions of it, and the latter one didn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 have any doc, which is a legal if slightly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 bogus situation, so don't blow up. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 if (! (b->flags.documentationp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 weird_doc (sym, GETTEXT ("no doc slot"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 GETTEXT ("bytecode"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 Lisp_Object old =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 compiled_function_documentation (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 if (!ZEROP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 weird_doc (sym, GETTEXT ("duplicate"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 GETTEXT ("bytecode"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 /* In the case of duplicate doc file entries,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 always take the later one. But if the doc is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 not an int (a string, say) leave it alone. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 if (!INTP (old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 set_compiled_function_documentation (b, offset);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 /* Otherwise the function is undefined or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 otherwise weird. Ignore it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 weird_function:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 weird_doc (sym, GETTEXT ("weird function"),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 GETTEXT ("function"), pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 goto weird;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 /* lose: */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 error ("DOC file invalid at position %d", pos);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 weird:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 /* goto lose */;
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 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 pos += end - buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 filled -= end - buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 memmove (buf, end, filled);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 close (fd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 return Qnil;
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 #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
655 wrapped by advice-freeze.el... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 kludgily_ignore_lost_doc_p (Lisp_Object sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 # define kludge_prefix "ad-Orig-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 return (string_length (XSYMBOL (sym)->name) > sizeof (kludge_prefix) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 !strncmp ((char *) string_data (XSYMBOL (sym)->name), kludge_prefix,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 sizeof (kludge_prefix) - 1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 # undef kludge_prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 # define kludgily_ignore_lost_doc_p(sym) 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 verify_doc_mapper (Lisp_Object sym, Lisp_Object closure)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 if (!NILP (Ffboundp (sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 int doc = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 Lisp_Object fun = XSYMBOL (sym)->function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 if (CONSP (fun) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 EQ (XCAR (fun), Qmacro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 fun = XCDR (fun);
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 (SUBRP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 doc = (EMACS_INT) XSUBR (fun)->doc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 else if (SYMBOLP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 doc = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 else if (KEYMAPP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 doc = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 else if (CONSP (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 Lisp_Object tem = XCAR (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 if (EQ (tem, Qlambda) || EQ (tem, Qautoload))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 {
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 tem = Fcdr (Fcdr (fun));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 if (CONSP (tem) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 INTP (XCAR (tem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 doc = XINT (XCAR (tem));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 else if (COMPILED_FUNCTIONP (fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 struct Lisp_Compiled_Function *b = XCOMPILED_FUNCTION (fun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 if (! (b->flags.documentationp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 doc = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 Lisp_Object tem = compiled_function_documentation (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 if (INTP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 doc = XINT (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 if (doc == 0 && !kludgily_ignore_lost_doc_p (sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 message ("Warning: doc lost for function %s.",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 string_data (XSYMBOL (sym)->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 XCDR (closure) = Qt;
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 if (!NILP (Fboundp (sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 Lisp_Object doc = Fget (sym, Qvariable_documentation, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 if (ZEROP (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 message ("Warning: doc lost for variable %s.",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 string_data (XSYMBOL (sym)->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 XCDR (closure) = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
731 DEFUN ("Verify-documentation", Fverify_documentation, 0, 0, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 Used to make sure everything went well with Snarf-documentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 Writes to stderr if not.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
734 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
735 ())
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 Lisp_Object closure = Fcons (Qnil, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 GCPRO1 (closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 map_obarray (Vobarray, verify_doc_mapper, closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 if (!NILP (Fcdr (closure)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 message ("\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 "This is usually because some files were preloaded by loaddefs.el or\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 "site-load.el, but were not passed to make-docfile by Makefile.\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 return (NILP (Fcdr (closure)) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
750 DEFUN ("substitute-command-keys", Fsubstitute_command_keys, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 Substitute key descriptions for command names in STRING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 Return a new string which is STRING with substrings of the form \\=\\[COMMAND]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 replaced by either: a keystroke sequence that will invoke COMMAND,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 or \"M-x COMMAND\" if COMMAND is not on any keys.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 Substrings of the form \\=\\{MAPVAR} are replaced by summaries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 \(made by describe-bindings) of the value of MAPVAR, taken as a keymap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 as the keymap for future \\=\\[COMMAND] substrings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 \\=\\= quotes the following character and is discarded;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
761 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
762 (str))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 Bufbyte *buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 int changed = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 REGISTER Bufbyte *strdata;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 REGISTER Bufbyte *bufp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 Bytecount strlength;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 Bytecount idx;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 Bytecount bsize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 Bufbyte *new;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 Lisp_Object tem = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 Lisp_Object keymap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 Bufbyte *start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 Bytecount length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 Lisp_Object name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 if (NILP (str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 CHECK_STRING (str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 tem = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 keymap = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 GCPRO4 (str, tem, keymap, name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 /* There is the possibility that the string is not destined for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 translating stream, and it could be argued that we should do the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 same thing here as in Fformat(), but there are very few times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 when this will be the case and many calls to this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 would have to have `gettext' calls added. (I18N3) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 str = LISP_GETTEXT (str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 /* KEYMAP is either nil (which means search all the active keymaps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 or a specified local map (which means search just that and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 global map). If non-nil, it might come from Voverriding_local_map,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 or from a \\<mapname> construct in STR itself.. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 #if 0 /* FSFmacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 /* This is really weird and garbagey. If keymap is nil and there's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 an overriding-local-map, `where-is-internal' will correctly note
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 this, so there's no reason to do it here. Maybe FSFmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 `where-is-internal' is broken. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 keymap = current_kboard->Voverriding_terminal_local_map;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 if (NILP (keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 keymap = Voverriding_local_map;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
810 strlength = XSTRING_LENGTH (str);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 bsize = strlength;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 buf = (Bufbyte *) xmalloc (bsize);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 bufp = buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 /* Have to reset strdata every time GC might be called */
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
816 strdata = XSTRING_DATA (str);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 for (idx = 0; idx < strlength; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 Bufbyte *strp = strdata + idx;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 if (strp[0] != '\\')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 /* just copy other chars */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 /* As it happens, this will work with Mule even if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 character quoted is multi-byte; the remaining multi-byte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 characters will just be copied by this loop. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 *bufp++ = *strp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 idx++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 else switch (strp[1])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 default:
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 unknown escape sequences */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 *bufp++ = *strp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 idx++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 case '=':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 /* \= quotes the next character;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 thus, to put in \[ without its special meaning, use \=\[. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 /* As it happens, this will work with Mule even if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 character quoted is multi-byte; the remaining multi-byte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 characters will just be copied by this loop. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 changed = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 *bufp++ = strp[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 idx += 3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 case '[':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 changed = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 idx += 2; /* skip \[ */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 strp += 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 start = strp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 while ((idx < strlength)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 && *strp != ']')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 strp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 idx++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 length = strp - start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 idx++; /* skip ] */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 tem = Fintern (make_string (start, length), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 #if 0 /* FSFmacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 /* Disregard menu bar bindings; it is positively annoying to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 mention them when there's no menu bar, and it isn't terribly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 useful even when there is a menu bar. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 if (!NILP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 firstkey = Faref (tem, Qzero);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 if (EQ (firstkey, Qmenu_bar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 tem = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 if (NILP (tem)) /* but not on any keys */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 new = (Bufbyte *) xrealloc (buf, bsize += 4);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 bufp += new - buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 buf = new;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 memcpy (bufp, "M-x ", 4);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 bufp += 4;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 goto subst;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 { /* function is on a key */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 tem = Fkey_description (tem);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 goto subst_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 case '{':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 case '<':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 /* \{foo} is replaced with a summary of keymap (symbol-value foo).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 \<foo> just sets the keymap used for \[cmd]. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 struct buffer *oldbuf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 changed = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 idx += 2; /* skip \{ or \< */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 strp += 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 start = strp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 while ((idx < strlength)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 && *strp != '}' && *strp != '>')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 strp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 idx++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 length = strp - start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 idx++; /* skip } or > */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 /* Get the value of the keymap in TEM, or nil if undefined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 Do this while still in the user's current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 in case it is a local variable. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 name = Fintern (make_string (start, length), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 tem = Fboundp (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 if (! NILP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 tem = Fsymbol_value (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 if (! NILP (tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 tem = get_keymap (tem, 0, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 /* Now switch to a temp buffer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 oldbuf = current_buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933
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 char boof[255], *b = boof;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 *b++ = '\n';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 sprintf (b, GETTEXT (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 "Uses keymap \"%s\", which is not currently defined."),
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
940 (char *) XSTRING_DATA (Fsymbol_name (name)));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 b += strlen (b);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 *b++ = '\n';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 *b++ = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 buffer_insert_c_string (current_buffer, boof);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 if (start[-1] == '<') keymap = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 else if (start[-1] == '<')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 keymap = tem;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 describe_map_tree (tem, 1, Qnil, Qnil, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 tem = Fbuffer_substring (Qnil, Qnil, Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 Ferase_buffer (Fcurrent_buffer ());
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 set_buffer_internal (oldbuf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 goto subst_string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 subst_string:
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
958 start = XSTRING_DATA (tem);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
959 length = XSTRING_LENGTH (tem);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 subst:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 bsize += length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 new = (Bufbyte *) xrealloc (buf, bsize);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 bufp += new - buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 buf = new;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 memcpy (bufp, start, length);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 bufp += length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 /* Reset STRDATA in case gc relocated it. */
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
969 strdata = XSTRING_DATA (str);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 if (changed) /* don't bother if nothing substituted */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 tem = make_string (buf, bufp - buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 tem = str;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 xfree (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 return (tem);
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 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 syms_of_doc (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 {
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
993 DEFSUBR (Fdocumentation);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
994 DEFSUBR (Fdocumentation_property);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
995 DEFSUBR (Fsnarf_documentation);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
996 DEFSUBR (Fverify_documentation);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
997 DEFSUBR (Fsubstitute_command_keys);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 vars_of_doc (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 DEFVAR_LISP ("internal-doc-file-name", &Vdoc_file_name /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 Name of file containing documentation strings of built-in symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 Vdoc_file_name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 }