diff options
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -562,6 +562,7 @@ set_FNR() else #endif FNR = get_number_si(n); + FNR_node->var_value->flags |= VAR_SPEC; } /* set_NR --- update internal NR from awk variable */ @@ -577,6 +578,7 @@ set_NR() else #endif NR = get_number_si(n); + NR_node->var_value->flags |= VAR_SPEC; } /* inrec --- This reads in a record from the input file */ @@ -2475,8 +2477,11 @@ do_getline_redir(int into_variable, enum redirval redirtype) NODE **lhs = NULL; int redir_error = 0; - if (into_variable) + if (into_variable) { lhs = POP_ADDRESS(); + if (((*lhs)->flags & VAR_CONST) != 0) + fatal(_("cannot assign to defined constant")); + } assert(redirtype != redirect_none); redir_exp = TOP(); @@ -2562,6 +2567,8 @@ do_getline(int into_variable, IOBUF *iop) else { /* assignment to variable */ NODE **lhs; lhs = POP_ADDRESS(); + if (((*lhs)->flags & VAR_CONST) != 0) + fatal(_("cannot assign to defined constant")); unref(*lhs); *lhs = make_string(s, cnt); (*lhs)->flags |= MAYBE_NUM; @@ -3700,6 +3707,7 @@ set_RS() set_FS: if (current_field_sep() == Using_FS) set_FS(); + RS_node->var_value->flags |= VAR_SPEC; } |