mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 22:11:54 +02:00
17873: When restoring SECONDS after a function call, included elapsed time.
This commit is contained in:
parent
ff23ebe925
commit
c2b5a21ae5
2 changed files with 20 additions and 0 deletions
|
@ -1,5 +1,8 @@
|
|||
2002-10-29 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 17873: Src/params.c: When restoring SECONDS after a function,
|
||||
take account of time spent in the function.
|
||||
|
||||
* 17872: Src/builtin.c: Make sure `typeset SECONDS' uses a
|
||||
suitable type when creating a new local parameter.
|
||||
|
||||
|
|
17
Src/params.c
17
Src/params.c
|
@ -3484,7 +3484,24 @@ scanendscope(HashNode hn, int flags)
|
|||
Param tpm = pm->old;
|
||||
|
||||
if (!strcmp(pm->nam, "SECONDS"))
|
||||
{
|
||||
setsecondstype(pm, PM_TYPE(tpm->flags), PM_TYPE(pm->flags));
|
||||
/*
|
||||
* We restore SECONDS by adding back in the elapsed
|
||||
* time (from the point we reset shtimer) rather
|
||||
* than restoring it completely, since SECONDS should
|
||||
* run in the calling function, too.
|
||||
*/
|
||||
if (PM_TYPE(pm->flags) == PM_INTEGER)
|
||||
{
|
||||
pm->sets.ifn(pm, pm->gets.ifn(pm) + tpm->u.val);
|
||||
}
|
||||
else
|
||||
{
|
||||
pm->sets.ffn(pm, pm->gets.ffn(pm) + tpm->u.dval);
|
||||
}
|
||||
tpm->flags |= PM_NORESTORE;
|
||||
}
|
||||
DPUTS(!tpm || PM_TYPE(pm->flags) != PM_TYPE(tpm->flags) ||
|
||||
!(tpm->flags & PM_SPECIAL),
|
||||
"BUG: in restoring scope of special parameter");
|
||||
|
|
Loading…
Reference in a new issue