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: reset \tikz@expandcount more frequent #969 #970

Merged
merged 5 commits into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
\def\tikz@lib@cal@calendar{%
\begingroup%
\let\tikz@lib@cal@ifs=\pgfutil@empty%
\tikz@expandcount=1000\relax%
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1000 seemed really excessive. It was probably set to 1000 because it would never be reset.

\tikz@resetexpandcount
\tikzset{name=,at={(0,0)}}%
\let\%=\pgfcalendarshorthand%
\tikzset{every calendar/.try}%
Expand All @@ -370,27 +370,13 @@
}

\def\tikz@lib@cal@handle{%
\let\pgfutil@next=\tikz@lib@cal@expand%
\ifx\pgf@let@token;%
\let\pgfutil@next=\tikz@lib@cal@stop%
\else%
\ifx\pgf@let@token(%)
\let\pgfutil@next=\tikz@lib@cal@name%
\else%
\ifx\pgf@let@token a%
\let\pgfutil@next=\tikz@lib@cal@at%
\else%
\ifx\pgf@let@token[%
\let\pgfutil@next=\tikz@lib@cal@option%
\else%
\ifx\pgf@let@token i%
\let\pgfutil@next=\tikz@lib@cal@if%
\fi%
\fi%
\fi%
\fi%
\fi%
\pgfutil@next%
\pgfutil@switch\pgfutil@ifx\pgf@let@token{%
{;}{\tikz@lib@cal@stop}%
{(}{\tikz@lib@cal@name}%)
{a}{\tikz@lib@cal@at}%
{[}{\tikz@lib@cal@option}%]
{i}{\tikz@lib@cal@if}%
}{}{\tikz@resetexpandcount\tikz@lib@cal@expand}%
}
\def\tikz@lib@cal@expand{%
\advance\tikz@expandcount by -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
\pgftransformcm{\pgf@lib@svg@a}{\pgf@lib@svg@b}{\pgf@lib@svg@c}{\pgf@lib@svg@d}{\pgfpointorigin}%
}
}]{};
\expandafter\pgfutil@switch\expandafter{\tikz@anchor}{%
\expandafter\pgfutil@switch\expandafter\pgfutil@ifstrequal\expandafter{\tikz@anchor}{%
{north} {\def\tikz@spy@anchor{south}}%
{north east}{\def\tikz@spy@anchor{south west}}%
{east} {\def\tikz@spy@anchor{west}}%
Expand All @@ -106,9 +106,7 @@
{south west}{\def\tikz@spy@anchor{north east}}%
{west} {\def\tikz@spy@anchor{east}}%
{north west}{\def\tikz@spy@anchor{south east}}%
% default to center
{default} {\def\tikz@spy@anchor{center}}%
}
}{}{\def\tikz@spy@anchor{center}}%
\node [alias=tikzspyinnode,inner sep=0pt,outer sep=0pt,at={#2},every spy in node/.try,
path picture={\node[anchor=\tikz@spy@anchor,tikz@lib@reset@gs]{\nullfont%
\pgfpicture\relax\pgfsetbaseline{default}\pgfsettrimleft{default}\pgfsettrimright{default}%
Expand Down
155 changes: 36 additions & 119 deletions tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2105,7 +2105,7 @@
\tikz@snakedfalse%
\tikz@decoratepathfalse%
\tikz@node@is@a@labelfalse%
\tikz@expandcount=100\relax%
\tikz@resetexpandcount
\pgf@path@lastx=0pt%
\pgf@path@lasty=0pt%
\tikz@lastx=0pt%
Expand All @@ -2123,125 +2123,42 @@
\afterassignment\tikz@handle\let\pgf@let@token=%
}%
\newcount\tikz@expandcount
\def\tikz@resetexpandcount{\tikz@expandcount=100\relax}
\let\tikz@collected@onpath=\pgfutil@empty%

\edef\tikz@frozen@relax@token{\ifnum0=0\fi}

% Central dispatcher for commands
\def\tikz@handle{%
\let\pgfutil@next=\tikz@expand%
\ifx\pgf@let@token(%)
\let\pgfutil@next=\tikz@movetoabs%
\else%
\ifx\pgf@let@token+%
\let\pgfutil@next=\tikz@movetorel%
\else%
\ifx\pgf@let@token-%
\let\pgfutil@next=\tikz@lineto%
\else%
\ifx\pgf@let@token.%
\let\pgfutil@next=\tikz@dot%
\else%
\ifx\pgf@let@token r%
\let\pgfutil@next=\tikz@rect%
\else%
\ifx\pgf@let@token n%
\let\pgfutil@next=\tikz@fig%
\else%
\ifx\pgf@let@token[%]
\let\pgfutil@next=\tikz@parse@options%
\else%
\ifx\pgf@let@token c%
\let\pgfutil@next=\tikz@cchar%
\else%
\ifx\pgf@let@token\bgroup%
\let\pgfutil@next=\tikz@beginscope%
\else%
\ifx\pgf@let@token\egroup%
\let\pgfutil@next=\tikz@endscope%
\else%
\ifx\pgf@let@token;%
\let\pgfutil@next=\tikz@finish%
\else%
\let\pgfutil@next=\tikz@handle@more%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\pgfutil@next%
}%

% Continued...
\def\tikz@handle@more{%
\ifx\pgf@let@token a%
\let\pgfutil@next=\tikz@a@char%
\else%
\ifx\pgf@let@token e%
\let\pgfutil@next=\tikz@e@char%
\else%
\ifx\pgf@let@token g%
\let\pgfutil@next=\tikz@g@char%
\else%
\ifx\pgf@let@token s%
\let\pgfutil@next=\tikz@schar%
\else%
\ifx\pgf@let@token |%
\let\pgfutil@next=\tikz@vh@lineto%
\else%
\ifx\pgf@let@token p%
\let\pgfutil@next=\tikz@pchar%
\pgfsetmovetofirstplotpoint%
\else%
\ifx\pgf@let@token t%
\let\pgfutil@next=\tikz@to%
\else%
\ifx\pgf@let@token\pgfextra%
\let\pgfutil@next=\tikz@extra%
\else%
\ifx\pgf@let@token\foreach%
\let\pgfutil@next=\tikz@foreach%
\else%
\ifx\pgf@let@token f%
\let\pgfutil@next=\tikz@fchar%
\else%
\ifx\pgf@let@token\pgf@stop%
\let\pgfutil@next=\relax%
\else%
\ifx\pgf@let@token\par%
\let\pgfutil@next=\tikz@scan@next@command%
\else%
\ifx\pgf@let@token d%
\let\pgfutil@next=\tikz@decoration%
\else%
\ifx\pgf@let@token l%
\let\pgfutil@next=\tikz@l@char%
\else%
\ifx\pgf@let@token:%
\let\pgfutil@next=\tikz@colon@char%
\else%
\let\pgfutil@next=\tikz@expand%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\fi%
\ifx\pgfutil@next\tikz@expand\else\tikz@expandcount=100\relax\fi%
\pgfutil@next%
\pgfutil@switch\pgfutil@ifx\pgf@let@token{%
{(}{\tikz@movetoabs}%)
{+}{\tikz@movetorel}%
{-}{\tikz@lineto}%
{.}{\tikz@dot}%
{r}{\tikz@rect}%
{n}{\tikz@fig}%
{[}{\tikz@parse@options}%]
{c}{\tikz@cchar}%
{\bgroup}{\tikz@beginscope}%
{\egroup}{\tikz@endscope}%
{;}{\tikz@finish}%
{a}{\tikz@a@char}%
{e}{\tikz@e@char}%
{g}{\tikz@g@char}%
{s}{\tikz@schar}%
{|}{\tikz@vh@lineto}%
{p}{\pgfsetmovetofirstplotpoint\tikz@pchar}%
{t}{\tikz@to}%
{\pgfextra}{\tikz@extra}%
{\foreach}{\tikz@foreach}%
{f}{\tikz@fchar}%
{\pgf@stop}{\relax}%
{\par}{\tikz@scan@next@command}%
{d}{\tikz@decoration}%
{l}{\tikz@l@char}%
{:}{\tikz@colon@char}%
{\relax}{\relax\tikz@scan@next@command}%
}{}{\tikz@resetexpandcount\tikz@expand}%
muzimuzhi marked this conversation as resolved.
Show resolved Hide resolved
}%

\def\tikz@l@char{%
Expand Down Expand Up @@ -4754,8 +4671,8 @@
\expandafter\expandafter\expandafter\tikz@parse@child@node%
\fi%
}%
\def\tikz@parse@child@node@rest#1\pgf@stop{\tikz@expandcount=100\relax\def\tikz@child@node@rest{#1}}%
\def\tikz@parse@child@node@c c{\tikz@expandcount=100\pgfutil@ifnextchar o{\tikz@parse@child@node@co}{\tikz@parse@child@node@rest c}}%
\def\tikz@parse@child@node@rest#1\pgf@stop{\tikz@resetexpandcount\def\tikz@child@node@rest{#1}}%
\def\tikz@parse@child@node@c c{\tikz@resetexpandcount\pgfutil@ifnextchar o{\tikz@parse@child@node@co}{\tikz@parse@child@node@rest c}}%
\def\tikz@parse@child@node@co o{\pgfutil@ifnextchar o{\tikz@parse@child@node@coordinate}{\tikz@parse@child@node@rest co}}%
\def\tikz@parse@child@node@coordinate ordinate{%
\pgfutil@ifnextchar ({\tikz@@parse@child@node@coordinate}{%
Expand All @@ -4777,7 +4694,7 @@
\expandafter\expandafter\expandafter{\expandafter\tikz@child@node@text@pre\tikz@marshal}%
\tikz@parse@child@node@rest%
}%
\def\tikz@parse@child@node@n node{\tikz@expandcount=100%
\def\tikz@parse@child@node@n node{\tikz@resetexpandcount%
\let\tikz@child@node@text=\pgfutil@empty%
\tikz@p@c@s}%
\def\tikz@p@c@s{%
Expand Down
25 changes: 24 additions & 1 deletion tex/generic/pgf/systemlayer/pgfsys.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,30 @@
% inserted into the resulting .pdf/.ps/.xxx file.



% String comparison
\ifdefined\pdfstrcmp
\let\pgfsys@strcmp\pdfstrcmp
\else\ifdefined\strcmp
\let\pgfsys@strcmp\strcmp
\else\ifdefined\directlua
\directlua{
local lft = lua.get_functions_table()
lft[\string#lft+1] = function()
local lhs = token.scan_string()
local rhs = token.scan_string()
if lhs < rhs then
tex.sprint(-2, "-1")
elseif lhs == rhs then
tex.sprint(-2, "0")
else
tex.sprint(-2, "1")
end
end
token.set_lua("pgfsys@strcmp", \string#lft, "global")
}
\else
\def\pgfsys@strcmp#1#2{\pgf@sys@fail{string comparison}}%
\fi\fi\fi


% Discern the driver:
Expand Down
Loading