Rebuild fields when NF is assigned to itself
This commit is contained in:
parent
2dc7e5ff1a
commit
6315525dbe
@ -23,3 +23,5 @@ and also if CONVFMT changed.
|
||||
|
||||
7. unary-plus: Unary plus on a string constant returned the string.
|
||||
Instead, it should convert the value to numeric and give that value.
|
||||
|
||||
X. nf-self-assign: "NF = NF" wouldn't force the record to be rebuilt.
|
||||
|
6
bugs-fixed/nf-self-assign.awk
Normal file
6
bugs-fixed/nf-self-assign.awk
Normal file
@ -0,0 +1,6 @@
|
||||
BEGIN {
|
||||
$0="a b c";
|
||||
OFS=",";
|
||||
NF = NF;
|
||||
print;
|
||||
}
|
1
bugs-fixed/nf-self-assign.bad
Normal file
1
bugs-fixed/nf-self-assign.bad
Normal file
@ -0,0 +1 @@
|
||||
a b c
|
1
bugs-fixed/nf-self-assign.ok
Normal file
1
bugs-fixed/nf-self-assign.ok
Normal file
@ -0,0 +1 @@
|
||||
a,b,c
|
4
run.c
4
run.c
@ -1117,8 +1117,8 @@ Cell *assign(Node **a, int n) /* a[0] = a[1], a[0] += a[1], etc. */
|
||||
y = execute(a[1]);
|
||||
x = execute(a[0]);
|
||||
if (n == ASSIGN) { /* ordinary assignment */
|
||||
if (x == y && !(x->tval & (FLD|REC))) /* self-assignment: */
|
||||
; /* leave alone unless it's a field */
|
||||
if (x == y && !(x->tval & (FLD|REC)) && x != nfloc)
|
||||
; /* self-assignment: leave alone unless it's a field or NF */
|
||||
else if ((y->tval & (STR|NUM)) == (STR|NUM)) {
|
||||
setsval(x, getsval(y));
|
||||
x->fval = getfval(y);
|
||||
|
Loading…
Reference in New Issue
Block a user