diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2020-07-01 13:26:55 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2020-07-01 13:26:55 +0000 |
commit | 6bbb100b9c00f063e424174411bb6491d11c3ccb (patch) | |
tree | 2d5411b768ef92ce8eca4e6171a41b4e9245b7c5 /usr.bin/awk/run.c | |
parent | 7b86c765862cddf69826109d8eb29d82e5e58ceb (diff) |
Fix concatenation regression introduced in version 20201024.
Concatenation evaluated both sides of the expression before doing
its work, which, since assign() evaluates to the cell being assigned
to, meant that expressions like "print (a = 1) (a = 2)" would print
"22" rather than "12". From Tim van der Molen
Diffstat (limited to 'usr.bin/awk/run.c')
-rw-r--r-- | usr.bin/awk/run.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c index 88fd26f1002..fcfe239726e 100644 --- a/usr.bin/awk/run.c +++ b/usr.bin/awk/run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: run.c,v 1.60 2020/06/26 15:57:39 millert Exp $ */ +/* $OpenBSD: run.c,v 1.61 2020/07/01 13:26:54 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -1193,12 +1193,12 @@ Cell *cat(Node **a, int q) /* a[0] cat a[1] */ x = execute(a[0]); n1 = strlen(getsval(x)); + adjbuf(&s, &ssz, n1, recsize, 0, "cat1"); + memcpy(s, x->sval, n1); y = execute(a[1]); n2 = strlen(getsval(y)); - - adjbuf(&s, &ssz, n1 + n2 + 1, recsize, 0, "cat"); - memcpy(s, x->sval, n1); + adjbuf(&s, &ssz, n1 + n2 + 1, recsize, 0, "cat2"); memcpy(s + n1, y->sval, n2); s[n1 + n2] = '\0'; |