From fd3bac933fef0ed3f867b28528301107bd79c030 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Thu, 31 Oct 2002 18:32:06 +0000 Subject: - Save off the raw start-time of the $SECONDS special variable if we're creating a local value (avoids rounding problems with elapsed time). - Also changed a line where the newspecial enum was compared to 0 instead of NS_NONE. --- Src/builtin.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Src/builtin.c b/Src/builtin.c index 045c80f36..5f7203fbe 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -1774,6 +1774,8 @@ typeset_single(char *cname, char *pname, Param pm, int func, return NULL; } } + else if (newspecial != NS_NONE && strcmp(pname, "SECONDS") == 0) + newspecial = NS_SECONDS; /* * A parameter will be local if @@ -1913,8 +1915,12 @@ typeset_single(char *cname, char *pname, Param pm, int func, * because we've checked for unpleasant surprises above. */ pm->flags = (PM_TYPE(pm->flags) | on | PM_SPECIAL) & ~off; - if (newspecial == NS_SECONDS) + if (newspecial == NS_SECONDS) { + /* We save off the raw internal value of the SECONDS var */ + tpm->u.dval = getrawseconds(); setsecondstype(pm, on, off); + } + /* * Final tweak: if we've turned on one of the flags with * numbers, we should use the appropriate integer. @@ -1998,7 +2004,7 @@ typeset_single(char *cname, char *pname, Param pm, int func, "BUG: parameter recreated with wrong flags"); unsetparam_pm(ipm, 0, 1); } - } else if (newspecial && !(pm->old->flags & PM_NORESTORE)) { + } else if (newspecial != NS_NONE && !(pm->old->flags & PM_NORESTORE)) { /* * We need to use the special setting function to re-initialise * the special parameter to empty. -- cgit 1.4.1