From f7d5ff31ce8d354dd69de619e703b9c0e49f0977 Mon Sep 17 00:00:00 2001 From: Stephane Chazelas Date: Wed, 24 Feb 2016 17:09:04 +0000 Subject: 38020: fix problems with $SECONDS. Fractions of a second were not handled correctly. --- Src/params.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Src') diff --git a/Src/params.c b/Src/params.c index 8bd8a8eee..7c5f79fff 100644 --- a/Src/params.c +++ b/Src/params.c @@ -3804,8 +3804,8 @@ intsecondsgetfn(UNUSED(Param pm)) gettimeofday(&now, &dummy_tz); - return (zlong)(now.tv_sec - shtimer.tv_sec) + - (zlong)(now.tv_usec - shtimer.tv_usec) / (zlong)1000000; + return (zlong)(now.tv_sec - shtimer.tv_sec - + (now.tv_usec < shtimer.tv_usec ? 1 : 0)); } /* Function to set value of special parameter `SECONDS' */ @@ -3823,7 +3823,7 @@ intsecondssetfn(UNUSED(Param pm), zlong x) shtimer.tv_sec = diff; if ((zlong)shtimer.tv_sec != diff) zwarn("SECONDS truncated on assignment"); - shtimer.tv_usec = 0; + shtimer.tv_usec = now.tv_usec; } /**/ -- cgit 1.4.1