Subject: Re: bug#63722: 29.0.91; (elisp) Skip to end #@00 does not work

From: Eli Zaretskii <[email-masked]>
Date: Thu, 25 May 2023 21:44:28 +0300

> From: richard newton <[email-masked]>
> Date: Thu, 25 May 2023 16:19:42 +0200
> 
> With emacs 29.0.91 pretest, the "skip to end" syntax #@00 no longer seems to work. For example,
> with the three lines below in a buffer (eval-buffer) gives the error - End of file during parsing. With
> previous emacs versions it did not complain.
> 
> (setq testStr "zz")
> #@00
> should be ignored

Thanks.

Mattias, this is due to commit b903507b36, which fixed bug#55676.  It
introduced a subtle change in the behavior of read0 in this case.

Does the below look like the correct way of fixing this regression?

diff --git a/src/lread.c b/src/lread.c
index 342d367..6ee2829 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3400,8 +3400,9 @@ read_bool_vector (Lisp_Object readcharfun)
 }
 
 /* Skip (and optionally remember) a lazily-loaded string
-   preceded by "#@".  */
-static void
+   preceded by "#@".  Return non-zero if we skip to EOB,
+   otherwise zero.  */
+static bool
 skip_lazy_string (Lisp_Object readcharfun)
 {
   ptrdiff_t nskip = 0;
@@ -3429,7 +3430,7 @@ skip_lazy_string (Lisp_Object readcharfun)
 	{
 	  /* #@00 means "skip to end" */
 	  skip_dyn_eof (readcharfun);
-	  return;
+	  return true;
 	}
     }
 
@@ -3476,6 +3477,8 @@ skip_lazy_string (Lisp_Object readcharfun)
   else
     /* Skip that many bytes.  */
     skip_dyn_bytes (readcharfun, nskip);
+
+  return false;
 }
 
 /* Given a lazy-loaded string designator VAL, return the actual string.
@@ -3933,7 +3936,8 @@ read0 (Lisp_Object readcharfun, bool locate_syms)
 	    /* #@NUMBER is used to skip NUMBER following bytes.
 	       That's used in .elc files to skip over doc strings
 	       and function definitions that can be loaded lazily.  */
-	    skip_lazy_string (readcharfun);
+	    if (skip_lazy_string (readcharfun))
+	      return unbind_to (base_pdl, Qnil);
 	    goto read_obj;
 
 	  case '$':