static void store_function_docstring (Lisp_Object obj, ptrdiff_t offset) { /* Don't use indirect_function here, or defaliases will apply their docstrings to the base functions (Bug#2603). */ Lisp_Object fun = SYMBOLP (obj) ? XSYMBOL (obj)->function : obj; /* The type determines where the docstring is stored. */ /* Lisp_Subrs have a slot for it. */ if (SUBRP (fun)) { intptr_t negative_offset = - offset; XSUBR (fun)->doc = (char *) negative_offset; } /* If it's a lisp form, stick it in the form. */ else if (CONSP (fun)) { Lisp_Object tem; tem = XCAR (fun); if (EQ (tem, Qlambda) || EQ (tem, Qautoload) || (EQ (tem, Qclosure) && (fun = XCDR (fun), 1))) { tem = Fcdr (Fcdr (fun)); if (CONSP (tem) && INTEGERP (XCAR (tem))) /* FIXME: This modifies typically pure hash-cons'd data, so its correctness is quite delicate. */ XSETCAR (tem, make_number (offset)); } else if (EQ (tem, Qmacro)) store_function_docstring (XCDR (fun), offset); } /* Bytecode objects sometimes have slots for it. */ else if (COMPILEDP (fun)) { /* This bytecode object must have a slot for the docstring, since we've found a docstring for it. */ if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING) ASET (fun, COMPILED_DOC_STRING, make_number (offset)); else { AUTO_STRING (format, "No docstring slot for %s"); CALLN (Fmessage, format, (SYMBOLP (obj) ? SYMBOL_NAME (obj) : build_string ("<anonymous>"))); } } }
static void store_function_docstring (Lisp_Object obj, EMACS_INT offset) /* Use EMACS_INT because we get offset from pointer subtraction. */ { /* Don't use indirect_function here, or defaliases will apply their docstrings to the base functions (Bug#2603). */ Lisp_Object fun = SYMBOLP (obj) ? XSYMBOL (obj)->function : obj; /* The type determines where the docstring is stored. */ /* Lisp_Subrs have a slot for it. */ if (SUBRP (fun)) { intptr_t negative_offset = - offset; XSUBR (fun)->doc = (char *) negative_offset; } /* If it's a lisp form, stick it in the form. */ else if (CONSP (fun)) { Lisp_Object tem; tem = XCAR (fun); if (EQ (tem, Qlambda) || EQ (tem, Qautoload) || (EQ (tem, Qclosure) && (fun = XCDR (fun), 1))) { tem = Fcdr (Fcdr (fun)); if (CONSP (tem) && INTEGERP (XCAR (tem))) XSETCAR (tem, make_number (offset)); } else if (EQ (tem, Qmacro)) store_function_docstring (XCDR (fun), offset); } /* Bytecode objects sometimes have slots for it. */ else if (COMPILEDP (fun)) { /* This bytecode object must have a slot for the docstring, since we've found a docstring for it. */ if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING) ASET (fun, COMPILED_DOC_STRING, make_number (offset)); } }