Michael Kuron wants to merge 1 commit from /u/mkuron/gnuplot/ to master, 2020-04-23
Sample script:
set terminal tikz
set output '/dev/null'
set xrange [0:1]
set yrange [0:1]
set object polygon from 2,2 to 3,2 to 3,3 to 2,3 to 2,2
plot 0.5
unset out
causes the following error:
"test.gp", line 9: warning: Error re-writing output file: Invalid argument
"test.gp", line 9: /usr/share/gnuplot/gnuplot/5.2/lua/gnuplot-tikz.lua:439: attempt to index a nil value (field '?')
stack traceback:
/usr
line 0: Missing Lua context! No script?
line 0: Missing Lua context! No script?
[...repeated...]
This merge request fixes the issue by not drawing any polygons that have less than two (visible) points. I have observed the above error on gnuplot 5.0 and 5.2 and believe it remains present in the current master branch.
For some reason Sourceforge doesn't want to show my commit right now. This is the patch:
Hmm, I see what you mean. The merge request executes but reports "nothing to merge". I have no idea what's going on there.
Notes:
1) Some other terminals check for a minimum of 3 points rather than 2.
2) In this particular problematic example the entire rectangle is out of range, causing the terminal routine to be called with 0 points. That strikes me as a top-level error since it makes no sense to call the terminal at all in this case. Therefore in addition to the check in your patch, the equivalent check should also be made in the calling routine.
Well, I managed to get Sourceforge to show the commit. Even though it stopped showing me HTTP 500 error messages now, my forked Git repo is still behaving odd.
1) 2 is the minimum that the logic in the Lua code needs. Of course, a 2-gon is just a line, but there is not explicit reason to prevent 2 here.
2) That's correct, though I couldn't find the right place in the code for that. Furthermore, other terminals seem to be fine with 0 points.
Applied to both 5.2 and 5.3
I added a check to the caller also (graphics.c:do_polygon).