diff src/lread.c @ 103101:58c92ec0c915

* files.el (hack-local-variables-prop-line) (hack-local-variables, dir-locals-read-from-file): Bind read-circle to nil before reading. * lread.c (Vread_circle): New variable. (read1): Disable recursive read if Vread_circle is nil.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 29 Apr 2009 03:02:54 +0000
parents 245a1f77b840
children b426d08d0ba3
line wrap: on
line diff
--- a/src/lread.c	Wed Apr 29 01:42:51 2009 +0000
+++ b/src/lread.c	Wed Apr 29 03:02:54 2009 +0000
@@ -125,6 +125,9 @@
 /* Function to use for reading, in `load' and friends.  */
 Lisp_Object Vload_read_function;
 
+/* Non-nil means read recursive structures using #n= and #n# syntax.  */
+Lisp_Object Vread_circle;
+
 /* The association list of objects read with the #n=object form.
    Each member of the list has the form (n . object), and is used to
    look up the object for the corresponding #n# construct.
@@ -2558,7 +2561,7 @@
 	      c = READCHAR;
 	    }
 	  /* #n=object returns object, but associates it with n for #n#.  */
-	  if (c == '=')
+	  if (c == '=' && !NILP (Vread_circle))
 	    {
 	      /* Make a placeholder for #n# to use temporarily */
 	      Lisp_Object placeholder;
@@ -2580,7 +2583,7 @@
 	      return tem;
 	    }
 	  /* #n# returns a previously read object.  */
-	  if (c == '#')
+	  if (c == '#' && !NILP (Vread_circle))
 	    {
 	      tem = Fassq (make_number (n), read_objects);
 	      if (CONSP (tem))
@@ -4215,6 +4218,10 @@
 were read in. */);
   Vread_symbol_positions_list = Qnil;
 
+  DEFVAR_LISP ("read-circle", &Vread_circle,
+	       doc: /* Non-nil means read recursive structures using #N= and #N# syntax.  */);
+  Vread_circle = Qt;
+
   DEFVAR_LISP ("load-path", &Vload_path,
 	       doc: /* *List of directories to search for files to load.
 Each element is a string (directory name) or nil (try default directory).