Skip to content

Commit

Permalink
Merge pull request #967 from muzimuzhi/handle-relax
Browse files Browse the repository at this point in the history
Handle \relax and frozen \relax in tikz path
  • Loading branch information
hmenke authored Dec 22, 2020
2 parents ad06895 + 43b4544 commit defb816
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
\pgfutil@next%
}
\def\tikz@lib@cal@expand{%
\advance\tikz@expandcount by -1%
\advance\tikz@expandcount by -1
\ifnum\tikz@expandcount<0\relax%
\tikzerror{Giving up on this calendar}%
\let\pgfutil@next=\tikz@lib@cal@end%
Expand Down
39 changes: 30 additions & 9 deletions tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2120,10 +2120,15 @@
\else%
\tikz@invoke@collected@onpath%
\fi%
\afterassignment\tikz@handle\let\pgf@let@token=%
\tikz@scan@@next@command
}%
\def\tikz@scan@@next@command{%
\afterassignment\tikz@handle\let\pgf@let@token=%
}

\newcount\tikz@expandcount
\let\tikz@collected@onpath=\pgfutil@empty%
\edef\tikz@frozen@relax@token{\ifnum0=0\fi}

% Central dispatcher for commands
\def\tikz@handle{%
Expand Down Expand Up @@ -2224,7 +2229,7 @@
\ifx\pgf@let@token:%
\let\pgfutil@next=\tikz@colon@char%
\else%
\let\pgfutil@next=\tikz@expand%
\let\pgfutil@next=\tikz@handle@evenmore
\fi%
\fi%
\fi%
Expand All @@ -2240,10 +2245,26 @@
\fi%
\fi%
\fi%
\ifx\pgfutil@next\tikz@expand\else\tikz@expandcount=100\relax\fi%
\pgfutil@next%
}%

% Continued...
\def\tikz@handle@evenmore{%
% if \pgf@let@token is \relax or frozen \relax, skip it and
% scan from the next token
\ifx\pgf@let@token\relax
\let\pgfutil@next=\tikz@scan@@next@command
\else
\ifx\pgf@let@token\tikz@frozen@relax@token
\let\pgfutil@next=\tikz@scan@@next@command
\else
\let\pgfutil@next=\tikz@expand
\fi
\fi
\ifx\pgfutil@next\tikz@expand\else\tikz@expandcount=100\relax\fi
\pgfutil@next
}

\def\tikz@l@char{%
\pgfutil@ifnextchar e{\tikz@let@command}{%
\pgfutil@ifnextchar i{\tikz@lsystem}{%
Expand Down Expand Up @@ -2566,7 +2587,7 @@

\def\tikz@skip#1{\tikz@scan@next@command#1}%
\def\tikz@expand{%
\advance\tikz@expandcount by -1%
\advance\tikz@expandcount by -1
\ifnum\tikz@expandcount<0\relax%
\tikzerror{Giving up on this path. Did you forget a semicolon?}%
\let\pgfutil@next=\tikz@finish%
Expand Down Expand Up @@ -2939,7 +2960,7 @@
% -| <point>

\def\tikz@hv@lineto{%
\pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@hv@lineto}{
\pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@hv@lineto}{%
\pgfutil@ifnextchar p{\tikz@collect@pic@onpath\tikz@hv@lineto}%
{\pgfutil@ifnextchar c{\tikz@collect@coordinate@onpath\tikz@hv@lineto}%
{\tikz@scan@one@point{\tikz@@hv@lineto}}}}}%
Expand Down Expand Up @@ -3204,13 +3225,13 @@
\let\tikz@collected@onpath=\pgfutil@empty%
\tikz@edgetoparentcollect%
}%
\def\tikz@edgetoparentcollect{
\def\tikz@edgetoparentcollect{%
\pgfutil@ifnextchar n{\tikz@collect@label@onpath\tikz@edgetoparentcollect}%
{%
\expandafter%
\endgroup%
\expandafter\tikz@edgetoparent@rollout\expandafter{\tikz@collected@onpath}%
}
}%
}%
\def\tikz@edgetoparent@rollout#1{%
Expand Down Expand Up @@ -3840,7 +3861,7 @@
% A label text always ``ends'' the node.
%
\def\tikz@fig ode{%
\pgfutil@ifnextchar a\tikz@test@also{
\pgfutil@ifnextchar a\tikz@test@also{%
\pgfutil@ifnextchar f{\tikz@nodes@start}\tikz@normal@fig}}%
\def\tikz@test@also a{\pgfutil@ifnextchar l\tikz@node@also{\tikz@normal@fig a}}%
\def\tikz@normal@fig{%
Expand Down Expand Up @@ -5240,7 +5261,7 @@
\def\tikz@scan@absolute#1{%
\pgfutil@ifnextchar({\tikz@scan@@absolute#1}%)
{%
\advance\tikz@expandcount by -1%
\advance\tikz@expandcount by -1
\ifnum\tikz@expandcount<0\relax%
\let\pgfutil@next=\tikz@@scangiveup%
\else%
Expand Down

0 comments on commit defb816

Please sign in to comment.