diff src/doc.c @ 22562:ddb3fd464b77

(get_doc_string): 2nd arg is now DEFINITION; if non-nil, read a dynamic function definition. (read_doc_string): Don't call read here.
author Richard M. Stallman <rms@gnu.org>
date Wed, 24 Jun 1998 04:11:00 +0000
parents 9308a15aa8f8
children 9c6b3b9c3c8f
line wrap: on
line diff
--- a/src/doc.c	Wed Jun 24 02:41:08 1998 +0000
+++ b/src/doc.c	Wed Jun 24 04:11:00 1998 +0000
@@ -83,12 +83,15 @@
    (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 @@
 	*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 @@
 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,