summary refs log tree commit diff
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2002-10-31 18:32:06 +0000
committerWayne Davison <wayned@users.sourceforge.net>2002-10-31 18:32:06 +0000
commitfd3bac933fef0ed3f867b28528301107bd79c030 (patch)
treee15059f29ae2e5413801dd3ce8eaaec32d5bb408
parent23fdf20e03c065f0379cac840fc5805d4f862255 (diff)
downloadzsh-fd3bac933fef0ed3f867b28528301107bd79c030.tar.gz
zsh-fd3bac933fef0ed3f867b28528301107bd79c030.tar.xz
zsh-fd3bac933fef0ed3f867b28528301107bd79c030.zip
- 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.
-rw-r--r--Src/builtin.c10
1 files 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.