Fix for an error message seen when testing the shx shared-library

program: do not allow a negative timestep.
This commit is contained in:
Giles Atkinson 2025-03-29 14:20:52 +00:00 committed by Holger Vogt
parent b8b83b1601
commit 46c5a8d375
1 changed files with 8 additions and 2 deletions

View File

@ -2471,8 +2471,14 @@ sharedsync(double *pckttime, double *pcktdelta, double olddelta, double finalt,
step if return value from getsync is 1. */
int retval = getsync(*pckttime, pcktdelta, olddelta, redostep, ng_ident, loc, userptr);
/* never move beyond final time */
if (*pckttime + *pcktdelta > finalt)
*pcktdelta = finalt - *pckttime - 1.1 * delmin;
if (*pckttime + *pcktdelta > finalt) {
double newdelta;
newdelta = finalt - *pckttime - 1.1 * delmin;
if (newdelta <= 0.0)
newdelta = finalt - *pckttime;
*pcktdelta = newdelta;
}
/* user has decided to redo the step, ignoring redostep being set to 0
by ngspice. */