Skip to content

Commit a4774c9

Browse files
committed
fix: check if .gnuplot is up-to-date in a more reliable way
Fixes #1397 Signed-off-by: Yukai Chou <[email protected]>
1 parent 757f4c2 commit a4774c9

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

doc/generic/pgf/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2222
- Treat varargs for `min()` and `max()` in `luamath` pgf library pgf-tikz/pgfplots#492 #1359
2323
- Fixed support for the `\tikz` command in the `dvisvgm4ht` driver for TeX4ht
2424
- Wrong key name in unknown decoration option error #1082
25+
- `gnuplot` is always run when the function contains leading or trailing spaces #1397
2526

2627
### Changed
2728

tex/generic/pgf/frontendlayer/tikz/tikz.code.tex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,7 +3365,8 @@
33653365
\def\tikz@plot@function unction#1{%
33663366
\def\tikz@plot@filename{\tikz@plot@prefix\tikz@plot@id}%
33673367
\iftikz@plot@raw@gnuplot%
3368-
\def\tikz@plot@data{\pgfplotgnuplot[\tikz@plot@filename]{#1}}%
3368+
\def\tikz@plot@data{%
3369+
\pgfplotgnuplot[\tikz@plot@filename]{\pgfutil@trimspaces{#1}}}%
33693370
\else%
33703371
\iftikz@plot@parametric%
33713372
\def\tikz@plot@data{\pgfplotgnuplot[\tikz@plot@filename]{%
@@ -3374,13 +3375,13 @@
33743375
plot [t=\tikz@plot@domain]
33753376
[\tikz@plot@xrange]
33763377
[\tikz@plot@range]
3377-
#1}}%
3378+
\pgfutil@trimspaces{#1}}}%
33783379
\else%
33793380
\def\tikz@plot@data{\pgfplotgnuplot[\tikz@plot@filename]{%
33803381
set samples \tikz@plot@samples;
33813382
plot [x=\tikz@plot@domain]
33823383
\ifx\tikz@plot@range\pgfutil@empty\else[\tikz@plot@range]\fi
3383-
#1}}%
3384+
\pgfutil@trimspaces{#1}}}%
33843385
\fi%
33853386
\fi%
33863387
\tikz@@@plot%

tex/generic/pgf/modules/pgfmoduleplot.code.tex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,14 +481,16 @@
481481
\pgfutilpreparefilename{#1.table}%
482482
\let\pgf@plottablefile=\pgfretval
483483
\let\pgf@plottablefile@quoted=\pgfretvalquoted
484+
\begingroup
485+
\endlinechar=-1 % suppress white space at end
484486
% Check, whether it is up-to-date
485487
\openin\pgfutil@inputcheck=\pgf@plotgnuplotfile\relax
486488
\ifeof\pgfutil@inputcheck%
487489
\else%
488490
\pgfutil@read\pgfutil@inputcheck to\pgf@temp% ignored
489491
\pgfutil@read\pgfutil@inputcheck to\pgf@plot@line%
490492
\closein\pgfutil@inputcheck
491-
\edef\pgf@plot@code{#2\space}%
493+
\edef\pgf@plot@code{#2}%
492494
\ifx\pgf@plot@code\pgf@plot@line%
493495
\openin\pgfutil@inputcheck=\pgfretval\relax
494496
\ifeof\pgfutil@inputcheck%
@@ -501,11 +503,12 @@
501503
\ifpgf@resample@plot%
502504
\immediate\openout\pgf@plotwrite=\pgf@plotgnuplotfile\relax
503505
\immediate\pgfutil@write\pgf@plotwrite{\pgf@gnuplot@head}%
504-
\immediate\pgfutil@write\pgf@plotwrite{#2}%
506+
\immediate\pgfutil@write\pgf@plotwrite{\pgf@plot@code}%
505507
\immediate\closeout\pgf@plotwrite%
506508
\pgfutil@shellescape{%
507509
\pgfkeysvalueof{/pgf/plot/gnuplot call} \pgf@plotgnuplotfile}%
508510
\fi%
511+
\endgroup
509512
% \let\pgf@savedparsexyline=\pgf@parsexyline%
510513
% \let\pgf@parsexyline=\pgf@parsegnuplotxyline%
511514
\pgfplotxyfile{\pgf@plottablefile}%

0 commit comments

Comments
 (0)