From 7ef192a2b9c9d56251975bb80c64ef08fd7255e5 Mon Sep 17 00:00:00 2001 From: millert Date: Fri, 3 Jun 2022 19:42:27 +0000 Subject: [PATCH] The fulfillment of an assignment operand had been truncating its entry in ARGV (since circa 1989). From Miguel Pineiro Jr. --- usr.bin/awk/FIXES | 7 ++++++- usr.bin/awk/lib.c | 6 ++++-- usr.bin/awk/main.c | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/usr.bin/awk/FIXES b/usr.bin/awk/FIXES index 17115123f0d..77fa8227e51 100644 --- a/usr.bin/awk/FIXES +++ b/usr.bin/awk/FIXES @@ -1,4 +1,4 @@ -/* $OpenBSD: FIXES,v 1.44 2022/06/03 19:40:56 millert Exp $ */ +/* $OpenBSD: FIXES,v 1.45 2022/06/03 19:42:27 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -26,6 +26,11 @@ THIS SOFTWARE. This file lists all bug fixes, changes, etc., made since the AWK book was sent to the printers in August, 1987. +Mar 14, 2022: + The fulfillment of an assignment operand had been truncating its + entry in ARGV (since circa 1989). Thanks to Miguel Pineiro Jr. + . + Mar 3, 2022: Fixed file management memory leak that appears to have been there since the files array was first initialized with stdin, diff --git a/usr.bin/awk/lib.c b/usr.bin/awk/lib.c index 752b66d9a8d..0b58ed55e5a 100644 --- a/usr.bin/awk/lib.c +++ b/usr.bin/awk/lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lib.c,v 1.47 2021/11/02 15:29:41 millert Exp $ */ +/* $OpenBSD: lib.c,v 1.48 2022/06/03 19:42:27 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -295,12 +295,13 @@ char *getargv(int n) /* get ARGV[n] */ void setclvar(char *s) /* set var=value from s */ { - char *p; + char *e, *p; Cell *q; double result; for (p=s; *p != '='; p++) ; + e = p; *p++ = 0; p = qstring(p, '\0'); q = setsymtab(s, p, 0.0, STR, symtab); @@ -310,6 +311,7 @@ void setclvar(char *s) /* set var=value from s */ q->tval |= NUM; } DPRINTF("command line set %s to |%s|\n", s, p); + *e = '='; } diff --git a/usr.bin/awk/main.c b/usr.bin/awk/main.c index f3a3fe423dc..e1aef4a6b30 100644 --- a/usr.bin/awk/main.c +++ b/usr.bin/awk/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.52 2022/06/03 19:40:56 millert Exp $ */ +/* $OpenBSD: main.c,v 1.53 2022/06/03 19:42:27 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -23,7 +23,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ****************************************************************/ -const char *version = "version 20220303"; +const char *version = "version 20220314"; #define DEBUG #include -- 2.20.1