emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/doc.c


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/src/doc.c
Date: Mon, 01 Apr 2002 18:04:47 -0500

Index: emacs/src/doc.c
diff -c emacs/src/doc.c:1.90 emacs/src/doc.c:1.91
*** emacs/src/doc.c:1.90        Wed Feb  6 18:00:52 2002
--- emacs/src/doc.c     Mon Apr  1 18:04:46 2002
***************
*** 106,111 ****
--- 106,115 ----
     (A negative integer is used for user variables, so we can distinguish
     them without actually fetching the doc string.)
  
+    If the location does not point to the beginning of a docstring
+    (e.g. because the file has been modified and the location is stale),
+    return nil.
+ 
     If UNIBYTE is nonzero, always make a unibyte string.
  
     If DEFINITION is nonzero, assume this is for reading
***************
*** 188,194 ****
      }
  
    /* Seek only to beginning of disk block.  */
!   offset = position % (8 * 1024);
    if (0 > lseek (fd, position - offset, 0))
      {
        emacs_close (fd);
--- 192,200 ----
      }
  
    /* Seek only to beginning of disk block.  */
!   /* Make sure we read at least 1024 bytes before `position'
!      so we can check the leading text for consistency.  */
!   offset = min (position, max (1024, position % (8 * 1024)));
    if (0 > lseek (fd, position - offset, 0))
      {
        emacs_close (fd);
***************
*** 246,251 ****
--- 252,281 ----
      }
    emacs_close (fd);
  
+   /* Sanity checking.  */
+   if (CONSP (filepos))
+     {
+       int test = 1;
+       if (get_doc_string_buffer[offset - test++] != ' ')
+       return Qnil;
+       while (get_doc_string_buffer[offset - test] >= '0'
+            && get_doc_string_buffer[offset - test] <= '9')
+       test++;
+       if (get_doc_string_buffer[offset - test++] != '@'
+         || get_doc_string_buffer[offset - test] != '#')
+       return Qnil;
+     }
+   else
+     {
+       int test = 1;
+       if (get_doc_string_buffer[offset - test++] != '\n')
+       return Qnil;
+       while (get_doc_string_buffer[offset - test] > ' ')
+       test++;
+       if (get_doc_string_buffer[offset - test] != '\037')
+       return Qnil;
+     }
+ 
    /* Scan the text and perform quoting with ^A (char code 1).
       ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_.  */
    from = get_doc_string_buffer + offset;
***************
*** 305,310 ****
--- 335,360 ----
    return get_doc_string (filepos, 0, 1);
  }
  
+ static void
+ reread_doc_file (file)
+ {
+   Lisp_Object reply, prompt[3];
+   struct gcpro gcpro1;
+   GCPRO1 (file);
+   prompt[0] = build_string ("File ");
+   prompt[1] = NILP (file) ? Vdoc_file_name : file;
+   prompt[2] = build_string (" is out-of-sync.  Reload? ");
+   reply = Fy_or_n_p (Fconcat (3, prompt));
+   UNGCPRO;
+   if (NILP (reply))
+     error ("Aborted");
+ 
+   if (NILP (file))
+     Fsnarf_documentation (Vdoc_file_name);
+   else
+     Fload (file, Qt, Qt, Qt, Qnil);
+ }
+ 
  DEFUN ("documentation", Fdocumentation, Sdocumentation, 1, 2, 0,
         doc: /* Return the documentation string of FUNCTION.
  Unless a non-nil second argument RAW is given, the
***************
*** 384,390 ****
      }
  
    if (INTEGERP (doc) || CONSP (doc))
!     doc = get_doc_string (doc, 0, 0);
  
    if (NILP (raw))
      doc = Fsubstitute_command_keys (doc);
--- 434,454 ----
      }
  
    if (INTEGERP (doc) || CONSP (doc))
!     {
!       Lisp_Object tem;
!       tem = get_doc_string (doc, 0, 0);
!       if (NILP (tem))
!       {
!         /* The file is newer, we need to reset the pointers.  */
!         struct gcpro gcpro1, gcpro2;
!         GCPRO2 (function, raw);
!         reread_doc_file (Fcar_safe (doc));
!         UNGCPRO;
!         return Fdocumentation (function, raw);
!       }
!       else
!       doc = tem;
!     }
  
    if (NILP (raw))
      doc = Fsubstitute_command_keys (doc);
***************
*** 407,413 ****
  
    tem = Fget (symbol, prop);
    if (INTEGERP (tem) || (CONSP (tem) && INTEGERP (XCDR (tem))))
!     tem = get_doc_string (tem, 0, 0);
    else if (!STRINGP (tem))
      /* Feval protects its argument.  */
      tem = Feval (tem);
--- 471,489 ----
  
    tem = Fget (symbol, prop);
    if (INTEGERP (tem) || (CONSP (tem) && INTEGERP (XCDR (tem))))
!     {
!       Lisp_Object doc = tem;
!       tem = get_doc_string (tem, 0, 0);
!       if (NILP (tem))
!       {
!         /* 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));
!         UNGCPRO;
!         return Fdocumentation_property (symbol, prop, raw);
!       }
!     }
    else if (!STRINGP (tem))
      /* Feval protects its argument.  */
      tem = Feval (tem);
***************
*** 480,501 ****
    Lisp_Object sym;
    char *name;
  
- #ifndef CANNOT_DUMP
-   if (NILP (Vpurify_flag))
-     error ("Snarf-documentation can only be called in an undumped Emacs");
- #endif
- 
    CHECK_STRING (filename);
  
  #ifndef CANNOT_DUMP
!   name = (char *) alloca (XSTRING (filename)->size + 14);
!   strcpy (name, "../etc/");
  #else /* CANNOT_DUMP */
!   CHECK_STRING (Vdoc_directory);
!   name = (char *) alloca (XSTRING (filename)->size
!                         + XSTRING (Vdoc_directory)->size + 1);
!   strcpy (name, XSTRING (Vdoc_directory)->data);
  #endif /* CANNOT_DUMP */
    strcat (name, XSTRING (filename)->data);    /*** Add this line ***/
  #ifdef VMS
  #ifndef VMS4_4
--- 556,580 ----
    Lisp_Object sym;
    char *name;
  
    CHECK_STRING (filename);
  
+   if
  #ifndef CANNOT_DUMP
!     (!NILP (Vpurify_flag))
  #else /* CANNOT_DUMP */
!       (0)
  #endif /* CANNOT_DUMP */
+     {
+       name = (char *) alloca (XSTRING (filename)->size + 14);
+       strcpy (name, "../etc/");
+     }
+   else
+     {
+       CHECK_STRING (Vdoc_directory);
+       name = (char *) alloca (XSTRING (filename)->size
+                         + XSTRING (Vdoc_directory)->size + 1);
+       strcpy (name, XSTRING (Vdoc_directory)->data);
+     }
    strcat (name, XSTRING (filename)->data);    /*** Add this line ***/
  #ifdef VMS
  #ifndef VMS4_4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]