diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 12:33:03 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 12:33:03 +0300 |
commit | 2f83a4e72166e811a9f0b4726c19a3d5a0b17dcb (patch) | |
tree | 469bebda4e807139efb497edfca1ec0678b5ab8b /eval.c | |
parent | 66b0bdd602e952f20fa98f6ce5430cea68d4f598 (diff) | |
download | egawk-2f83a4e72166e811a9f0b4726c19a3d5a0b17dcb.tar.gz egawk-2f83a4e72166e811a9f0b4726c19a3d5a0b17dcb.tar.bz2 egawk-2f83a4e72166e811a9f0b4726c19a3d5a0b17dcb.zip |
Move to gawk-2.15.5.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 31 |
1 files changed, 21 insertions, 10 deletions
@@ -137,6 +137,10 @@ register NODE *volatile tree; NODE *volatile stable_tree; int volatile traverse = 1; /* True => loop thru tree (Node_rule_list) */ + /* avoid false source indications */ + source = NULL; + sourceline = 0; + if (tree == NULL) return 1; sourceline = tree->source_line; @@ -381,7 +385,7 @@ register NODE *tree; register int di; AWKNUM x, x1, x2; long lx; -#ifdef CRAY +#ifdef _CRAY long lx2; #endif @@ -396,14 +400,18 @@ register NODE *tree; if ((char)tree->var_value->stref <= 0) cant_happen(); return tree->var_value; } +#endif + if (tree->type == Node_param_list) { - if (stack_ptr[tree->param_cnt] == NULL) + tree = stack_ptr[tree->param_cnt]; + if (tree == NULL) return Nnull_string; - else - return stack_ptr[tree->param_cnt]->var_value; } -#endif + switch (tree->type) { + case Node_var: + return tree->var_value; + case Node_and: return tmp_number((AWKNUM) (eval_condition(tree->lnode) && eval_condition(tree->rnode))); @@ -446,7 +454,7 @@ register NODE *tree; return *lhs; case Node_var_array: - fatal("attempt to use an array in a scalar context"); + fatal("attempt to use array `%s' in a scalar context", tree->vname); case Node_unary_minus: t1 = tree_eval(tree->subnode); @@ -530,6 +538,7 @@ register NODE *tree; } *strp = NULL; emalloc(str, char *, len+2, "tree_eval"); + str[len] = str[len+1] = '\0'; /* for good measure */ dest = str; strp = strlist; while (*strp) { @@ -651,7 +660,7 @@ register NODE *tree; return tmp_number(x1 - x2); case Node_var_array: - fatal("attempt to use an array in a scalar context"); + fatal("attempt to use array `%s' in a scalar context", tree->vname); default: fatal("illegal type (%d) in tree_eval", tree->type); @@ -966,12 +975,14 @@ NODE *arg_list; /* Node_expression_list of calling args. */ if (arg->type == Node_param_list) arg = stack_ptr[arg->param_cnt]; n = *sp++; - if (arg->type == Node_var && n->type == Node_var_array) { + if ((arg->type == Node_var || arg->type == Node_var_array) + && n->type == Node_var_array) { /* should we free arg->var_value ? */ arg->var_array = n->var_array; arg->type = Node_var_array; arg->array_size = n->array_size; arg->table_size = n->table_size; + arg->flags = n->flags; } /* n->lnode overlays the array size, don't unref it if array */ if (n->type != Node_var_array) @@ -1018,7 +1029,7 @@ Func_ptr *assign; switch (ptr->type) { case Node_var_array: - fatal("attempt to use an array in a scalar context"); + fatal("attempt to use array `%s' in a scalar context", ptr->vname); case Node_var: aptr = &(ptr->var_value); #ifdef DEBUG @@ -1194,7 +1205,7 @@ set_ORS() ORS[ORSlen] = '\0'; } -static NODE **fmt_list = NULL; +NODE **fmt_list = NULL; static int fmt_ok P((NODE *n)); static int fmt_index P((NODE *n)); |