Mercurial > hg > minc-tools
changeset 1366:1ad7ab29f45d
Added check in sym_set_scalar and sym_set_vector to make sure that
width of existing symbol was at least enough to accomodate the new
scalar values being assigned.
author | neelin <neelin> |
---|---|
date | Fri, 04 May 2001 13:39:11 +0000 |
parents | d0a951b8aed9 |
children | 3a7bcc094fb7 |
files | progs/minccalc/sym.c |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/progs/minccalc/sym.c +++ b/progs/minccalc/sym.c @@ -92,7 +92,9 @@ } /* Create a new scalar if needed */ - if (newsym->type == SYM_UNKNOWN) { + if (newsym->type == SYM_UNKNOWN || newsym->scalar->width < width) { + if (newsym->type == SYM_SCALAR) + scalar_free(newsym->scalar); newsym->type = SYM_SCALAR; newsym->scalar = new_scalar(width); } @@ -124,13 +126,14 @@ } /* Create a new vector if needed - either it does not exist or the - length is changing */ - if (newsym->type == SYM_UNKNOWN || newsym->vector->len != v->len) { + length is changing or the width is increasing*/ + if (newsym->type == SYM_UNKNOWN || newsym->vector->len != v->len || + (newsym->vector->len > 0 && newsym->vector->el[0]->width < width) ) { /* Free an existing vector. If eval_flags is set, then we cannot change the length of the vector */ if (newsym->type == SYM_VECTOR) { - if (eval_flags != NULL) { + if (eval_flags != NULL && newsym->vector->len != v->len) { /* errx(1, "assigned vector must match length of %s in if", ident_str(id)); */ fprintf(stderr, "assigned vector must match length of %s in if",