diff options
author | 2020-06-23 16:54:40 +0000 | |
---|---|---|
committer | 2020-06-23 16:54:40 +0000 | |
commit | 4cbae565acf2915ab04aa7e75c48ce77fd4c9a5f (patch) | |
tree | d39385fdc6a2d2179d2956f838547250ebceb42e | |
parent | Revert previous. hashfree() just calls free() which handles NULL with (diff) | |
download | wireguard-openbsd-4cbae565acf2915ab04aa7e75c48ce77fd4c9a5f.tar.xz wireguard-openbsd-4cbae565acf2915ab04aa7e75c48ce77fd4c9a5f.zip |
When parsing a character class don't increment openclass for a literal '['.
This allows expressions like '/[[/[]/' to parse which are also
allowed by gawk.
-rw-r--r-- | usr.bin/awk/lex.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/awk/lex.c b/usr.bin/awk/lex.c index cfe7faac44c..61963f4ff96 100644 --- a/usr.bin/awk/lex.c +++ b/usr.bin/awk/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.21 2020/06/13 01:21:01 millert Exp $ */ +/* $OpenBSD: lex.c,v 1.22 2020/06/23 16:54:40 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -551,8 +551,10 @@ int regexpr(void) */ if (!do_posix) { if (c == '[') { - if (++openclass == 1) - cstart = bp; + if (openclass == 0 || peek() == ':') { + if (++openclass == 1) + cstart = bp; + } } else if (c == ']' && openclass > 0) { /* * A ']' as the first char in a |