annotate src/doc.c @ 5628:81fee4aee9b6

text_width methods interface cleanup. -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2011-12-28 Didier Verna <didier@xemacs.org> * console-impl.h (struct console_methods): Have the text_width methods expect a frame instead of a window pointer. * console-stream.c (stream_text_width): * redisplay-msw.c (mswindows_text_width): * redisplay-tty.c (tty_text_width): * redisplay-xlike-inc.c (XLIKE_text_width): Update accordingly. * redisplay-msw.c (mswindows_output_string): * redisplay-xlike-inc.c (XLIKE_output_string): * redisplay.c (redisplay_window_text_width_ichar_string): * redisplay.c (redisplay_text_width_string): Update the callers. This also fixes an uncertainty about always getting a window from a domain.
author Didier Verna <didier@xemacs.org>
date Wed, 28 Dec 2011 11:21:38 +0100
parents 3b1d4fa716a4
children 2014ff433daf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Record indices of function doc strings stored in a file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Free Software Foundation, Inc.
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
4 Copyright (C) 2001, 2002, 2004 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
8 XEmacs is free software: you can redistribute it and/or modify it
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
10 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
11 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5206
diff changeset
19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.30. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
23 /* This file has been Mule-ized. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include "bytecode.h"
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
30 #include "file-coding.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include "insdel.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "keymap.h"
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
33 #include "lstream.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "sysfile.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 Lisp_Object Vinternal_doc_file_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
38 Lisp_Object QSsubstitute, Qdefvar;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
40 /* Work out what source file a function or variable came from, taking the
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
41 information from the documentation file. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
42
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
43 static Lisp_Object
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
44 extract_object_file_name (int fd, EMACS_INT doc_pos,
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
45 Ibyte *name_nonreloc, Lisp_Object name_reloc,
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
46 int standard_doc_file)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
47 {
3383
3583b965b1c5 [xemacs-hg @ 2006-05-07 14:20:33 by stephent]
stephent
parents: 3368
diff changeset
48 Ibyte buf[DOC_MAX_FILENAME_LENGTH+1];
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
49 Ibyte *buffer = buf;
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
50 int buffer_size = sizeof (buf) - 1, space_left;
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
51 Ibyte *from, *to;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
52 REGISTER Ibyte *p = buffer;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
53 Lisp_Object return_me;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
54 Lisp_Object fdstream = Qnil, instream = Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
55 struct gcpro gcpro1, gcpro2;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
56 EMACS_INT position, seenS = 0;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
57
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
58 GCPRO2 (fdstream, instream);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
59
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
60 position = doc_pos > buffer_size ?
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
61 doc_pos - buffer_size : 0;
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
62
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
63 if (0 > lseek (fd, position, 0))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
64 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
65 if (name_nonreloc)
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
66 name_reloc = build_istring (name_nonreloc);
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
67 return_me = list3 (build_msg_string
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
68 ("Position out of range in doc string file"),
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
69 name_reloc, make_fixnum (position));
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
70 goto done;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
71 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
72
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
73 fdstream = make_filedesc_input_stream (fd, 0, -1, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
74 Lstream_set_buffering (XLSTREAM (fdstream), LSTREAM_UNBUFFERED, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
75 instream =
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
76 make_coding_input_stream
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
77 (XLSTREAM (fdstream), standard_doc_file ? Qescape_quoted : Qbinary,
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
78 CODING_DECODE, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
79 Lstream_set_buffering (XLSTREAM (instream), LSTREAM_UNBUFFERED, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
80
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
81 space_left = buffer_size - (p - buffer);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
82 while (space_left > 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
83 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
84 int nread;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
85
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
86 nread = Lstream_read (XLSTREAM (instream), p, space_left);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
87 if (nread < 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
88 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
89 return_me = list1 (build_msg_string
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
90 ("Read error on documentation file"));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
91 goto done;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
92 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
93
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
94 p[nread] = 0;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
95
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
96 if (!nread)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
97 break;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
98
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
99 p += nread;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
100 space_left = buffer_size - (p - buffer);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
101 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
102
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
103 /* First, search backward for the "\037S" that marks the beginning of the
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
104 file name, then search forward from that to the newline or to the end
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
105 of the buffer. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
106 from = p;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
107
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
108 while (from > buf)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
109 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
110 --from;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
111 if (seenS)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
112 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
113 if ('\037' == *from)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
114 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
115 /* Got a file name; adjust `from' to point to it, break out of
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
116 the loop. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
117 from += 2;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
118 break;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
119 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
120 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
121 /* Is *from 'S' ? */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
122 seenS = ('S' == *from);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
123 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
124
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
125 if (buf == from)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
126 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
127 /* We've scanned back to the beginning of the buffer without hitting
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
128 the file name. Either the file name plus the symbol name is longer
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
129 than DOC_MAX_FILENAME_LENGTH--which shouldn't happen, because it'll
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
130 trigger an assertion failure in make-docfile, the DOC file is
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
131 corrupt, or it was produced by a version of make-docfile that
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
132 doesn't store the file name with the symbol name and docstring. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
133 return_me = list1 (build_msg_string
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
134 ("Object file name not stored in doc file"));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
135 goto done;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
136 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
137
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
138 to = from;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
139 /* Search for the end of the file name. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
140 while (++to < p)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
141 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
142 if ('\n' == *to || '\037' == *to)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
143 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
144 break;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
145 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
146 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
147
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
148 /* Don't require the file name to end in a newline. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
149 return_me = make_string (from, to - from);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
150
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
151 done:
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
152 if (!NILP (instream))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
153 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
154 Lstream_delete (XLSTREAM (instream));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
155 Lstream_delete (XLSTREAM (fdstream));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
156 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
157
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
158 UNGCPRO;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
159 return return_me;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
160 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 unparesseuxify_doc_string (int fd, EMACS_INT position,
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
164 Ibyte *name_nonreloc, Lisp_Object name_reloc,
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
165 int standard_doc_file)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
167 Ibyte buf[512 * 32 + 1];
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
168 Ibyte *buffer = buf;
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
169 int buffer_size = sizeof (buf) - 1;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
170 Ibyte *from, *to;
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
171 REGISTER Ibyte *p = buffer;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 Lisp_Object return_me;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
173 Lisp_Object fdstream = Qnil, instream = Qnil;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
174 struct gcpro gcpro1, gcpro2;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
175
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
176 GCPRO2 (fdstream, instream);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 if (0 > lseek (fd, position, 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 if (name_nonreloc)
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
181 name_reloc = build_istring (name_nonreloc);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
182 return_me = list3 (build_msg_string
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 ("Position out of range in doc string file"),
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
184 name_reloc, make_fixnum (position));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
188 fdstream = make_filedesc_input_stream (fd, 0, -1, 0);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
189 Lstream_set_buffering (XLSTREAM (fdstream), LSTREAM_UNBUFFERED, 0);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
190 instream =
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
191 make_coding_input_stream
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
192 /* Major trouble if we are too clever when reading byte-code
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
193 instructions!
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
194
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
195 #### We should have a way of handling escape-quoted elc files
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
196 (i.e. files with non-ASCII/Latin-1 chars in them). Currently this
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
197 is "solved" in bytecomp.el by never inserting lazy references in
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
198 such files. */
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 814
diff changeset
199 (XLSTREAM (fdstream), standard_doc_file ? Qescape_quoted : Qbinary,
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
200 CODING_DECODE, 0);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
201 Lstream_set_buffering (XLSTREAM (instream), LSTREAM_UNBUFFERED, 0);
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
202
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 /* Read the doc string into a buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 Use the fixed buffer BUF if it is big enough; otherwise allocate one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 We store the buffer in use in BUFFER and its size in BUFFER_SIZE. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 int space_left = buffer_size - (p - buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 int nread;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 /* Switch to a bigger buffer if we need one. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 if (space_left == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
215 Ibyte *old_buffer = buffer;
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
216 buffer_size *= 2;
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
217
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
218 if (buffer == buf)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
219 {
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
220 buffer = xnew_ibytes (buffer_size + 1);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
221 memcpy (buffer, old_buffer, p - old_buffer);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
222 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
223 else
3411
41c353ad2c74 [xemacs-hg @ 2006-05-21 18:35:30 by aidan]
aidan
parents: 3383
diff changeset
224 XREALLOC_ARRAY (buffer, Ibyte, buffer_size + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 p += buffer - old_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 space_left = buffer_size - (p - buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 /* Don't read too much at one go. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 if (space_left > 1024 * 8)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 space_left = 1024 * 8;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
232 nread = Lstream_read (XLSTREAM (instream), p, space_left);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 if (nread < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
235 return_me = list1 (build_msg_string
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 ("Read error on documentation file"));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 p[nread] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 if (!nread)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
243 Ibyte *p1 = qxestrchr (p, '\037'); /* End of doc string marker */
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
244 if (p1)
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
245 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
246 *p1 = 0;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
247 p = p1;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
248 break;
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
249 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 p += nread;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 /* Scan the text and remove quoting with ^A (char code 1).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 from = to = buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 while (from < p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 if (*from != 1 /*^A*/)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 *to++ = *from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 int c = *(++from);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 from++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 case 1: *to++ = c; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 case '0': *to++ = '\0'; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 case '_': *to++ = '\037'; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 default:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
272 return_me = list2 (build_msg_string
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 ("Invalid data in documentation file -- ^A followed by weird code"),
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
274 make_fixnum (c));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 goto done;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
280 return_me = make_string (buffer, to - buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 done:
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
283 if (!NILP (instream))
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
284 {
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
285 Lstream_delete (XLSTREAM (instream));
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
286 Lstream_delete (XLSTREAM (fdstream));
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
287 }
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
288 UNGCPRO;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 if (buffer != buf) /* We must have allocated buffer above */
4976
16112448d484 Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
290 xfree (buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 return return_me;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
294 #define string_join(dest, s1, s2) \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
295 memcpy (dest, XSTRING_DATA (s1), XSTRING_LENGTH (s1)); \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
296 memcpy (dest + XSTRING_LENGTH (s1), XSTRING_DATA (s2), \
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
297 XSTRING_LENGTH (s2)); \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 dest[XSTRING_LENGTH (s1) + XSTRING_LENGTH (s2)] = '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 /* Extract a doc string from a file. FILEPOS says where to get it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 (This could actually be byte code instructions/constants instead
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 of a doc string.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 If it is an integer, use that position in the standard DOC file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 If it is (FILE . INTEGER), use FILE as the file name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 and INTEGER as the position in that file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 But if INTEGER is negative, make it positive.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 (A negative integer is used for user variables, so we can distinguish
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 them without actually fetching the doc string.) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 static Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 get_doc_string (Lisp_Object filepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 REGISTER int fd;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
314 REGISTER Ibyte *name_nonreloc = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 EMACS_INT position;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 Lisp_Object file, tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 Lisp_Object name_reloc = Qnil;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
318 int standard_doc_file = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
320 if (FIXNUMP (filepos))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 file = Vinternal_doc_file_name;
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
323 standard_doc_file = 1;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
324 position = XFIXNUM (filepos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 }
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
326 else if (CONSP (filepos) && FIXNUMP (XCDR (filepos)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 file = XCAR (filepos);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
329 position = XFIXNUM (XCDR (filepos));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 if (position < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 position = - position;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 if (!STRINGP (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 /* Put the file name in NAME as a C string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 If it is relative, combine it with Vdoc_directory. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 tem = Ffile_name_absolute_p (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 if (NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 {
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 563
diff changeset
345 Bytecount minsize;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 /* XEmacs: Move this check here. OK if called during loadup to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 load byte code instructions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 if (!STRINGP (Vdoc_directory))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 minsize = XSTRING_LENGTH (Vdoc_directory);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 /* sizeof ("../lib-src/") == 12 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 if (minsize < 12)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 minsize = 12;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
355 name_nonreloc = alloca_ibytes (minsize + XSTRING_LENGTH (file) + 8);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 string_join (name_nonreloc, Vdoc_directory, file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 name_reloc = file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
361 fd = qxe_open (name_nonreloc ? name_nonreloc :
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
362 XSTRING_DATA (name_reloc), O_RDONLY | OPEN_BINARY, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 if (fd < 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 if (purify_flag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 /* sizeof ("../lib-src/") == 12 */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
368 name_nonreloc = alloca_ibytes (12 + XSTRING_LENGTH (file) + 8);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 /* Preparing to dump; DOC file is probably not installed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 So check in ../lib-src. */
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
371 qxestrcpy_ascii (name_nonreloc, "../lib-src/");
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
372 qxestrcat (name_nonreloc, XSTRING_DATA (file));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
374 fd = qxe_open (name_nonreloc, O_RDONLY | OPEN_BINARY, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 if (fd < 0)
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
378 report_file_error ("Cannot open doc string file",
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
379 name_nonreloc ? build_istring (name_nonreloc) :
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
380 name_reloc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
383 tem = unparesseuxify_doc_string (fd, position, name_nonreloc, name_reloc,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
384 standard_doc_file);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
385 retry_close (fd);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 if (!STRINGP (tem))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
388 signal_error_1 (Qinvalid_byte_code, tem);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 return tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 /* Get a string from position FILEPOS and pass it through the Lisp reader.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 We use this for fetching the bytecode string and constants vector
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 of a compiled function from the .elc file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 read_doc_string (Lisp_Object filepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 Lisp_Object string = get_doc_string (filepos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 if (!STRINGP (string))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
403 invalid_state ("loading bytecode failed to return string", string);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 return Fread (string);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
407 static Lisp_Object
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
408 get_object_file_name (Lisp_Object filepos)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
409 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
410 REGISTER int fd;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
411 REGISTER Ibyte *name_nonreloc = 0;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
412 EMACS_INT position;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
413 Lisp_Object file, tem;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
414 Lisp_Object name_reloc = Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
415 int standard_doc_file = 0;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
416
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
417 if (FIXNUMP (filepos))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
418 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
419 file = Vinternal_doc_file_name;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
420 standard_doc_file = 1;
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
421 position = XFIXNUM (filepos);
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
422 }
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
423 else if (CONSP (filepos) && FIXNUMP (XCDR (filepos)))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
424 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
425 file = XCAR (filepos);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
426 position = XFIXNUM (XCDR (filepos));
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
427 if (position < 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
428 position = - position;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
429 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
430 else
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
431 return Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
432
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
433 if (!STRINGP (file))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
434 return Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
435
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
436 /* Put the file name in NAME as a C string.
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
437 If it is relative, combine it with Vdoc_directory. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
438
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
439 tem = Ffile_name_absolute_p (file);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
440 if (NILP (tem))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
441 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
442 Bytecount minsize;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
443 /* XEmacs: Move this check here. OK if called during loadup to
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
444 load byte code instructions. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
445 if (!STRINGP (Vdoc_directory))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
446 return Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
447
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
448 minsize = XSTRING_LENGTH (Vdoc_directory);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
449 /* sizeof ("../lib-src/") == 12 */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
450 if (minsize < 12)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
451 minsize = 12;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
452 name_nonreloc = alloca_ibytes (minsize + XSTRING_LENGTH (file) + 8);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
453 string_join (name_nonreloc, Vdoc_directory, file);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
454 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
455 else
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
456 name_reloc = file;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
457
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
458 fd = qxe_open (name_nonreloc ? name_nonreloc :
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
459 XSTRING_DATA (name_reloc), O_RDONLY | OPEN_BINARY, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
460 if (fd < 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
461 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
462 if (purify_flag)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
463 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
464 /* sizeof ("../lib-src/") == 12 */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
465 name_nonreloc = alloca_ibytes (12 + XSTRING_LENGTH (file) + 8);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
466 /* Preparing to dump; DOC file is probably not installed.
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
467 So check in ../lib-src. */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
468 qxestrcpy_ascii (name_nonreloc, "../lib-src/");
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
469 qxestrcat (name_nonreloc, XSTRING_DATA (file));
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
470
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
471 fd = qxe_open (name_nonreloc, O_RDONLY | OPEN_BINARY, 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
472 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
473
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
474 if (fd < 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
475 report_file_error ("Cannot open doc string file",
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
476 name_nonreloc ? build_istring (name_nonreloc) :
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
477 name_reloc);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
478 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
479
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
480 tem = extract_object_file_name (fd, position, name_nonreloc, name_reloc,
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
481 standard_doc_file);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
482 retry_close (fd);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
483
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
484 if (!STRINGP (tem))
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
485 signal_error_1 (Qinvalid_byte_code, tem);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
486
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
487 return tem;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
488 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
489
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
490
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
491 static void
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
492 weird_doc (Lisp_Object sym, const Ascbyte *weirdness, const Ascbyte *type,
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
493 int pos)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
494 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
495 if (!strcmp (weirdness, "duplicate")) return;
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
496 message ("Note: Strange doc (%s) for %s %s @ %d",
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
497 GETTEXT (weirdness), GETTEXT (type),
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
498 XSTRING_DATA (XSYMBOL (sym)->name), pos);
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
499 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
500
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
501 DEFUN ("built-in-symbol-file", Fbuilt_in_symbol_file, 1, 2, 0, /*
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
502 Return the C source file built-in symbol SYM comes from.
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
503 Don't use this. Use the more general `symbol-file' (q.v.) instead.
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
504
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
505 If TYPE is nil or omitted, any kind of definition is acceptable.
4905
755ae5b97edb Change "special form" to "special operator" in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4539
diff changeset
506 If TYPE is `defun', then function, subr, special operator or macro definitions
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
507 are acceptable.
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
508 If TYPE is `defvar', then variable definitions are acceptable.
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
509 */
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
510 (symbol, type))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
511 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
512 /* This function can GC */
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
513 Lisp_Object fun;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
514 Lisp_Object filename = Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
515
5596
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
516 CHECK_SYMBOL (symbol);
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
517
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
518 if (!UNBOUNDP (XSYMBOL_FUNCTION (symbol))
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
519 && (NILP (type) || EQ (type, Qdefun)))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
520 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
521 fun = Findirect_function (symbol);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
522
5596
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
523 if (EQ (Qmacro, Fcar_safe (fun)))
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
524 {
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
525 fun = XCDR (fun);
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
526 }
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
527
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
528 if (SUBRP (fun))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
529 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
530 if (XSUBR (fun)->doc == 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
531 return Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
532
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
533 if ((EMACS_INT) XSUBR (fun)->doc >= 0)
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
534 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
535 weird_doc (symbol, "No file info available for function",
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
536 GETTEXT("function"), 0);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
537 return Qnil;
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
538 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
539 else
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
540 {
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
541 filename = get_object_file_name
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
542 (make_fixnum (- (EMACS_INT) XSUBR (fun)->doc));
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
543 return filename;
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
544 }
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
545 }
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
546
5596
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
547 if (COMPILED_FUNCTIONP (fun))
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
548 {
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
549 Lisp_Object tem;
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
550 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun);
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
551
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
552 if (! (f->flags.documentationp))
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
553 return Qnil;
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
554 tem = compiled_function_documentation (f);
5596
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
555 if (NATNUMP (tem))
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
556 {
5596
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
557 return get_object_file_name (tem);
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
558 }
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
559 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
560 }
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
561
5596
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
562 if (!UNBOUNDP (XSYMBOL_VALUE (symbol)) && (NILP (type) || EQ (type, Qdefvar)))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
563 {
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
564 Lisp_Object doc_offset = Fget (symbol, Qvariable_documentation, Qnil);
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
565
5596
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
566 if (!NILP (doc_offset))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
567 {
5596
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
568 if (FIXNUMP (doc_offset))
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
569 {
5596
3b1d4fa716a4 Ignore lazy docstring info, #'built-in-symbol-file; nothing built-in uses it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5581
diff changeset
570 filename = get_object_file_name
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
571 (XFIXNUM (doc_offset) > 0 ? doc_offset
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
572 : make_fixnum (- XFIXNUM (doc_offset)));
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
573 }
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
574 return filename;
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
575 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
576 }
4539
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
577
061e030e3270 Fix some bugs in load-history construction, built-in symbol file names.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4381
diff changeset
578 return Qnil;
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
579 }
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
580
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 DEFUN ("documentation", Fdocumentation, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 Return the documentation string of FUNCTION.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
583 Unless a non-nil second argument RAW is given, the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 string is passed through `substitute-command-keys'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 (function, raw))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 Lisp_Object fun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 Lisp_Object doc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 fun = Findirect_function (function);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 if (SUBRP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 if (XSUBR (fun)->doc == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 if ((EMACS_INT) XSUBR (fun)->doc >= 0)
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
599 doc = build_cistring (XSUBR (fun)->doc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 else
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
601 doc = get_doc_string (make_fixnum (- (EMACS_INT) XSUBR (fun)->doc));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 else if (COMPILED_FUNCTIONP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 Lisp_Object tem;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
606 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 if (! (f->flags.documentationp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 tem = compiled_function_documentation (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 if (STRINGP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 doc = tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 else if (NATNUMP (tem) || CONSP (tem))
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
613 {
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
614 doc = get_doc_string (tem);
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
615 /* We may have zero length strings in the docfile for file
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
616 information. */
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
617 if (STRINGP (doc) && 0 == XSTRING_LENGTH (doc))
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
618 {
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
619 return Qnil;
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
620 }
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
621 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 else if (KEYMAPP (fun))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
626 return build_msg_string ("Prefix command (definition is a keymap of subcommands).");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 else if (STRINGP (fun) || VECTORP (fun))
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
628 return build_msg_string ("Keyboard macro.");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 else if (CONSP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 Lisp_Object funcar = Fcar (fun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 if (!SYMBOLP (funcar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 return Fsignal (Qinvalid_function, list1 (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 else if (EQ (funcar, Qlambda)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 || EQ (funcar, Qautoload))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 Lisp_Object tem, tem1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 tem1 = Fcdr (Fcdr (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 tem = Fcar (tem1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 if (STRINGP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 doc = tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 /* Handle a doc reference--but these never come last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 in the function body, so reject them if they are last. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 else if ((NATNUMP (tem) || CONSP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 && ! NILP (XCDR (tem1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 doc = get_doc_string (tem);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 else if (EQ (funcar, Qmacro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 return Fdocumentation (Fcdr (fun), raw);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 goto oops;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 oops:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 return Fsignal (Qinvalid_function, list1 (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 if (NILP (raw))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 Lisp_Object domain = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 if (COMPILED_FUNCTIONP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 domain = compiled_function_domain (XCOMPILED_FUNCTION (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 if (NILP (domain))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 doc = Fgettext (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 doc = Fdgettext (domain, doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 GCPRO1 (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 doc = Fsubstitute_command_keys (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 return doc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 DEFUN ("documentation-property", Fdocumentation_property, 2, 3, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 Return the documentation string that is SYMBOL's PROP property.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 This is like `get', but it can refer to strings stored in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 `doc-directory/DOC' file; and if the value is a string, it is passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 through `substitute-command-keys'. A non-nil third argument avoids this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 translation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
689 (symbol, prop, raw))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 /* This function can GC */
1849
21549d437f09 [xemacs-hg @ 2004-01-03 21:54:41 by james]
james
parents: 1726
diff changeset
692 Lisp_Object doc = Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 REGISTER Lisp_Object domain;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 GCPRO1 (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
700 doc = Fget (symbol, prop, Qnil);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
701 if (FIXNUMP (doc))
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
702 doc = get_doc_string (XFIXNUM (doc) > 0 ? doc : make_fixnum (- XFIXNUM (doc)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 else if (CONSP (doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 doc = get_doc_string (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 #ifdef I18N3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 if (!NILP (doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
708 domain = Fget (symbol, Qvariable_domain, Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 if (NILP (domain))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 doc = Fgettext (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 doc = Fdgettext (domain, doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 if (NILP (raw) && STRINGP (doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 doc = Fsubstitute_command_keys (doc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 return doc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 DEFUN ("Snarf-documentation", Fsnarf_documentation, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 Used during Emacs initialization, before dumping runnable Emacs,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 to find pointers to doc strings stored in `.../lib-src/DOC' and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 record them in function definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 One arg, FILENAME, a string which does not include a directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 The file is written to `../lib-src', and later found in `exec-directory'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 when doc strings are referred to in the dumped Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 (filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 int fd;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
733 Ibyte buf[1024 + 1];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 REGISTER int filled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 REGISTER int pos;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
736 REGISTER Ibyte *p, *end;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 Lisp_Object sym, fun, tem;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
738 Ibyte *name;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739
814
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
740 /* This function should not pass the data it's reading through a coding
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
741 stream. The reason is that the only purpose of this function is to
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
742 find the file offsets for the documentation of the various functions,
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
743 not do anything with the documentation itself. If we pass through a
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
744 coding stream, the pointers will get messed up when we start reading
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
745 ISO 2022 data because our pointers will reflect internal format, not
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
746 external format. */
a634e3b7acc8 [xemacs-hg @ 2002-04-14 12:41:59 by ben]
ben
parents: 793
diff changeset
747
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 if (!purify_flag)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 446
diff changeset
749 invalid_operation ("Snarf-documentation can only be called in an undumped Emacs", Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 CHECK_STRING (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752
1330
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 867
diff changeset
753 {
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 867
diff changeset
754 name = alloca_ibytes (XSTRING_LENGTH (filename) + 14);
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
755 qxestrcpy_ascii (name, "../lib-src/");
1330
4542b72c005e [xemacs-hg @ 2003-03-01 07:25:26 by ben]
ben
parents: 867
diff changeset
756 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
758 qxestrcat (name, XSTRING_DATA (filename));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
760 fd = qxe_open (name, O_RDONLY | OPEN_BINARY, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 if (fd < 0)
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
762 report_file_error ("Opening doc string file", build_istring (name));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 Vinternal_doc_file_name = filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 filled = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 pos = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 if (filled < 512)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
769 filled += retry_read (fd, &buf[filled], sizeof (buf) - 1 - filled);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 if (!filled)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 buf[filled] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 p = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 end = buf + (filled < 512 ? filled : filled - 128);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 while (p != end && *p != '\037') p++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 /* p points to ^_Ffunctionname\n or ^_Vvarname\n. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 if (p != end)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
780 end = qxestrchr (p, '\n');
3548
9b8943d0d12a [xemacs-hg @ 2006-08-07 20:33:23 by aidan]
aidan
parents: 3545
diff changeset
781 /* If you trigger a failure with this assertion, you probably
9b8943d0d12a [xemacs-hg @ 2006-08-07 20:33:23 by aidan]
aidan
parents: 3545
diff changeset
782 configured with --quick-build and need to rebuild your DOC
3545
2ba8b7a25429 [xemacs-hg @ 2006-08-06 16:37:31 by aidan]
aidan
parents: 3411
diff changeset
783 file. */
2ba8b7a25429 [xemacs-hg @ 2006-08-06 16:37:31 by aidan]
aidan
parents: 3411
diff changeset
784 assert((end - p - 2) > -1);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
785 sym = oblookup (Vobarray, p + 2, end - p - 2);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 if (SYMBOLP (sym))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
788 Lisp_Object offset = make_fixnum (pos + end + 1 - buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 /* Attach a docstring to a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 if (p[1] == 'V')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 /* Install file-position as variable-documentation property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 and make it negative for a user-variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 (doc starts with a `*'). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 Lisp_Object old = Fget (sym, Qvariable_documentation, Qzero);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 if (!ZEROP (old))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
798 weird_doc (sym, "duplicate",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
799 "variable", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 /* In the case of duplicate doc file entries, always
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 take the later one. But if the doc is not an int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 (a string, say) leave it alone. */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
803 if (!FIXNUMP (old))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 Fput (sym, Qvariable_documentation,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 ((end[1] == '*')
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
808 ? make_fixnum (- XFIXNUM (offset))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 : offset));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 /* Attach a docstring to a function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 The type determines where the docstring is stored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 else if (p[1] == 'F')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 fun = indirect_function (sym,0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 if (CONSP (fun) && EQ (XCAR (fun), Qmacro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 fun = XCDR (fun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 if (UNBOUNDP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
822 #if 0 /* There are lots of legitimate cases where this message will appear
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
823 (e.g. any function that's only defined when MULE is defined,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
824 provided that the function is used somewhere in a dumped Lisp
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
825 file, so that the symbol is interned in the dumped XEmacs), and
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
826 there's not a lot that can be done to eliminate the warning other
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
827 than kludges like moving the function to a Mule-only source file,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
828 which often results in ugly code. Furthermore, the only point of
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
829 this warning is to warn you when you have a DEFUN that you forget
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
830 to DEFSUBR, but the compiler will also warn you, because the DEFUN
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
831 declares a static object, and the object will be unused -- you'll
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
832 get something like
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
833
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
834 /src/xemacs/mule/src/abbrev.c:269: warning: `SFexpand_abbrev' defined but not used
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
835
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
836 So I'm disabling this. --ben */
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
837
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 /* May have been #if'ed out or something */
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
839 weird_doc (sym, "not fboundp",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
840 "function", pos);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
841 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 else if (SUBRP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 /* Lisp_Subrs have a slot for it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 if (XSUBR (fun)->doc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
849 weird_doc (sym, "duplicate",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
850 "subr", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 }
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
853 XSUBR (fun)->doc = (char *) (- XFIXNUM (offset));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 else if (CONSP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 /* If it's a lisp form, stick it in the form. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 tem = XCAR (fun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 if (EQ (tem, Qlambda) || EQ (tem, Qautoload))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 tem = Fcdr (Fcdr (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 if (CONSP (tem) &&
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
863 FIXNUMP (XCAR (tem)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 Lisp_Object old = XCAR (tem);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 if (!ZEROP (old))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
868 if (EQ (tem, Qlambda))
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
869 weird_doc (sym, "duplicate", "lambda",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
870 pos);
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
871 else
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
872 weird_doc (sym, "duplicate", "autoload",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
873 pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 /* In the case of duplicate doc file entries,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 always take the later one. But if the doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 is not an int (a string, say) leave it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 alone. */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
878 if (!FIXNUMP (old))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 XCAR (tem) = offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 else if (!CONSP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
885 weird_doc (sym, "!CONSP(tem)", "function", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 goto cont;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 /* DOC string is a string not integer 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 #if 0
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
892 weird_doc (sym, "!FIXNUMP(XCAR(tem))",
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
893 "function", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 goto cont;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 {
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
900 weird_doc (sym, "not lambda or autoload",
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
901 "function", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 goto cont;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 else if (COMPILED_FUNCTIONP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 /* Compiled-Function objects sometimes have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 slots for it. */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
909 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
911 /* If there were multiple definitions for this function,
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
912 and the latter one didn't
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
913 have any doc, warn and don't blow up. */
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
914 Lisp_Object old =
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
915 compiled_function_documentation (f);
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
916 if (!ZEROP (old) && !NILP (old))
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
917 {
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
918 weird_doc (sym, "duplicate", "bytecode", pos);
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
919 /* In the case of duplicate doc file entries,
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
920 always take the later one. But if the doc is
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
921 not an int (a string, say) leave it alone. */
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
922 if (!FIXNUMP (old))
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
923 goto weird;
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
924 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925
5206
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
926 /* This may be a function or variable where we want
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
927 to make the file name available. */
39d74978fd32 Keep around file info for dumped functions and variables without docstrings.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4976
diff changeset
928 set_compiled_function_documentation (f, offset);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 /* Otherwise the function is undefined or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 otherwise weird. Ignore it. */
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
934 weird_doc (sym, "weird function", "function", pos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 goto weird;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 /* lose: */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
941 signal_error (Qfile_error, "DOC file invalid at position",
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
942 make_fixnum (pos));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 weird:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 /* goto lose */;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 cont:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 pos += end - buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 filled -= end - buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 memmove (buf, end, filled);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
953 retry_close (fd);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 #if 1 /* Don't warn about functions whose doc was lost because they were
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 wrapped by advice-freeze.el... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 kludgily_ignore_lost_doc_p (Lisp_Object sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 # define kludge_prefix "ad-Orig-"
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
963 Lisp_Object name = XSYMBOL (sym)->name;
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
964 return (XSTRING_LENGTH (name) > (Bytecount) (sizeof (kludge_prefix)) &&
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
965 !qxestrncmp_ascii (XSTRING_DATA (name), kludge_prefix,
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
966 sizeof (kludge_prefix) - 1));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 # undef kludge_prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 # define kludgily_ignore_lost_doc_p(sym) 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 verify_doc_mapper (Lisp_Object sym, void *arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 {
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
977 Lisp_Object closure = * (Lisp_Object *) arg;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 if (!NILP (Ffboundp (sym)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 int doc = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 Lisp_Object fun = XSYMBOL (sym)->function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 if (CONSP (fun) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 EQ (XCAR (fun), Qmacro))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 fun = XCDR (fun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 if (SUBRP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 doc = (EMACS_INT) XSUBR (fun)->doc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 else if (SYMBOLP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 doc = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 else if (KEYMAPP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 doc = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 else if (CONSP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 Lisp_Object tem = XCAR (fun);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 if (EQ (tem, Qlambda) || EQ (tem, Qautoload))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 doc = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 tem = Fcdr (Fcdr (fun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 if (CONSP (tem) &&
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
1001 FIXNUMP (XCAR (tem)))
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
1002 doc = XFIXNUM (XCAR (tem));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 else if (COMPILED_FUNCTIONP (fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1007 Lisp_Compiled_Function *f = XCOMPILED_FUNCTION (fun);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 if (! (f->flags.documentationp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 doc = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 Lisp_Object tem = compiled_function_documentation (f);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
1013 if (FIXNUMP (tem))
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
1014 doc = XFIXNUM (tem);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 if (doc == 0 && !kludgily_ignore_lost_doc_p (sym))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 message ("Warning: doc lost for function %s.",
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1021 XSTRING_DATA (XSYMBOL (sym)->name));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 XCDR (closure) = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 if (!NILP (Fboundp (sym)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 Lisp_Object doc = Fget (sym, Qvariable_documentation, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 if (ZEROP (doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 message ("Warning: doc lost for variable %s.",
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
1031 XSTRING_DATA (XSYMBOL (sym)->name));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 XCDR (closure) = Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 return 0; /* Never stop */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 DEFUN ("Verify-documentation", Fverify_documentation, 0, 0, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 Used to make sure everything went well with Snarf-documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 Writes to stderr if not.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 ())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 Lisp_Object closure = Fcons (Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 struct gcpro gcpro1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 GCPRO1 (closure);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 map_obarray (Vobarray, verify_doc_mapper, &closure);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 if (!NILP (Fcdr (closure)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 message ("\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 "This is usually because some files were preloaded by loaddefs.el or\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 "site-load.el, but were not passed to make-docfile by Makefile.\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 return NILP (Fcdr (closure)) ? Qt : Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 DEFUN ("substitute-command-keys", Fsubstitute_command_keys, 1, 1, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 Substitute key descriptions for command names in STRING.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 Return a new string which is STRING with substrings of the form \\=\\[COMMAND]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 replaced by either: a keystroke sequence that will invoke COMMAND,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 or "M-x COMMAND" if COMMAND is not on any keys.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 Substrings of the form \\=\\{MAPVAR} are replaced by summaries
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1063 \(made by `describe-bindings') of the value of MAPVAR, taken as a keymap.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 Substrings of the form \\=\\<MAPVAR> specify to use the value of MAPVAR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 as the keymap for future \\=\\[COMMAND] substrings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 \\=\\= quotes the following character and is discarded;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 thus, \\=\\=\\=\\= puts \\=\\= into the output, and \\=\\=\\=\\[ puts \\=\\[ into the output.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1069 (string))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 /* This function can GC */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1072 Ibyte *buf;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 int changed = 0;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1074 REGISTER Ibyte *strdata;
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1075 REGISTER Ibyte *bufp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 Bytecount strlength;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 Bytecount idx;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 Bytecount bsize;
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1079 Ibyte *new_;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1080 Lisp_Object tem = Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1081 Lisp_Object keymap = Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1082 Lisp_Object name = Qnil;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1083 Ibyte *start;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 Bytecount length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1087 if (NILP (string))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1090 CHECK_STRING (string);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1091 GCPRO4 (string, tem, keymap, name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 /* There is the possibility that the string is not destined for a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 translating stream, and it could be argued that we should do the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 same thing here as in Fformat(), but there are very few times
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 when this will be the case and many calls to this function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 would have to have `gettext' calls added. (I18N3) */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1098 string = LISP_GETTEXT (string);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 /* KEYMAP is either nil (which means search all the active keymaps)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 or a specified local map (which means search just that and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 global map). If non-nil, it might come from Voverriding_local_map,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1103 or from a \\<mapname> construct in STRING itself.. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 #if 0 /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 /* This is really weird and garbagey. If keymap is nil and there's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 an overriding-local-map, `where-is-internal' will correctly note
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 this, so there's no reason to do it here. Maybe FSFmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 `where-is-internal' is broken. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 keymap = current_kboard->Voverriding_terminal_local_map;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 if (NILP (keymap))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 keymap = Voverriding_local_map;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1116 strlength = XSTRING_LENGTH (string);
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
1117 bsize = ITEXT_ZTERM_SIZE + strlength;
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 1849
diff changeset
1118 buf = xnew_ibytes (bsize);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 bufp = buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 /* Have to reset strdata every time GC might be called */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1122 strdata = XSTRING_DATA (string);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 for (idx = 0; idx < strlength; )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
1125 Ibyte *strp = strdata + idx;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 if (strp[0] != '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 /* just copy other chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 /* As it happens, this will work with Mule even if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 character quoted is multi-byte; the remaining multi-byte
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 characters will just be copied by this loop. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 *bufp++ = *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 idx++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 else switch (strp[1])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 /* just copy unknown escape sequences */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 *bufp++ = *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 idx++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 case '=':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 /* \= quotes the next character;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 thus, to put in \[ without its special meaning, use \=\[. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 /* As it happens, this will work with Mule even if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 character quoted is multi-byte; the remaining multi-byte
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 characters will just be copied by this loop. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 changed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 *bufp++ = strp[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 idx += 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 case '[':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 changed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 idx += 2; /* skip \[ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 strp += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 start = strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 while ((idx < strlength)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 && *strp != ']')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 strp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 idx++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 length = strp - start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 idx++; /* skip ] */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 tem = Fintern (make_string (start, length), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 tem = Fwhere_is_internal (tem, keymap, Qt, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 #if 0 /* FSFmacs */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1177 /* Disregard menu bar bindings; it is positively annoying to
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1178 mention them when there's no menu bar, and it isn't terribly
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1179 useful even when there is a menu bar. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1180 if (!NILP (tem))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1181 {
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1182 firstkey = Faref (tem, Qzero);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1183 if (EQ (firstkey, Qmenu_bar))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1184 tem = Qnil;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1185 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 if (NILP (tem)) /* but not on any keys */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1190 new_ = (Ibyte *) xrealloc (buf, bsize += 4);
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1191 bufp += new_ - buf;
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1192 buf = new_;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 memcpy (bufp, "M-x ", 4);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 bufp += 4;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 goto subst;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 { /* function is on a key */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 tem = Fkey_description (tem);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 goto subst_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 case '<':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1206 Lisp_Object buffer = Fget_buffer_create (QSsubstitute);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1207 struct buffer *buf_ = XBUFFER (buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 Fbuffer_disable_undo (buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 Ferase_buffer (buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 /* \{foo} is replaced with a summary of keymap (symbol-value foo).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 \<foo> just sets the keymap used for \[cmd]. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 changed = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 idx += 2; /* skip \{ or \< */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 strp += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 start = strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 while ((idx < strlength)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 && *strp != '}' && *strp != '>')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 strp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 idx++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 length = strp - start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 idx++; /* skip } or > */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 /* Get the value of the keymap in TEM, or nil if undefined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 Do this while still in the user's current buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 in case it is a local variable. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 name = Fintern (make_string (start, length), Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 tem = Fboundp (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 if (! NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 tem = Fsymbol_value (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 if (! NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 tem = get_keymap (tem, 0, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 if (NILP (tem))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 {
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
1242 buffer_insert_ascstring (buf_, "(uses keymap \"");
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1243 buffer_insert_lisp_string (buf_, Fsymbol_name (name));
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4952
diff changeset
1244 buffer_insert_ascstring (buf_, "\", which is not currently defined) ");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 if (start[-1] == '<') keymap = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 else if (start[-1] == '<')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 keymap = tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 describe_map_tree (tem, 1, Qnil, Qnil, 0, buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 tem = make_string_from_buffer (buf_, BUF_BEG (buf_),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 BUF_Z (buf_) - BUF_BEG (buf_));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 Ferase_buffer (buffer);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1256 }
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1257 goto subst_string;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1259 subst_string:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1260 start = XSTRING_DATA (tem);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1261 length = XSTRING_LENGTH (tem);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1262 subst:
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1263 bsize += length;
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1264 new_ = (Ibyte *) xrealloc (buf, bsize);
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1265 bufp += new_ - buf;
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2367
diff changeset
1266 buf = new_;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1267 memcpy (bufp, start, length);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1268 bufp += length;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1270 /* Reset STRDATA in case gc relocated it. */
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1271 strdata = XSTRING_DATA (string);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1273 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 if (changed) /* don't bother if nothing substituted */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 tem = make_string (buf, bufp - buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 else
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1280 tem = string;
4976
16112448d484 Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
1281 xfree (buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 return tem;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 syms_of_doc (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 {
3368
959746c534f6 [xemacs-hg @ 2006-04-29 16:15:21 by aidan]
aidan
parents: 3025
diff changeset
1294 DEFSUBR (Fbuilt_in_symbol_file);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 DEFSUBR (Fdocumentation);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 DEFSUBR (Fdocumentation_property);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 DEFSUBR (Fsnarf_documentation);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 DEFSUBR (Fverify_documentation);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 DEFSUBR (Fsubstitute_command_keys);
4367
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
1300
69e6352406f0 Handle macros, autoloads correctly in symbol-file. Add an incomplete TYPE arg.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3548
diff changeset
1301 DEFSYMBOL (Qdefvar);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 vars_of_doc (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 DEFVAR_LISP ("internal-doc-file-name", &Vinternal_doc_file_name /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 Name of file containing documentation strings of built-in symbols.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 Vinternal_doc_file_name = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4539
diff changeset
1312 QSsubstitute = build_ascstring (" *substitute*");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 staticpro (&QSsubstitute);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 }