Skip to content

Commit 1834fe8

Browse files
authored
Merge pull request #1412 from pgf-tikz/hotfix/pgf@plot@code
Correct the fix to trim spaces from `gnuplot` function
2 parents da81907 + ef6a38a commit 1834fe8

File tree

8 files changed

+130
-4
lines changed

8 files changed

+130
-4
lines changed

build.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ specialformats["latex"] = specialformats["latex"] or
3535
checkengines = {"pdftex", "latexdvips", "latexdvisvgm", "luatex", "xetex"}
3636

3737
-- Use multiple sets of tests
38-
checkconfigs = { "build", "config-gd", "config-manual" }
38+
checkconfigs = {
39+
"build",
40+
"config-gd",
41+
"config-manual",
42+
"config-shell",
43+
}
44+
45+
-- common testing support files
46+
checksuppfiles = {"pgf-regression-test.tex"}
3947

4048
-- For release
4149
ctanzip = "pgf.ctan.flatdir"

config-shell.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Tests which require shell escape enabled
2+
3+
testfiledir = "testfiles-shell"
4+
checkopts = "-interaction=nonstopmode -shell-escape"
5+
6+
-- files removed between different engine tests
7+
dynamicfiles = {"*.gnuplot", "*.table"}

doc/generic/pgf/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
99
### Fixed
1010

1111
- Fix formatting of `default XXX, initially XXX` in key docs #1278
12+
- Correct the fix to trim spaces from `gnuplot` functions #1397 #1399
13+
14+
### Added
15+
16+
- Emulated `runsystem(...)` logging for LuaTeX
1217

1318
## [3.1.11] - 2025-08-14 Henri Menke
1419

File renamed without changes.

testfiles-shell/gh1397.lvt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
\documentclass{article}
2+
\input{pgf-regression-test}
3+
4+
\usepackage{tikz}
5+
6+
\begin{document}
7+
8+
\START
9+
10+
\BEGINTEST{no .gnuplot}
11+
\begin{tikzpicture}
12+
\draw[id=normal] plot[domain=-2:2] function {x**2};
13+
\end{tikzpicture}
14+
15+
\SHOWFILE{\jobname.normal.gnuplot}
16+
\ENDTEST
17+
18+
\BEGINTEST{no .gnuplot, leading space in function}
19+
\begin{tikzpicture}
20+
\draw[id=leading-space] plot[domain=-2:2] function { x**2};
21+
\end{tikzpicture}
22+
23+
\SHOWFILE{\jobname.leading-space.gnuplot}
24+
\ENDTEST
25+
26+
\BEGINTEST{no .gnuplot, trailing space in function}
27+
\begin{tikzpicture}
28+
\draw[id=trailing-space] plot[domain=-2:2] function {x**2 };
29+
\end{tikzpicture}
30+
31+
\SHOWFILE{\jobname.trailing-space.gnuplot}
32+
\ENDTEST
33+
34+
\BEGINTEST{.gnuplot existing and matched}
35+
\begin{tikzpicture}
36+
\draw[id=normal] plot[domain=-2:2] function {x**2};
37+
\draw[id=leading-space] plot[domain=-2:2] function { x**2};
38+
\draw[id=trailing-space] plot[domain=-2:2] function {x**2 };
39+
\end{tikzpicture}
40+
\ENDTEST
41+
42+
\BEGINTEST{.gnuplot existing but outdated}
43+
\begin{tikzpicture}
44+
% use the existing id but a different domain
45+
\draw[id=normal] plot[domain=-4:4] function {x**2};
46+
\end{tikzpicture}
47+
48+
\SHOWFILE{\jobname.normal.gnuplot}
49+
\ENDTEST
50+
51+
\END

