=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/awk/b.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- src/usr.bin/awk/b.c 2020/06/10 21:01:50 1.23 +++ src/usr.bin/awk/b.c 2020/06/10 21:02:19 1.24 @@ -1,4 +1,4 @@ -/* $OpenBSD: b.c,v 1.23 2020/06/10 21:01:50 millert Exp $ */ +/* $OpenBSD: b.c,v 1.24 2020/06/10 21:02:19 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -920,6 +920,7 @@ int i; int num, m, commafound, digitfound; const uschar *startreptok; + static int parens = 0; rescan: starttok = prestr; @@ -933,9 +934,18 @@ case '\0': prestr--; return '\0'; case '^': case '$': + return c; case '(': - case ')': + parens++; return c; + case ')': + if (parens) { + parens--; + return c; + } + /* unmatched close parenthesis; per POSIX, treat as literal */ + rlxval = c; + return CHAR; case '\\': rlxval = quoted(&prestr); return CHAR;