From c27c8098e9ce75d17e84bf57a234a6101bdb04d7 Mon Sep 17 00:00:00 2001 From: erg Date: Thu, 10 Jan 2008 18:35:18 +0000 Subject: [PATCH] Fix bugs related to the type of functions (the return type was being set to the last type declared in its body) and casting from a string to a double. --- lib/expr/exgram.h | 9 ++++----- lib/expr/exparse.y | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/expr/exgram.h b/lib/expr/exgram.h index 63594ab01..ac82c752f 100644 --- a/lib/expr/exgram.h +++ b/lib/expr/exgram.h @@ -479,17 +479,16 @@ extern "C" { vmstrdup(p->vm, sfstruse(p->tmp)); break; case S2F: - x->data.constant.value.floating = - strtod(x->data.constant.value.string, &e); + s = x->data.constant.value.string; + x->data.constant.value.floating = strtod (s, &e); if (*e) - x->data.constant.value.floating = - *x->data.constant.value.string != 0; + x->data.constant.value.floating = (*s != 0); break; case S2I: s = x->data.constant.value.string; x->data.constant.value.integer = strToL(s, &e); if (*e) - x->data.constant.value.integer = *s != 0; + x->data.constant.value.integer = (*s != 0); break; default: exerror("internal error: %d: unknown cast op", t2t); diff --git a/lib/expr/exparse.y b/lib/expr/exparse.y index fb124678e..a9cd392cc 100644 --- a/lib/expr/exparse.y +++ b/lib/expr/exparse.y @@ -456,6 +456,7 @@ dcl_item : dcl_name {checkName ($1); expr.id=$1;} array initialize if ($4 && $4->op == PROCEDURE) { $1->lex = PROCEDURE; + $1->type = $4->type; $1->value = $4; } else -- 2.50.1