# HG changeset patch # User Jim Blandy # Date 723680186 0 # Node ID ef09501a0a9b31c328c6174716e28610561f1274 # Parent 60a49bc9673a8cd3a2f8b95087e0d358334b2d08 * 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. diff -r 60a49bc9673a -r ef09501a0a9b src/doc.c --- a/src/doc.c Sun Dec 06 22:16:01 1992 +0000 +++ b/src/doc.c Sun Dec 06 22:16:26 1992 +0000 @@ -202,6 +202,51 @@ return tem; } +/* Scanning the DOC files and placing docstring offsets into functions. */ + +static void +store_function_docstring (fun, offset) + Lisp_Object fun; + int offset; +{ + fun = indirect_function (fun); + + /* The type determines where the docstring is stored. */ + + /* Lisp_Subrs have a slot for it. */ + if (XTYPE (fun) == Lisp_Subr) + XSUBR (fun)->doc = (char *) - offset; + + /* If it's a lisp form, stick it in the form. */ + else if (CONSP (fun)) + { + Lisp_Object tem; + + tem = XCONS (fun)->car; + if (EQ (tem, Qlambda) || EQ (tem, Qautoload)) + { + tem = Fcdr (Fcdr (fun)); + if (CONSP (tem) && + XTYPE (XCONS (tem)->car) == Lisp_Int) + XFASTINT (XCONS (tem)->car) = offset; + } + else if (EQ (tem, Qmacro)) + store_function_docstring (XCONS (fun)->cdr, offset); + } + + /* Bytecode objects sometimes have slots for it. */ + else if (XTYPE (fun) == Lisp_Compiled) + { + /* This bytecode object must have a slot for the + docstring, since we've found a docstring for it. */ + if (XVECTOR (fun)->size <= COMPILED_DOC_STRING) + abort (); + + XFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING]) = offset; + } +} + + DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation, 1, 1, 0, "Used during Emacs initialization, before dumping runnable Emacs,\n\ @@ -292,42 +337,12 @@ * (end[1] == '*' ? -1 : 1))); } - /* Attach a docstring to a function? The type determines where - the docstring is stored. */ + /* Attach a docstring to a function? */ else if (p[1] == 'F') - { - fun = XSYMBOL (sym)->function; - - /* Lisp_Subrs have a slot for it. */ - if (XTYPE (fun) == Lisp_Subr) - XSUBR (fun)->doc = (char *) - (pos + end + 1 - buf); + store_function_docstring (sym, pos + end + 1 - buf); - /* If it's a lisp form, stick it in the form. */ - else if (CONSP (fun)) - { - tem = XCONS (fun)->car; - if (EQ (tem, Qlambda) || EQ (tem, Qautoload)) - { - tem = Fcdr (Fcdr (fun)); - if (CONSP (tem) && - XTYPE (XCONS (tem)->car) == Lisp_Int) - XFASTINT (XCONS (tem)->car) = (pos + end + 1 - buf); - } - } - - /* Bytecode objects sometimes have slots for it. */ - else if (XTYPE (fun) == Lisp_Compiled) - { - /* This bytecode object must have a slot for the - docstring, since we've found a docstring for it. */ - if (XVECTOR (fun)->size <= COMPILED_DOC_STRING) - abort (); - - XFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING]) - = pos + end + 1 - buf; - } - } - else error ("DOC file invalid at position %d", pos); + else + error ("DOC file invalid at position %d", pos); } } pos += end - buf;