diff options
author | Stephane Chazelas <stephane.chazelas@gmail.com> | 2016-02-24 17:09:04 +0000 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2016-02-26 11:12:32 +0000 |
commit | f7d5ff31ce8d354dd69de619e703b9c0e49f0977 (patch) | |
tree | 532d4bf25a7cb35662995eeaa3bf3d3f4cb27e00 /Src/params.c | |
parent | c55d8551718bcf2fc7661c31c13e934060a5f1a7 (diff) | |
download | zsh-f7d5ff31ce8d354dd69de619e703b9c0e49f0977.tar.gz zsh-f7d5ff31ce8d354dd69de619e703b9c0e49f0977.tar.xz zsh-f7d5ff31ce8d354dd69de619e703b9c0e49f0977.zip |
38020: fix problems with $SECONDS.
Fractions of a second were not handled correctly.
Diffstat (limited to 'Src/params.c')
-rw-r--r-- | Src/params.c | 6 |
1 files changed, 3 insertions, 3 deletions
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; } /**/ |