testfiles-shell/gh1397.tlg

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
This is a generated file for the l3build validation system.
2+
Don't change this file in any respect.
3+
============================================================
4+
TEST 1: no .gnuplot
5+
============================================================
6+
runsystem(gnuplot gh1397.normal.gnuplot)...executed.
7+
-------- gh1397.normal.gnuplot (start) ---------
8+
(gh1397.normal.gnuplot) set table "gh1397.normal.table"; set format "%.5f"[nl]
9+
set samples 25; plot [x=-2:2] x**2[nl]
10+
-------- gh1397.normal.gnuplot (end) -----------
11+
============================================================
12+
============================================================
13+
TEST 2: no .gnuplot, leading space in function
14+
============================================================
15+
runsystem(gnuplot gh1397.leading-space.gnuplot)...executed.
16+
-------- gh1397.leading-space.gnuplot (start) ---------
17+
(gh1397.leading-space.gnuplot) set table "gh1397.leading-space.table"; set format "%.5f"[nl]
18+
set samples 25; plot [x=-2:2] x**2[nl]
19+
-------- gh1397.leading-space.gnuplot (end) -----------
20+
============================================================
21+
============================================================
22+
TEST 3: no .gnuplot, trailing space in function
23+
============================================================
24+
runsystem(gnuplot gh1397.trailing-space.gnuplot)...executed.
25+
-------- gh1397.trailing-space.gnuplot (start) ---------
26+
(gh1397.trailing-space.gnuplot) set table "gh1397.trailing-space.table"; set format "%.5f"[nl]
27+
set samples 25; plot [x=-2:2] x**2[nl]
28+
-------- gh1397.trailing-space.gnuplot (end) -----------
29+
============================================================
30+
============================================================
31+
TEST 4: .gnuplot existing and matched
32+
============================================================
33+
============================================================
34+
============================================================
35+
TEST 5: .gnuplot existing but outdated
36+
============================================================
37+
runsystem(gnuplot gh1397.normal.gnuplot)...executed.
38+
-------- gh1397.normal.gnuplot (start) ---------
39+
(gh1397.normal.gnuplot) set table "gh1397.normal.table"; set format "%.5f"[nl]
40+
set samples 25; plot [x=-4:4] x**2[nl]
41+
-------- gh1397.normal.gnuplot (end) -----------
42+
============================================================

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@
481481
\pgfutilpreparefilename{#1.table}%
482482
\let\pgf@plottablefile=\pgfretval
483483
\let\pgf@plottablefile@quoted=\pgfretvalquoted
484+
\edef\pgf@plot@code{\pgfutil@trimspaces@e{#2}}%
484485
\begingroup
485486
\endlinechar=-1 % suppress white space at end
486487
% Check, whether it is up-to-date
@@ -490,7 +491,6 @@
490491
\pgfutil@read\pgfutil@inputcheck to\pgf@temp% ignored
491492
\pgfutil@read\pgfutil@inputcheck to\pgf@plot@line%
492493
\closein\pgfutil@inputcheck
493-
\edef\pgf@plot@code{\pgfutil@trimspaces@e{#2}}%
494494
\ifx\pgf@plot@code\pgf@plot@line%
495495
\openin\pgfutil@inputcheck=\pgfretval\relax
496496
\ifeof\pgfutil@inputcheck%

tex/generic/pgf/utilities/pgfutil-common.tex

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,9 +883,22 @@
883883
\def\pgfutil@luaescapestring#1{}
884884
\fi
885885

886-
886+
% Emulate the "runsystem(...)" logging for LuaTeX
887+
% based on the emulation in l3kernel (l3sys.dtx, @@_shell_now:e), and the
888+
% ending periods are added following https://github.com/latex3/latex2e/commit/90d53de44fe4a09baa4a17506abe6ce9e120a7c3.
887889
\def\pgfutil@shellescape@lua@eightseven#1{%
888-
\pgfutil@directlua{os.execute("\pgfutil@luaescapestring{#1}")}%
890+
\pgfutil@directlua{%
891+
local write_nl = texio.write_nl
892+
local cmd = "\pgfutil@luaescapestring{#1}"
893+
local status, msg = os.execute(cmd)
894+
if status == nil then
895+
write_nl("log", "runsystem(" .. cmd .. ")...(" .. msg .. ").\string\n")
896+
elseif status == 0 then
897+
write_nl("log", "runsystem(" .. cmd .. ")...executed.\string\n")
898+
else
899+
write_nl("log", "runsystem(" .. cmd .. ")...failed. " .. (msg or "") .. "\string\n")
900+
end
901+
}%
889902
}%
890903
\def\pgfutil@shellescape#1{%
891904
\immediate\write18{#1}%

0 commit comments

Comments
 (0)