summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-01-15 13:52:08 +0000
committerPeter Stephenson <pws@zsh.org>2015-01-15 13:52:40 +0000
commit3a99ef322dafcd2cf833b2a0668436ac120df1b3 (patch)
tree1572509835aab319e5f89ed239d12a3d19518a25 /Src
parentc7aa6443907ddd97b6b1e8729ce9c897de0d244c (diff)
downloadzsh-3a99ef322dafcd2cf833b2a0668436ac120df1b3.tar.gz
zsh-3a99ef322dafcd2cf833b2a0668436ac120df1b3.zip
34280: more widespread use of FORCE_FLOAT.
Add the case of variables read for use in arithmetic expressions.
Diffstat (limited to 'Src')
-rw-r--r--Src/math.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/Src/math.c b/Src/math.c
index db42d0f7c..c047725c5 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -336,16 +336,27 @@ enum prec_type {
static mnumber
getmathparam(struct mathvalue *mptr)
{
+ mnumber result;
if (!mptr->pval) {
char *s = mptr->lval;
mptr->pval = (Value)zhalloc(sizeof(struct value));
if (!getvalue(mptr->pval, &s, 1))
{
mptr->pval = NULL;
+ if (isset(FORCEFLOAT)) {
+ result.type = MN_FLOAT;
+ result.u.d = 0.0;
+ return result;
+ }
return zero_mnumber;
}
}
- return getnumvalue(mptr->pval);
+ result = getnumvalue(mptr->pval);
+ if (isset(FORCEFLOAT) && result.type == MN_INTEGER) {
+ result.type = MN_FLOAT;
+ result.u.d = (double)result.u.l;
+ }
+ return result;
}
static mnumber