summaryrefslogtreecommitdiff
path: root/usr.bin/awk/run.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2020-08-11 16:57:06 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2020-08-11 16:57:06 +0000
commit7566784ca2fb8503490e8ca3b5e65cf2c92d1489 (patch)
tree0567ff21004ae84dbb520cf202faacf76ff2a3c0 /usr.bin/awk/run.c
parent7f5faee3631066d04328aa8e22bb66aa75bff109 (diff)
Update awk to August 7, 2020 version.
Diffstat (limited to 'usr.bin/awk/run.c')
-rw-r--r--usr.bin/awk/run.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c
index b098edf6147..dcd959aa52d 100644
--- a/usr.bin/awk/run.c
+++ b/usr.bin/awk/run.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: run.c,v 1.66 2020/07/30 17:45:44 millert Exp $ */
+/* $OpenBSD: run.c,v 1.67 2020/08/11 16:57:05 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -120,7 +120,7 @@ int adjbuf(char **pbuf, int *psiz, int minlen, int quantum, char **pbptr,
if (rminlen)
minlen += quantum - rminlen;
tbuf = realloc(*pbuf, minlen);
- DPRINTF("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, *pbuf, tbuf);
+ DPRINTF("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, (void*)*pbuf, (void*)tbuf);
if (tbuf == NULL) {
if (whatrtn)
FATAL("out of memory in %s", whatrtn);
@@ -1526,7 +1526,6 @@ static char *nawk_convert(const char *s, int (*fun_c)(int),
char *pbuf = NULL;
const char *ps = NULL;
size_t n = 0;
- mbstate_t mbs, mbs2;
wchar_t wc;
size_t sz = MB_CUR_MAX;
@@ -1541,17 +1540,24 @@ static char *nawk_convert(const char *s, int (*fun_c)(int),
/* upper/lower character may be shorter/longer */
buf = tostringN(s, strlen(s) * sz + 1);
- memset(&mbs, 0, sizeof(mbs));
- memset(&mbs2, 0, sizeof(mbs2));
+ (void) mbtowc(NULL, NULL, 0); /* reset internal state */
+ /*
+ * Reset internal state here too.
+ * Assign result to avoid a compiler warning. (Casting to void
+ * doesn't work.)
+ * Increment said variable to avoid a different warning.
+ */
+ int unused = wctomb(NULL, L'\0');
+ unused++;
ps = s;
pbuf = buf;
- while (n = mbrtowc(&wc, ps, sz, &mbs),
+ while (n = mbtowc(&wc, ps, sz),
n > 0 && n != (size_t)-1 && n != (size_t)-2)
{
ps += n;
- n = wcrtomb(pbuf, fun_wc(wc), &mbs2);
+ n = wctomb(pbuf, fun_wc(wc));
if (n == (size_t)-1)
FATAL("illegal wide character %s", s);
@@ -1941,7 +1947,7 @@ const char *filename(FILE *fp)
Cell *x;
size_t i;
bool stat;
-
+
x = execute(a[0]);
getsval(x);
stat = true;