Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tikz should reset \tikz@expandcount more frequent #969

Closed
muzimuzhi opened this issue Dec 28, 2020 · 0 comments · Fixed by #970
Closed

tikz should reset \tikz@expandcount more frequent #969

muzimuzhi opened this issue Dec 28, 2020 · 0 comments · Fixed by #970

Comments

@muzimuzhi
Copy link
Member

muzimuzhi commented Dec 28, 2020

Brief outline of the bug

As discussed in #967 (comment), currently tikz never resets \tikz@expandcount when a token handled in \tikz@handle is encountered on a path. This will raise error Giving up on this path. Did you forget a semicolon? when too many steps of expansions are executed when scanning a path.

Minimal working example (MWE)

\documentclass{article}
\usepackage{tikz}

\makeatletter
% Token "r" is handled in \tikz@handle. 
% To show the problem, redefine its handler.
\let\tikz@rect\tikz@scan@next@command

\def\oneHundredExpansions{}
\def\oneExpansion{r}

\foreach \i in {1,...,101} { % 100 passes, 101 throws error
  \g@addto@macro\oneHundredExpansions{\oneExpansion}
}
\makeatother

\begin{document}
\begin{tikzpicture}
  % One handled "r" is encountered every two expansions, but the 
  % \tikz@expandcount is never reset until the 101st expansion throws an error.
  \draw (0,0) -- (1,1) \oneHundredExpansions;
\end{tikzpicture}
\end{document}
! Package tikz Error: Giving up on this path. Did you forget a semicolon?.

@Rmano
Note that in pgf 3.1.8 and 3.1.8a, tokens handled by \tikz@handler@more will not reset the count as well. In the above example, they are ( in (0, 0), - in --, and ( in (1, 1), hence \foreach \i in {1,...,98} is enough to trigger the error. See a therefore broken circuitikz example in #967 (comment).

muzimuzhi added a commit to muzimuzhi/pgf that referenced this issue Dec 28, 2020
This makes \tikz@expandcount get reset every time a token is handled
in tikz path scanning.
hmenke added a commit that referenced this issue Jan 4, 2021
tikz: reset \tikz@expandcount more frequent #969
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant