aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1992-12-06 22:16:26 +0000
committerJim Blandy1992-12-06 22:16:26 +0000
commit283e1184f3b57400d7e97033eb82218f375e16ff (patch)
treec379bfdb57c39b2319159adfb165667a9092f6e0 /src
parentf76e7178ee500726e88718cd73d596798d6b0c47 (diff)
downloademacs-283e1184f3b57400d7e97033eb82218f375e16ff.tar.gz
emacs-283e1184f3b57400d7e97033eb82218f375e16ff.zip
* doc.c (store_function_docstring): New function, made from part
of Fsnarf_documentation, which handles docstrings for macros properly. (Fsnarf_documentation): Call store_function_docstring.
Diffstat (limited to 'src')
-rw-r--r--src/doc.c85
1 files changed, 50 insertions, 35 deletions
diff --git a/src/doc.c b/src/doc.c
index 36f04a4a1e2..13c261bb495 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -202,6 +202,51 @@ translation.")
202 return tem; 202 return tem;
203} 203}
204 204
205/* Scanning the DOC files and placing docstring offsets into functions. */
206
207static void
208store_function_docstring (fun, offset)
209 Lisp_Object fun;
210 int offset;
211{
212 fun = indirect_function (fun);
213
214 /* The type determines where the docstring is stored. */
215
216 /* Lisp_Subrs have a slot for it. */
217 if (XTYPE (fun) == Lisp_Subr)
218 XSUBR (fun)->doc = (char *) - offset;
219
220 /* If it's a lisp form, stick it in the form. */
221 else if (CONSP (fun))
222 {
223 Lisp_Object tem;
224
225 tem = XCONS (fun)->car;
226 if (EQ (tem, Qlambda) || EQ (tem, Qautoload))
227 {
228 tem = Fcdr (Fcdr (fun));
229 if (CONSP (tem) &&
230 XTYPE (XCONS (tem)->car) == Lisp_Int)
231 XFASTINT (XCONS (tem)->car) = offset;
232 }
233 else if (EQ (tem, Qmacro))
234 store_function_docstring (XCONS (fun)->cdr, offset);
235 }
236
237 /* Bytecode objects sometimes have slots for it. */
238 else if (XTYPE (fun) == Lisp_Compiled)
239 {
240 /* This bytecode object must have a slot for the
241 docstring, since we've found a docstring for it. */
242 if (XVECTOR (fun)->size <= COMPILED_DOC_STRING)
243 abort ();
244
245 XFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING]) = offset;
246 }
247}
248
249
205DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation, 250DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation,
206 1, 1, 0, 251 1, 1, 0,
207 "Used during Emacs initialization, before dumping runnable Emacs,\n\ 252 "Used during Emacs initialization, before dumping runnable Emacs,\n\
@@ -292,42 +337,12 @@ when doc strings are referred to later in the dumped Emacs.")
292 * (end[1] == '*' ? -1 : 1))); 337 * (end[1] == '*' ? -1 : 1)));
293 } 338 }
294 339
295 /* Attach a docstring to a function? The type determines where 340 /* Attach a docstring to a function? */
296 the docstring is stored. */
297 else if (p[1] == 'F') 341 else if (p[1] == 'F')
298 { 342 store_function_docstring (sym, pos + end + 1 - buf);
299 fun = XSYMBOL (sym)->function; 343
300 344 else
301 /* Lisp_Subrs have a slot for it. */ 345 error ("DOC file invalid at position %d", pos);
302 if (XTYPE (fun) == Lisp_Subr)
303 XSUBR (fun)->doc = (char *) - (pos + end + 1 - buf);
304
305 /* If it's a lisp form, stick it in the form. */
306 else if (CONSP (fun))
307 {
308 tem = XCONS (fun)->car;
309 if (EQ (tem, Qlambda) || EQ (tem, Qautoload))
310 {
311 tem = Fcdr (Fcdr (fun));
312 if (CONSP (tem) &&
313 XTYPE (XCONS (tem)->car) == Lisp_Int)
314 XFASTINT (XCONS (tem)->car) = (pos + end + 1 - buf);
315 }
316 }
317
318 /* Bytecode objects sometimes have slots for it. */
319 else if (XTYPE (fun) == Lisp_Compiled)
320 {
321 /* This bytecode object must have a slot for the
322 docstring, since we've found a docstring for it. */
323 if (XVECTOR (fun)->size <= COMPILED_DOC_STRING)
324 abort ();
325
326 XFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING])
327 = pos + end + 1 - buf;
328 }
329 }
330 else error ("DOC file invalid at position %d", pos);
331 } 346 }
332 } 347 }
333 pos += end - buf; 348 pos += end - buf;