changeset 108161:514ebf69b289

Fix wrong-docstring problem introduced with hash-consing. * eval.c (Fautoload): Set doc to a unique number rather than to 0. Remove unused var `args'. * lisp.h (XSETCARFASTINT, XSETCDRFASTINT): Remove. (LOADHIST_ATTACH): Wrap with do...while to avoid surprises for callers. * doc.c (store_function_docstring): Use XSETCAR.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 29 Apr 2010 08:42:01 -0400
parents 7fc92f732328
children 3eb0fffdd08f
files src/ChangeLog src/ChangeLog.4 src/doc.c src/eval.c src/lisp.h
diffstat 5 files changed, 30 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Apr 28 18:27:54 2010 -0400
+++ b/src/ChangeLog	Thu Apr 29 08:42:01 2010 -0400
@@ -1,3 +1,12 @@
+2010-04-29  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	Fix wrong-docstring problem introduced with hash-consing.
+	* eval.c (Fautoload): Set doc to a unique number rather than to 0.
+	Remove unused var `args'.
+	* lisp.h (XSETCARFASTINT, XSETCDRFASTINT): Remove.
+	(LOADHIST_ATTACH): Wrap with do...while to avoid surprises for callers.
+	* doc.c (store_function_docstring): Use XSETCAR.
+
 2010-04-28  Glenn Morris  <rgm@gnu.org>
 
 	* Makefile.in (BASE_WINDOW_SUPPORT, X_WINDOW_SUPPORT): New variables.
--- a/src/ChangeLog.4	Wed Apr 28 18:27:54 2010 -0400
+++ b/src/ChangeLog.4	Thu Apr 29 08:42:01 2010 -0400
@@ -4329,7 +4329,7 @@
 
 1993-11-01  Richard Stallman  (rms@mole.gnu.ai.mit.edu)
 
-	* s/sunos4-1-3.h (HAVE_TERMIOS): Defined.
+	* s/sunos4-1-3.h (HAVE_TERMIOS): Define.
 
 1993-10-25  Brian J. Fox  (bfox@albert.gnu.ai.mit.edu)
 
@@ -4426,9 +4426,9 @@
 
 	* Makefile.in: File removed.  It is now generated by ../configure.
 
-	* Makefile.in.in (LIBES): Add $(GNULIB_VAR) again at end.  This
-	change to ymakefile was mysteriously lost.  Were any others lost
-	too?
+	* Makefile.in.in (LIBES): Add $(GNULIB_VAR) again at end.
+	This change to ymakefile was mysteriously lost.
+	Were any others lost too?
 
 1993-10-02  Brian J. Fox  (bfox@ai.mit.edu)
 
@@ -4461,8 +4461,7 @@
 
 1993-09-24  Brian J. Fox  (bfox@ai.mit.edu)
 
-	* textprop.c (validate_plist): Add declaration for `list'
-	argument.
+	* textprop.c (validate_plist): Add declaration for `list' argument.
 
 	* frame.c (Fhandle_switch_frame): Doc fix.
 
@@ -4501,7 +4500,7 @@
 	* doc.c (Fsubstitute_command_keys): Pass new arg.
 	* abbrev.c (Funexpand_abbrev, Fexpand_abbrev): Pass new arg.
 
-	* s/aix3-2.h (AIX3_2): Defined.
+	* s/aix3-2.h (AIX3_2): Define.
 	* m/ibmrs6000.h (LIBS_MACHINE): Include -lrts, -liconv only if AIX3_2.
 
 	* xterm.h (HAVE_X11R4): If AIX, do not define HAVE_X11R4.
@@ -4703,13 +4702,13 @@
 
 	* xfns.c (XScreenNumberOfScreen): New function.
 
-	* m/tek4300.h (C_DEBUG_SWITCH, SYSTEM_MALLOC): Defined.
+	* m/tek4300.h (C_DEBUG_SWITCH, SYSTEM_MALLOC): Define.
 
 	* m/iris4d.h (START_FILES, LIB_STANDARD): Don't define if USG5_4.
 	(DEFAULT_ENTRY_ADDRESS): Likewise.
 	(UNEXEC): Use unexelfsgi.o if USG5_4.
 
-	* s/irix5-0.h (C_SWITCH_MACHINE): Deleted.
+	* s/irix5-0.h (C_SWITCH_MACHINE): Delete.
 
 1993-08-13  Frederic Pierresteguy  (F.Pierresteguy@frcl.bull.fr)
 
