summaryrefslogtreecommitdiff
path: root/usr.bin/awk
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
parent7f5faee3631066d04328aa8e22bb66aa75bff109 (diff)
Update awk to August 7, 2020 version.
Diffstat (limited to 'usr.bin/awk')
-rw-r--r--usr.bin/awk/FIXES12
-rw-r--r--usr.bin/awk/main.c4
-rw-r--r--usr.bin/awk/run.c22
-rw-r--r--usr.bin/awk/tran.c8
4 files changed, 31 insertions, 15 deletions
diff --git a/usr.bin/awk/FIXES b/usr.bin/awk/FIXES
index 4f63d5c61f2..8341575f2c8 100644
--- a/usr.bin/awk/FIXES
+++ b/usr.bin/awk/FIXES
@@ -1,4 +1,4 @@
-/* $OpenBSD: FIXES,v 1.37 2020/07/30 17:45:44 millert Exp $ */
+/* $OpenBSD: FIXES,v 1.38 2020/08/11 16:57:05 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -26,6 +26,16 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.
+August 7, 2020:
+ Merge PR #93, which adds casts to (void*) for debug prints
+ using the %p format specifier. Thanks to GitHub user YongHaoWu
+ ("Chris") for the fixes.
+
+August 4, 2020:
+ In run.c, use non-restartable multibyte routines to attain
+ portability to DJGPP. Should fix Issue 92. Thanks to Albert Wik
+ for the report and to Todd Miller for the suggested fix.
+
July 30, 2020:
Merge PRs 88-91 which fix small bugs. Thanks to Todd Miller and
Tim van der Molen for the fixes.
diff --git a/usr.bin/awk/main.c b/usr.bin/awk/main.c
index 47ac56d1833..9ffbf736b65 100644
--- a/usr.bin/awk/main.c
+++ b/usr.bin/awk/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.44 2020/07/30 17:45:44 millert Exp $ */
+/* $OpenBSD: main.c,v 1.45 2020/08/11 16:57:05 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 20200730";
+const char *version = "version 20200807";
#define DEBUG
#include <stdio.h>
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;
diff --git a/usr.bin/awk/tran.c b/usr.bin/awk/tran.c
index 8f96c33dc97..ea67e6f2fc5 100644
--- a/usr.bin/awk/tran.c
+++ b/usr.bin/awk/tran.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tran.c,v 1.30 2020/07/30 17:45:44 millert Exp $ */
+/* $OpenBSD: tran.c,v 1.31 2020/08/11 16:57:05 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -362,7 +362,7 @@ char *setsval(Cell *vp, const char *s) /* set string val of a Cell */
fldno = atoi(vp->nval);
if (fldno > *NF)
newfld(fldno);
- DPRINTF("setting field %d to %s (%p)\n", fldno, s, s);
+ DPRINTF("setting field %d to %s (%p)\n", fldno, s, (const void*)s);
} else if (isrec(vp)) {
donefld = false; /* mark $1... invalid */
donerec = true;
@@ -379,7 +379,7 @@ char *setsval(Cell *vp, const char *s) /* set string val of a Cell */
vp->fmt = NULL;
setfree(vp);
DPRINTF("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",
- (void*)vp, NN(vp->nval), t, t, vp->tval, donerec, donefld);
+ (void*)vp, NN(vp->nval), t, (void*)t, vp->tval, donerec, donefld);
vp->sval = t;
if (&vp->fval == NF) {
donerec = false; /* mark $0 invalid */
@@ -494,7 +494,7 @@ static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cel
}
done:
DPRINTF("getsval %p: %s = \"%s (%p)\", t=%o\n",
- (void*)vp, NN(vp->nval), vp->sval, vp->sval, vp->tval);
+ (void*)vp, NN(vp->nval), vp->sval, (void*)vp->sval, vp->tval);
return(vp->sval);
}