changeset 41823:e192139240f2

(Fsnarf_documentation): Add prototype. (get_doc_string): Handle negative arguments. (Fdocumentation): Use AREF and ASIZE. Move the calls to get_doc_string to a single place. Don't confuse an interactive-spec for a docstring reference. (Fdocumentation_property): Take advantage of the fact that get_doc_string now ignores the sign of the docstring position.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 05 Dec 2001 01:47:27 +0000
parents 50b6bc7ee607
children 9fc96faea7e7
files src/doc.c
diffstat 1 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/doc.c	Wed Dec 05 01:39:21 2001 +0000
+++ b/src/doc.c	Wed Dec 05 01:47:27 2001 +0000
@@ -81,6 +81,7 @@
 static int get_doc_string_buffer_size;
 
 static unsigned char *read_bytecode_pointer;
+Lisp_Object Fsnarf_documentation P_ ((Lisp_Object));
 
 /* readchar in lread.c calls back here to fetch the next byte.
    If UNREADFLAG is 1, we unread a byte.  */
@@ -134,12 +135,13 @@
     {
       file = XCAR (filepos);
       position = XINT (XCDR (filepos));
-      if (position < 0)
-	position = - position;
     }
   else
     return Qnil;
 
+  if (position < 0)
+    position = - position;
+
   if (!STRINGP (Vdoc_directory))
     return Qnil;
 
@@ -329,18 +331,17 @@
       else if ((EMACS_INT) XSUBR (fun)->doc >= 0)
 	doc = build_string (XSUBR (fun)->doc);
       else
-	doc = get_doc_string (make_number (- (EMACS_INT) XSUBR (fun)->doc),
-			      0, 0);
+	doc = make_number ((EMACS_INT) XSUBR (fun)->doc);
     }
   else if (COMPILEDP (fun))
     {
-      if ((XVECTOR (fun)->size & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING)
+      if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) <= COMPILED_DOC_STRING)
 	return Qnil;
-      tem = XVECTOR (fun)->contents[COMPILED_DOC_STRING];
+      tem = AREF (fun, COMPILED_DOC_STRING);
       if (STRINGP (tem))
 	doc = tem;
       else if (NATNUMP (tem) || CONSP (tem))
-	doc = get_doc_string (tem, 0, 0);
+	doc = tem;
       else
 	return Qnil;
     }
@@ -365,9 +366,9 @@
 	    doc = tem;
 	  /* Handle a doc reference--but these never come last
 	     in the function body, so reject them if they are last.  */
-	  else if ((NATNUMP (tem) || CONSP (tem))
-		   && ! NILP (XCDR (tem1)))
-	    doc = get_doc_string (tem, 0, 0);
+	  else if ((NATNUMP (tem) || (CONSP (tem) && INTEGERP (XCDR (tem))))
+		   && !NILP (XCDR (tem1)))
+	    doc = tem;
 	  else
 	    return Qnil;
 	}
@@ -384,6 +385,9 @@
       Fsignal (Qinvalid_function, Fcons (fun, Qnil));
     }
 
+  if (INTEGERP (doc) || CONSP (doc))
+    doc = get_doc_string (doc, 0, 0);
+
   if (NILP (raw))
     doc = Fsubstitute_command_keys (doc);
   return doc;
@@ -404,9 +408,7 @@
   Lisp_Object tem;
 
   tem = Fget (symbol, prop);
-  if (INTEGERP (tem))
-    tem = get_doc_string (XINT (tem) > 0 ? tem : make_number (- XINT (tem)), 0, 0);
-  else if (CONSP (tem) && INTEGERP (XCDR (tem)))
+  if (INTEGERP (tem) || (CONSP (tem) && INTEGERP (XCDR (tem))))
     tem = get_doc_string (tem, 0, 0);
   else if (!STRINGP (tem))
     /* Feval protects its argument.  */
@@ -454,8 +456,8 @@
     {
       /* This bytecode object must have a slot for the
 	 docstring, since we've found a docstring for it.  */
-      if ((XVECTOR (fun)->size & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING)
-	XSETFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING], offset);
+      if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING)
+	XSETFASTINT (AREF (fun, COMPILED_DOC_STRING), offset);
     }
 }