@@ -4809,7 +4808,7 @@
 
 	* m/dpx2.h (HAVE_TCATTR): Macro #defined.
 	(HAVE_CLOSEDIR): #undef to allow use of closedir in sysdep.c.
-	(SIGTSTP): Commented #undef to allow use of ^Z in shell-mode.
+	(SIGTSTP): Comment #undef to allow use of ^Z in shell-mode.
 	(SIGNALS_VIA_CHARACTERS): #defined.
 
 1993-08-09  Paul Eggert  (eggert@twinsun.com)
@@ -4849,10 +4848,10 @@
 	and calculate position properly.
 
 	* s/bsd4-2.h, s/bsd4-3.h, s/umax.h, s/rtu.h, s/dgux.h (HAVE_VFORK):
-	Defined.
+	Define.
 
 	* ymakefile (alloc.o): Don't use DEBUG_MOLE.
-	(DEBUG_MOLE): Deleted.
+	(DEBUG_MOLE): Delete.
 	* gnu-hp300: File deleted.
 
 	* .gdbinit: Don't put -q in args.
@@ -4878,7 +4877,7 @@
 	(main): Call init_buffer, init_callproc and init_cmdargs
 	before init_lread.
 	(syms_of_emacs): Install the function, and protect the variable.
-	* lisp.h (Vinvocation_directory): Declared.
+	* lisp.h (Vinvocation_directory): Declare.
 	* lread.c (init_lread): Normally put Vinvocation_directory
 	at end of Vload_path, if not present already.
 
--- a/src/doc.c	Wed Apr 28 18:27:54 2010 -0400
+++ b/src/doc.c	Thu Apr 29 08:42:01 2010 -0400
@@ -538,7 +538,7 @@
 	{
 	  tem = Fcdr (Fcdr (fun));
 	  if (CONSP (tem) && INTEGERP (XCAR (tem)))
-	    XSETCARFASTINT (tem, offset);
+	    XSETCAR (tem, make_number (offset));
 	}
       else if (EQ (tem, Qmacro))
 	store_function_docstring (XCDR (fun), offset);
--- a/src/eval.c	Wed Apr 28 18:27:54 2010 -0400
+++ b/src/eval.c	Thu Apr 29 08:42:01 2010 -0400
@@ -2134,8 +2134,6 @@
      (function, file, docstring, interactive, type)
      Lisp_Object function, file, docstring, interactive, type;
 {
-  Lisp_Object args[4];
-
   CHECK_SYMBOL (function);
   CHECK_STRING (file);
 
@@ -2151,8 +2149,11 @@
     LOADHIST_ATTACH (Fcons (Qautoload, function));
   else
     /* We don't want the docstring in purespace (instead,
-       Snarf-documentation should (hopefully) overwrite it).  */
-    docstring = make_number (0);
+       Snarf-documentation should (hopefully) overwrite it).
+       We used to use 0 here, but that leads to accidental sharing in
+       purecopy's hash-consing, so we use a (hopefully) unique integer
+       instead.  */
+    docstring = make_number (XHASH (function));
   return Ffset (function,
 		Fpurecopy (list5 (Qautoload, file, docstring,
 				  interactive, type)));
--- a/src/lisp.h	Wed Apr 28 18:27:54 2010 -0400
+++ b/src/lisp.h	Thu Apr 29 08:42:01 2010 -0400
@@ -721,11 +721,6 @@
 #define XSETCAR(c,n) (XCAR_AS_LVALUE(c) = (n))
 #define XSETCDR(c,n) (XCDR_AS_LVALUE(c) = (n))
 
-/* For performance: Fast storage of positive integers into the
-   fields of a cons cell.  See above caveats.  */
-#define XSETCARFASTINT(c,n)  XSETFASTINT(XCAR_AS_LVALUE(c),(n))
-#define XSETCDRFASTINT(c,n)  XSETFASTINT(XCDR_AS_LVALUE(c),(n))
-
 /* Take the car or cdr of something whose type is not known.  */
 #define CAR(c)					\
  (CONSP ((c)) ? XCAR ((c))			\
@@ -2821,7 +2816,9 @@
 extern Lisp_Object make_symbol P_ ((char *));
 extern Lisp_Object oblookup P_ ((Lisp_Object, const char *, int, int));
 #define LOADHIST_ATTACH(x) \
- if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list)
+  do {									\
+    if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); \
+  } while (0)
 extern Lisp_Object Vcurrent_load_list;
 extern Lisp_Object Vload_history, Vload_suffixes, Vload_file_rep_suffixes;
 extern int openp P_ ((Lisp_Object, Lisp_Object, Lisp_Object,