mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
38020: fix problems with $SECONDS.
Fractions of a second were not handled correctly.
This commit is contained in:
parent
c55d855171
commit
f7d5ff31ce
2 changed files with 8 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
2016-02-26 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* Stephane: 38020: fix problems with fractions of a second in
|
||||
$SECONDS.
|
||||
|
||||
2016-02-25 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 38024: Src/signals.c, Test/C03traps.ztst: improve 37999 to
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**/
|
||||
|
|
Loading…
Reference in a new issue