From: Richard M. Stallman Date: Wed, 24 Jun 1998 04:11:00 +0000 (+0000) Subject: (get_doc_string): 2nd arg is now DEFINITION; X-Git-Tag: emacs-20.3~517 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f1df0d6764fd9192212a7805d2fe120572d60eb8;p=emacs.git (get_doc_string): 2nd arg is now DEFINITION; if non-nil, read a dynamic function definition. (read_doc_string): Don't call read here. --- diff --git a/src/doc.c b/src/doc.c index 8ca7670cc15..aacddc7bb38 100644 --- a/src/doc.c +++ b/src/doc.c @@ -83,12 +83,15 @@ static int get_doc_string_buffer_size; (A negative integer is used for user variables, so we can distinguish them without actually fetching the doc string.) - If UNIBYTE is nonzero, always return the result as a unibyte string. */ + If DEFINITION is nonzero, assume this is for reading + a dynamic function definition; convert the bytestring + and the constants vector with appropriate byte handling, + and return a cons cell. */ Lisp_Object -get_doc_string (filepos, unibyte) +get_doc_string (filepos, definition) Lisp_Object filepos; - int unibyte; + int definition; { char *from, *to; register int fd; @@ -242,12 +245,39 @@ get_doc_string (filepos, unibyte) *to++ = *from++; } - if (unibyte) - return make_unibyte_string (get_doc_string_buffer + offset, - to - (get_doc_string_buffer + offset)); - else - return make_string (get_doc_string_buffer + offset, - to - (get_doc_string_buffer + offset)); + if (definition) + { + char *p = get_doc_string_buffer + offset; + char *start_ptr; + Lisp_Object bytestring, vector; + + if (*p++ != '(') + return Qnil; + start_ptr = p; + if (*p++ != '"') + return Qnil; + while (*p != '"') + { + if (*p == '\\') + p++; + p++; + } + p++; + bytestring = Fread (make_unibyte_string (start_ptr, p - start_ptr)); + if (*p++ != ' ') + return Qnil; + if (*p++ != '.') + return Qnil; + if (*p++ != ' ') + return Qnil; + if (to[-1] != ')') + return Qnil; + vector = Fread (make_string (p, to - p - 1)); + return Fcons (bytestring, vector); + } + + return make_string (get_doc_string_buffer + offset, + to - (get_doc_string_buffer + offset)); } /* Get a string from position FILEPOS and pass it through the Lisp reader. @@ -258,7 +288,7 @@ Lisp_Object read_doc_string (filepos) Lisp_Object filepos; { - return Fread (get_doc_string (filepos, 1)); + return get_doc_string (filepos, 1); } DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0,