changeset 44348:80c9e94bec17

(reread_doc_file): Return whether reload was attempted. (Fdocumentation, Fdocumentation_property): Don't try to reload if the doc is 0 and only ask once.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 02 Apr 2002 21:58:39 +0000
parents 3822c9623366
children dba5b0b03cc5
files src/doc.c
diffstat 1 files changed, 29 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/doc.c	Tue Apr 02 21:30:29 2002 +0000
+++ b/src/doc.c	Tue Apr 02 21:58:39 2002 +0000
@@ -335,7 +335,7 @@
   return get_doc_string (filepos, 0, 1);
 }
 
-static void
+static int
 reread_doc_file (file)
 {
   Lisp_Object reply, prompt[3];
@@ -347,12 +347,14 @@
   reply = Fy_or_n_p (Fconcat (3, prompt));
   UNGCPRO;
   if (NILP (reply))
-    error ("Aborted");
+    return 0;
 
   if (NILP (file))
     Fsnarf_documentation (Vdoc_file_name);
   else
     Fload (file, Qt, Qt, Qt, Qnil);
+
+  return 1;
 }
 
 DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0,
@@ -365,6 +367,9 @@
   Lisp_Object fun;
   Lisp_Object funcar;
   Lisp_Object tem, doc;
+  int try_reload = 1;
+
+ documentation:
 
   doc = Qnil;
   
@@ -433,18 +438,24 @@
       Fsignal (Qinvalid_function, Fcons (fun, Qnil));
     }
 
-  if (INTEGERP (doc) || CONSP (doc))
+  /* If DOC is 0, it's typically because of a dumped file missing
+     from the DOC file (bug in src/Makefile.in).  */
+  if (INTEGERP (doc) && !EQ (tem, make_number (0)) || CONSP (doc))
     {
       Lisp_Object tem;
       tem = get_doc_string (doc, 0, 0);
-      if (NILP (tem))
+      if (NILP (tem) && try_reload)
 	{
 	  /* The file is newer, we need to reset the pointers.  */
 	  struct gcpro gcpro1, gcpro2;
 	  GCPRO2 (function, raw);
-	  reread_doc_file (Fcar_safe (doc));
+	  try_reload = reread_doc_file (Fcar_safe (doc));
 	  UNGCPRO;
-	  return Fdocumentation (function, raw);
+	  if (try_reload)
+	    {
+	      try_reload = 0;
+	      goto documentation;
+	    }
 	}
       else
 	doc = tem;
@@ -467,21 +478,29 @@
   (symbol, prop, raw)
      Lisp_Object symbol, prop, raw;
 {
+  int try_reload = 1;
   Lisp_Object tem;
 
+ documentation_property:
+  
   tem = Fget (symbol, prop);
-  if (INTEGERP (tem) || (CONSP (tem) && INTEGERP (XCDR (tem))))
+  if (INTEGERP (tem) && !EQ (tem, make_number (0))
+      || (CONSP (tem) && INTEGERP (XCDR (tem))))
     {
       Lisp_Object doc = tem;
       tem = get_doc_string (tem, 0, 0);
-      if (NILP (tem))
+      if (NILP (tem) && try_reload)
 	{
 	  /* The file is newer, we need to reset the pointers.  */
 	  struct gcpro gcpro1, gcpro2, gcpro3;
 	  GCPRO3 (symbol, prop, raw);
-	  reread_doc_file (Fcar_safe (doc));
+	  try_reload = reread_doc_file (Fcar_safe (doc));
 	  UNGCPRO;
-	  return Fdocumentation_property (symbol, prop, raw);
+	  if (try_reload)
+	    {
+	      try_reload = 0;
+	      goto documentation_property;
+	    }
 	}
     }
   else if (!STRINGP (tem))