diff --git a/doc/generic/pgf/CHANGELOG.md b/doc/generic/pgf/CHANGELOG.md index 3f5b2e53c..b12f67ccf 100644 --- a/doc/generic/pgf/CHANGELOG.md +++ b/doc/generic/pgf/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Treat varargs for `min()` and `max()` in `luamath` pgf library pgf-tikz/pgfplots#492 #1359 - Fixed support for the `\tikz` command in the `dvisvgm4ht` driver for TeX4ht - Wrong key name in unknown decoration option error #1082 +- `gnuplot` was always run when the function contained leading or trailing spaces #1397 ### Changed diff --git a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex index d9b1743b9..8868d5d7f 100644 --- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex +++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex @@ -3365,7 +3365,8 @@ \def\tikz@plot@function unction#1{% \def\tikz@plot@filename{\tikz@plot@prefix\tikz@plot@id}% \iftikz@plot@raw@gnuplot% - \def\tikz@plot@data{\pgfplotgnuplot[\tikz@plot@filename]{#1}}% + \def\tikz@plot@data{% + \pgfplotgnuplot[\tikz@plot@filename]{\pgfutil@trimspaces@e{#1}}}% \else% \iftikz@plot@parametric% \def\tikz@plot@data{\pgfplotgnuplot[\tikz@plot@filename]{% @@ -3374,13 +3375,13 @@ plot [t=\tikz@plot@domain] [\tikz@plot@xrange] [\tikz@plot@range] - #1}}% + \pgfutil@trimspaces@e{#1}}}% \else% \def\tikz@plot@data{\pgfplotgnuplot[\tikz@plot@filename]{% set samples \tikz@plot@samples; plot [x=\tikz@plot@domain] \ifx\tikz@plot@range\pgfutil@empty\else[\tikz@plot@range]\fi - #1}}% + \pgfutil@trimspaces@e{#1}}}% \fi% \fi% \tikz@@@plot% diff --git a/tex/generic/pgf/modules/pgfmoduleplot.code.tex b/tex/generic/pgf/modules/pgfmoduleplot.code.tex index 5135d4eec..4dbaa14f0 100644 --- a/tex/generic/pgf/modules/pgfmoduleplot.code.tex +++ b/tex/generic/pgf/modules/pgfmoduleplot.code.tex @@ -481,6 +481,8 @@ \pgfutilpreparefilename{#1.table}% \let\pgf@plottablefile=\pgfretval \let\pgf@plottablefile@quoted=\pgfretvalquoted + \begingroup + \endlinechar=-1 % suppress white space at end % Check, whether it is up-to-date \openin\pgfutil@inputcheck=\pgf@plotgnuplotfile\relax \ifeof\pgfutil@inputcheck% @@ -488,7 +490,7 @@ \pgfutil@read\pgfutil@inputcheck to\pgf@temp% ignored \pgfutil@read\pgfutil@inputcheck to\pgf@plot@line% \closein\pgfutil@inputcheck - \edef\pgf@plot@code{#2\space}% + \edef\pgf@plot@code{\pgfutil@trimspaces@e{#2}}% \ifx\pgf@plot@code\pgf@plot@line% \openin\pgfutil@inputcheck=\pgfretval\relax \ifeof\pgfutil@inputcheck% @@ -501,11 +503,12 @@ \ifpgf@resample@plot% \immediate\openout\pgf@plotwrite=\pgf@plotgnuplotfile\relax \immediate\pgfutil@write\pgf@plotwrite{\pgf@gnuplot@head}% - \immediate\pgfutil@write\pgf@plotwrite{#2}% + \immediate\pgfutil@write\pgf@plotwrite{\pgf@plot@code}% \immediate\closeout\pgf@plotwrite% \pgfutil@shellescape{% \pgfkeysvalueof{/pgf/plot/gnuplot call} \pgf@plotgnuplotfile}% \fi% + \endgroup % \let\pgf@savedparsexyline=\pgf@parsexyline% % \let\pgf@parsexyline=\pgf@parsegnuplotxyline% \pgfplotxyfile{\pgf@plottablefile}% diff --git a/tex/generic/pgf/utilities/pgfutil-common.tex b/tex/generic/pgf/utilities/pgfutil-common.tex index 1bf2e247a..66c6fd015 100644 --- a/tex/generic/pgf/utilities/pgfutil-common.tex +++ b/tex/generic/pgf/utilities/pgfutil-common.tex @@ -49,6 +49,10 @@ \def\pgfutil@trimspaces@@#1Q#2{#1} \catcode`\Q=11 +\def\pgfutil@trimspaces@e#1{% + \expandafter\pgfutil@trimspaces\expandafter{\pgfutil@expanded{#1}}% +} + % \pgfutil@ifx{}{}{}{} % % This macro is expandable.