This file lists all bug fixes, changes, etc., made since the
second edition of the AWK book was published in September 2023.
+Jan 22, 2024:
+ Restore the ability to compile with g++. Thanks to
+ Arnold Robbins.
+
+Dec 24, 2023:
+ matchop dereference after free problem fix when the first
+ argument is a function call. thanks to Oguz Ismail Uysal.
+ Fix inconsistent handling of --csv and FS set in the
+ command line. Thanks to Wilbert van der Poel.
+ casting changes to int for is* functions.
+
Nov 27, 2023:
Fix exit status of system on MacOS. update to REGRESS.
Thanks to Arnold Robbins.
Fix inconsistent handling of -F and --csv, and loss of csv
- mode when FS is set. Thanks to Wilbert van der Poel.
+ mode when FS is set.
Nov 24, 2023:
Fix issue #199: gototab improvements to dynamically resize the
-/* $OpenBSD: b.c,v 1.49 2023/11/25 16:31:33 millert Exp $ */
+/* $OpenBSD: b.c,v 1.50 2024/01/25 16:40:51 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
static int get_gototab(fa*, int, int);
static int set_gototab(fa*, int, int, int);
static void clear_gototab(fa*, int);
-extern int u8_rune(int *, const uschar *);
+extern int u8_rune(int *, const char *);
static int *
intalloc(size_t n, const char *f)
FATAL("out of space for character class [%.10s...] 1", p);
bp = buf;
for (i = 0; *p != 0; ) {
- n = u8_rune(&c, p);
+ n = u8_rune(&c, (const char *) p);
p += n;
if (c == '\\') {
c = quoted(&p);
if (*p != 0) {
c = bp[-1];
/* c2 = *p++; */
- n = u8_rune(&c2, p);
+ n = u8_rune(&c2, (const char *) p);
p += n;
if (c2 == '\\')
c2 = quoted(&p); /* BUG: sets p, has to be u8 size */
key.ch = ch;
key.state = 0; /* irrelevant */
- item = bsearch(& key, f->gototab[state].entries,
+ item = (gtte *) bsearch(& key, f->gototab[state].entries,
f->gototab[state].inuse, sizeof(gtte),
entry_cmp);
key.ch = ch;
key.state = 0; /* irrelevant */
- item = bsearch(& key, f->gototab[state].entries,
+ item = (gtte *) bsearch(& key, f->gototab[state].entries,
f->gototab[state].inuse, sizeof(gtte),
entry_cmp);
return(1);
do {
/* assert(*p < NCHARS); */
- n = u8_rune(&rune, p);
+ n = u8_rune(&rune, (const char *) p);
if ((ns = get_gototab(f, s, rune)) != 0)
s = ns;
else
if (f->out[s]) /* final state */
patlen = q-p;
/* assert(*q < NCHARS); */
- n = u8_rune(&rune, q);
+ n = u8_rune(&rune, (const char *) q);
if ((ns = get_gototab(f, s, rune)) != 0)
s = ns;
else
s = 2;
if (*p == 0)
break;
- n = u8_rune(&rune, p);
+ n = u8_rune(&rune, (const char *) p);
p += n;
} while (1); /* was *p++ */
return (0);
if (f->out[s]) /* final state */
patlen = q-p;
/* assert(*q < NCHARS); */
- n = u8_rune(&rune, q);
+ n = u8_rune(&rune, (const char *) q);
if ((ns = get_gototab(f, s, rune)) != 0)
s = ns;
else
}
}
- j += u8_rune(&c, (uschar *)j);
+ j += u8_rune(&c, j);
if ((ns = get_gototab(pfa, s, c)) != 0)
s = ns;
break; /* best match found */
/* no match at origin i, next i and start over */
- i += u8_rune(&c, (uschar *)i);
+ i += u8_rune(&c, i);
if (c == 0)
break; /* no match */
j = i;
return 0;
}
-extern int u8_rune(int *, const uschar *); /* run.c; should be in header file */
-
int relex(void) /* lexical analyzer for reparse */
{
int c, n;
rescan:
starttok = prestr;
- if ((n = u8_rune(&rlxval, prestr)) > 1) {
+ if ((n = u8_rune(&rlxval, (const char *) prestr)) > 1) {
prestr += n;
starttok = prestr;
return CHAR;
if (!adjbuf((char **) &buf, &bufsz, n, n, (char **) &bp, "relex1"))
FATAL("out of space for reg expr %.10s...", lastre);
for (; ; ) {
- if ((n = u8_rune(&rlxval, prestr)) > 1) {
+ if ((n = u8_rune(&rlxval, (const char *) prestr)) > 1) {
for (i = 0; i < n; i++)
*bp++ = *prestr++;
continue;
-/* $OpenBSD: main.c,v 1.67 2023/11/28 20:54:38 millert Exp $ */
+/* $OpenBSD: main.c,v 1.68 2024/01/25 16:40:51 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
THIS SOFTWARE.
****************************************************************/
-const char *version = "version 20231127";
+const char *version = "version 20240122";
#define DEBUG
#include <stdio.h>
}
if (strcmp(argv[1], "--csv") == 0) { /* turn on csv input processing */
CSV = true;
- if (fs)
- WARNING("danger: don't set FS when --csv is in effect");
argc--;
argv++;
continue;
break;
case 'F': /* set field separator */
fs = setfs(getarg(&argc, &argv, "no field separator"));
- if (CSV)
- WARNING("danger: don't set FS when --csv is in effect");
break;
case 'v': /* -v a=1 to be done NOW. one -v for each */
vn = getarg(&argc, &argv, "no variable name");
}
}
+ if (CSV && (fs != NULL || lookup("FS", symtab) != NULL))
+ WARNING("danger: don't set FS when --csv is in effect");
+
/* argv[1] is now the first argument */
if (npfile == 0) { /* no -f; first argument is program */
if (argc <= 1) {
-/* $OpenBSD: run.c,v 1.83 2023/11/28 20:54:38 millert Exp $ */
+/* $OpenBSD: run.c,v 1.84 2024/01/25 16:40:51 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
Cell *matchop(Node **a, int n) /* ~ and match() */
{
- Cell *x, *y;
+ Cell *x, *y, *z;
char *s, *t;
int i;
int cstart, cpatlen, len;
i = (*mf)(pfa, s);
tempfree(y);
}
- tempfree(x);
+ z = x;
if (n == MATCHFCN) {
int start = patbeg - s + 1; /* origin 1 */
if (patlen < 0) {
x = gettemp();
x->tval = NUM;
x->fval = start;
- return x;
} else if ((n == MATCH && i == 1) || (n == NOTMATCH && i == 0))
- return(True);
+ x = True;
else
- return(False);
+ x = False;
+
+ tempfree(z);
+ return x;
}
if (bs == NULL) { // invalid character
// use unicode invalid character, 0xFFFD
- bs = "\357\277\275";
+ static char invalid_char[] = "\357\277\275";
+ bs = invalid_char;
count = 3;
}
t = bs;
start = getsval(x);
while (pmatch(pfa, start)) {
if (buf == NULL) {
- if ((pb = buf = malloc(bufsz)) == NULL)
+ if ((pb = buf = (char *) malloc(bufsz)) == NULL)
FATAL("out of memory in dosub");
tempstat = pfa->initstat;
pfa->initstat = 2;
int mflag, tempstat, num, whichm;
int bufsz = recsize;
- if ((buf = malloc(bufsz)) == NULL)
+ if ((buf = (char *) malloc(bufsz)) == NULL)
FATAL("out of memory in gensub");
mflag = 0; /* if mflag == 0, can replace empty string */
num = 0;