From 6bbb100b9c00f063e424174411bb6491d11c3ccb Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 1 Jul 2020 13:26:55 +0000 Subject: 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 --- usr.bin/awk/run.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'usr.bin/awk/run.c') 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'; -- cgit v1.2.3