mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 17:56:50 -06:00
arc raised its second angle by 2π in a loop until it was no longer below the first, and arcn lowered it the same way. For an angle of 1e18 degrees that loop takes about 3e15 steps: vectorcraft-cli info was still reading an EPS file with "newpath 100 100 50 1e18 0 arc stroke" when "timeout 20" stopped it. For 1e308 the loop never ends: from 2^56 radians (about 4.1e18 degrees) up, adding 2π leaves a double unchanged. The import fuzz test eps_hostile_programs_never_panic builds programs from tokens that include arc, arcn, 1e308 and 1e15. arc now raises the second angle by multiples of 360 until it is at least the first, and arcn lowers it until it is at most the first, as the PostScript Language Reference defines them. The code works out both sweeps from the remainders of the two angles after whole turns, and it places the first endpoint at the remainder of the first angle. Ordinary angles give the same arcs as before, apart from rounding in the last digits. One case changes: when raising (arc) or lowering (arcn) the second angle by whole turns makes it equal to the first, as in 60 -300 arc or -60 300 arcn, rounding sometimes made the old loop add another turn and draw a full circle. Those arcs are now empty, as the PostScript Language Reference defines them. Tests: 1e18 0 arc, 1e308 0 arc, 0 1e18 arcn and 0 1e308 arcn draw the arc between the angles' remainders and leave the current point at the second angle. The test reads each program on a thread of its own and fails when no result arrives within 20 seconds.