Fix speedbar highlighting bug.
[bpt/emacs.git] / src / doc.c
index eb8ff3c..02db4dd 100644 (file)
--- a/src/doc.c
+++ b/src/doc.c
@@ -1,5 +1,5 @@
 /* Record indices of function doc strings stored in a file.
-   Copyright (C) 1985-1986, 1993-1995, 1997-2011
+   Copyright (C) 1985-1986, 1993-1995, 1997-2012
                  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -116,14 +116,16 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
      If it is relative, combine it with Vdoc_directory.  */
 
   tem = Ffile_name_absolute_p (file);
+  file = ENCODE_FILE (file);
   if (NILP (tem))
     {
-      minsize = SCHARS (Vdoc_directory);
+      Lisp_Object docdir = ENCODE_FILE (Vdoc_directory);
+      minsize = SCHARS (docdir);
       /* sizeof ("../etc/") == 8 */
       if (minsize < 8)
        minsize = 8;
       name = (char *) alloca (minsize + SCHARS (file) + 8);
-      strcpy (name, SSDATA (Vdoc_directory));
+      strcpy (name, SSDATA (docdir));
       strcat (name, SSDATA (file));
     }
   else
@@ -138,7 +140,7 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
       if (!NILP (Vpurify_flag))
        {
          /* Preparing to dump; DOC file is probably not installed.
-            So check in ../etc. */
+            So check in ../etc.  */
          strcpy (name, "../etc/");
          strcat (name, SSDATA (file));
 
@@ -166,19 +168,19 @@ get_doc_string (Lisp_Object filepos, int unibyte, int definition)
   p = get_doc_string_buffer;
   while (1)
     {
-      ptrdiff_t space_left = (get_doc_string_buffer_size
+      ptrdiff_t space_left = (get_doc_string_buffer_size - 1
                              - (p - get_doc_string_buffer));
       int nread;
 
       /* Allocate or grow the buffer if we need to.  */
-      if (space_left == 0)
+      if (space_left <= 0)
        {
          ptrdiff_t in_buffer = p - get_doc_string_buffer;
          get_doc_string_buffer =
            xpalloc (get_doc_string_buffer, &get_doc_string_buffer_size,
                     16 * 1024, -1, 1);
          p = get_doc_string_buffer + in_buffer;
-         space_left = (get_doc_string_buffer_size
+         space_left = (get_doc_string_buffer_size - 1
                        - (p - get_doc_string_buffer));
        }
 
@@ -500,10 +502,12 @@ aren't strings.  */)
 /* Scanning the DOC files and placing docstring offsets into functions.  */
 
 static void
-store_function_docstring (Lisp_Object fun, EMACS_INT offset)
+store_function_docstring (Lisp_Object obj, EMACS_INT offset)
 /* Use EMACS_INT because we get offset from pointer subtraction.  */
 {
-  fun = indirect_function (fun);
+  /* Don't use indirect_function here, or defaliases will apply their
+     docstrings to the base functions (Bug#2603).  */
+  Lisp_Object fun = SYMBOLP (obj) ? XSYMBOL (obj)->function : obj;
 
   /* The type determines where the docstring is stored.  */