diff src/minibuf.c @ 6384:5e8a442a836d

(read_minibuf): Disallow trailing junk.
author Karl Heuer <kwzh@gnu.org>
date Wed, 16 Mar 1994 22:44:00 +0000
parents a74524e1c961
children 7491cbb3d1a3
line wrap: on
line diff
--- a/src/minibuf.c	Wed Mar 16 22:14:23 1994 +0000
+++ b/src/minibuf.c	Wed Mar 16 22:44:00 1994 +0000
@@ -293,7 +293,17 @@
 
   /* If Lisp form desired instead of string, parse it. */
   if (expflag)
-    val = Fread (val);
+    {
+      Lisp_Object expr_and_pos;
+      unsigned char *p;
+
+      expr_and_pos = Fread_from_string (val, Qnil, Qnil);
+      /* Ignore trailing whitespace; any other trailing junk is an error.  */
+      for (p = XSTRING (val)->data + XINT (Fcdr (expr_and_pos)); *p; p++)
+	if (*p != ' ' && *p != '\t' && *p != '\n')
+	  error ("Trailing garbage following expression");
+      val = Fcar (expr_and_pos);
+    }
 
   unbind_to (count, Qnil);	/* The appropriate frame will get selected
 				   in set-window-configuration.  */