summaryrefslogtreecommitdiff
path: root/usr.bin/awk/lex.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/awk/lex.c')
-rw-r--r--usr.bin/awk/lex.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/awk/lex.c b/usr.bin/awk/lex.c
index 737f589ea66..eaf09d1cd45 100644
--- a/usr.bin/awk/lex.c
+++ b/usr.bin/awk/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.8 2004/12/30 01:52:48 millert Exp $ */
+/* $OpenBSD: lex.c,v 1.9 2006/04/16 02:10:18 hugh Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -514,7 +514,7 @@ void startreg(void) /* next call to yylex will return a regular expression */
int regexpr(void)
{
- int c;
+ int c, openclass = 0;
static char *buf = 0;
static int bufsz = 500;
char *bp;
@@ -522,7 +522,7 @@ int regexpr(void)
if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL)
FATAL("out of space for rex expr");
bp = buf;
- for ( ; (c = input()) != '/' && c != 0; ) {
+ for ( ; ((c = input()) != '/' || openclass == 1) && c != 0; ) {
if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, 0))
FATAL("out of space for reg expr %.10s...", buf);
if (c == '\n') {
@@ -533,6 +533,10 @@ int regexpr(void)
*bp++ = '\\';
*bp++ = input();
} else {
+ if (c == '[')
+ openclass = 1;
+ else if (c == ']')
+ openclass = 0;
*bp++ = c;
}
}