Skip to content

Commit

Permalink
Fix \peek_analysis_map_inline:n for not-expanded tokens (fix #1113)
Browse files Browse the repository at this point in the history
When followed by an implicit special token, the code saves the
next token using \futurelet, then stringifies the first token and
collects characters until hitting the saved next token.  If that
token was in a "notexpanded" state then the collection loop never
terminated.  Now fixed by simply running \futurelet twice to get
rid of the "notexpanded" state.  One could conceivably want to
keep track of it and restore it.
  • Loading branch information
blefloch committed Oct 3, 2022
1 parent 24f7188 commit 34bf477
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions l3kernel/CHANGELOG.md
Expand Up @@ -13,8 +13,9 @@ this project uses date-based 'snapshot' version identifiers.

### Fixed
- `\peek_analysis_map_inline:n` support for macro parameter characters (issue
[\#1109](https://github.com/latex3/latex3/issues/1109)) and for many
expandable tokens (issue [\#1110](https://github.com/latex3/latex3/issues/1110))
[\#1109](https://github.com/latex3/latex3/issues/1109)), for many expandable
tokens (issue [\#1110](https://github.com/latex3/latex3/issues/1110)), and an
esoteric case (issue [\#1113](https://github.com/latex3/latex3/issues/1113))

## [2022-09-28]

Expand Down
10 changes: 9 additions & 1 deletion l3kernel/l3tl-analysis.dtx
Expand Up @@ -1183,7 +1183,8 @@
% \@@_peek_analysis_nonexp:N, \@@_peek_analysis_cs:N,
% \@@_peek_analysis_char:N, \@@_peek_analysis_char:w,
% \@@_peek_analysis_special:, \@@_peek_analysis_retest:,
% \@@_peek_analysis_next:, \@@_peek_analysis_str:,
% \@@_peek_analysis_next:, \@@_peek_analysis_nextii:,
% \@@_peek_analysis_str:,
% \@@_peek_analysis_str:w, \@@_peek_analysis_str:n,
% \@@_peek_analysis_active_str:n, \@@_peek_analysis_explicit:n,
% \@@_peek_analysis_escape:, \@@_peek_analysis_collect:w,
Expand Down Expand Up @@ -1420,6 +1421,8 @@
% active character with the same character code as its meaning or as
% the escape character). Now look at the \meta{next token} following
% it using a combination of \tn{afterassignment} and \tn{futurelet}.
% (In fact look twice to reset an internal \TeX{} flag in case the
% \meta{next token} had been hit with \cs{exp_not:N}.)
% The syntax of this primitive is \tn{futurelet} \meta{peek token}
% \meta{first token} \meta{next token}, and it sets \meta{peek token}
% equal to \meta{next token}. Traditionally, one takes \meta{first
Expand All @@ -1436,6 +1439,11 @@
{
\tl_if_empty:oT { \tex_the:D \tex_everyeof:D }
{ \tex_everyeof:D { \scan_stop: } }
\tex_afterassignment:D \@@_peek_analysis_nextii:
\tex_futurelet:D \l_@@_analysis_next_token
}
\cs_new_protected:Npn \@@_peek_analysis_nextii:
{
\tex_afterassignment:D \@@_peek_analysis_str:
\tex_futurelet:D \l_@@_analysis_next_token
}
Expand Down

0 comments on commit 34bf477

Please sign in to comment.