From 91f68422d65d4fe746e4cd89cd274636a097c4ff Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Wed, 29 Apr 2009 03:02:54 +0000 Subject: [PATCH] * 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. --- etc/NEWS | 4 ++++ lisp/ChangeLog | 6 ++++++ lisp/files.el | 12 ++++++++---- src/ChangeLog | 5 +++++ src/lread.c | 11 +++++++++-- 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index de3464ede22..a1246837c3e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1930,6 +1930,10 @@ port support (see Emacs changes, above). ** Miscellaneous new variables ++++ +*** `read-circle', if nil, disables the reading of recursive Lisp +structures using the #N= and #N# syntax. + +++ *** `this-command-keys-shift-translated' is non-nil if the key sequence invoking the current command was found by shift-translation. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8d7881c1aa1..c93996b6ef0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2009-04-29 Ulrich Mueller + + * files.el (hack-local-variables-prop-line) + (hack-local-variables, dir-locals-read-from-file): Bind + read-circle to nil before reading. + 2009-04-28 Geert Kloosterman (tiny change) * progmodes/which-func.el (which-function): Don't assume that diff --git a/lisp/files.el b/lisp/files.el index b14ccc2be5c..7b7c438df3c 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2898,7 +2898,8 @@ and VAL is the specified value." (let ((key (intern (match-string 1))) (val (save-restriction (narrow-to-region (point) end) - (read (current-buffer))))) + (let ((read-circle nil)) + (read (current-buffer)))))) ;; It is traditional to ignore ;; case when checking for `mode' in set-auto-mode, ;; so we must do that here as well. @@ -3044,12 +3045,14 @@ is specified, returning t if it is specified." (if (eolp) (error "Missing colon in local variables entry")) (skip-chars-backward " \t") (let* ((str (buffer-substring beg (point))) - (var (read str)) + (var (let ((read-circle nil)) + (read str))) val) ;; Read the variable value. (skip-chars-forward "^:") (forward-char 1) - (setq val (read (current-buffer))) + (let ((read-circle nil)) + (setq val (read (current-buffer)))) (if mode-only (if (eq var 'mode) (setq result t)) @@ -3348,7 +3351,8 @@ is found. Returns the new class name." (insert-file-contents file) (let* ((dir-name (file-name-directory file)) (class-name (intern dir-name)) - (variables (read (current-buffer)))) + (variables (let ((read-circle nil)) + (read (current-buffer))))) (dir-locals-set-class-variables class-name variables) (dir-locals-set-directory-class dir-name class-name (nth 5 (file-attributes file))) diff --git a/src/ChangeLog b/src/ChangeLog index d47f354ba6a..760795f1870 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-04-29 Ulrich Mueller + + * lread.c (Vread_circle): New variable. + (read1): Disable recursive read if Vread_circle is nil. + 2009-04-29 Kenichi Handa * fontset.h (set_default_ascii_font): Delete extern. diff --git a/src/lread.c b/src/lread.c index 8a4b96874ce..cb3f5b04633 100644 --- a/src/lread.c +++ b/src/lread.c @@ -125,6 +125,9 @@ Lisp_Object Vload_file_name; /* 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 @@ read1 (readcharfun, pch, first_in_list) 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 @@ read1 (readcharfun, pch, first_in_list) 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 @@ read multiple times. The list is in the same order as the symbols 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). -- 2.39.2