summaryrefslogtreecommitdiff
path: root/usr.bin/awk/run.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2023-10-06 22:29:25 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2023-10-06 22:29:25 +0000
commit4f23941f93e1a285b3349c696e870e95c77fda97 (patch)
tree15993fba055e94085a8a9bd12f425d2873a48f01 /usr.bin/awk/run.c
parent0c14ece8148c071e7ecf8e15d2fc92b4a1492f11 (diff)
Update awk to Sep 24, 2023 version.
fnematch and getrune have been overhauled to solve issues around unicode FS and RS. also fixed gsub null match issue with unicode. big thanks to Arnold Robbins.
Diffstat (limited to 'usr.bin/awk/run.c')
-rw-r--r--usr.bin/awk/run.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c
index 436b6c75290..1c1b72c6dd8 100644
--- a/usr.bin/awk/run.c
+++ b/usr.bin/awk/run.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: run.c,v 1.78 2023/09/20 16:49:13 millert Exp $ */
+/* $OpenBSD: run.c,v 1.79 2023/10/06 22:29:24 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -2587,6 +2587,7 @@ Cell *gsub(Node **a, int nnn) /* global substitute */
fa *pfa;
int mflag, tempstat, num;
int bufsz = recsize;
+ int charlen = 0;
if ((buf = (char *) malloc(bufsz)) == NULL)
FATAL("out of memory in gsub");
@@ -2628,7 +2629,9 @@ Cell *gsub(Node **a, int nnn) /* global substitute */
if (*t == '\0') /* at end */
goto done;
adjbuf(&buf, &bufsz, 2+pb-buf, recsize, &pb, "gsub");
- *pb++ = *t++;
+ charlen = u8_nextlen(t);
+ while (charlen-- > 0)
+ *pb++ = *t++;
if (pb > buf + bufsz) /* BUG: not sure of this test */
FATAL("gsub result0 %.30s too big; can't happen", buf);
mflag = 0;