diff options
author | ozan yigit <ozan.yigit@gmail.com> | 2021-11-25 13:29:49 -0500 |
---|---|---|
committer | ozan yigit <ozan.yigit@gmail.com> | 2021-11-25 13:29:49 -0500 |
commit | 01749f04cf1366ac50d998c4747acc89549c082f (patch) | |
tree | c9ad0898eabe5ba1f4ee126379f7d00338b01bb4 | |
parent | cfe6b6b99d841c0f46d090265e0aa882feee411f (diff) | |
download | one-true-awk-01749f04cf1366ac50d998c4747acc89549c082f.tar.gz |
Revert "resolve parsing of a slash character within a cclass "/[/]/" without escape"
This reverts commit d91c473c7c187079a886fcbc27fc7955da52a8fd.
-rw-r--r-- | lex.c | 33 | ||||
-rwxr-xr-x | testdir/T.misc | 4 |
2 files changed, 6 insertions, 31 deletions
@@ -523,12 +523,11 @@ int regexpr(void) static char *buf = NULL; static int bufsz = 500; char *bp; - int brackets = 0; if (buf == NULL && (buf = (char *) malloc(bufsz)) == NULL) - FATAL("out of space for reg expr"); + FATAL("out of space for rex expr"); bp = buf; - for ( ; ((c = input()) != '/' || brackets > 0) && c != 0; ) { + for ( ; (c = input()) != '/' && c != 0; ) { if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, "regexpr")) FATAL("out of space for reg expr %.10s...", buf); if (c == '\n') { @@ -539,34 +538,6 @@ int regexpr(void) } else if (c == '\\') { *bp++ = '\\'; *bp++ = input(); - } else if (c == '[') { - *bp++ = c; - brackets++; - if ((c = input()) == '^') { - *bp++ = c; - if ((c = input()) == ']') { - *bp++ = c; - if ((c = input()) == '[') - *bp++ = c; - else - unput(c); - } else if (c == '[') { - *bp++ = c; - } else - unput(c); - } else if (c == ']') { /* []] is ok */ - *bp++ = c; - if ((c = input()) == '[') - *bp++ = c; - else - unput(c); - } else if (brackets == 1 && c == '[') { /* [[] is also ok */ - *bp++ = c; - } else - unput(c); - } else if (c == ']') { - *bp++ = c; - brackets--; } else { *bp++ = c; } diff --git a/testdir/T.misc b/testdir/T.misc index f12d459..ad34ab8 100755 --- a/testdir/T.misc +++ b/testdir/T.misc @@ -164,6 +164,10 @@ $awk 'BEGIN { unireghf() } function unireghf(hfeed) { hfeed[1] = 0 }' if test -r core; then echo 1>&2 "BAD: T.misc unireghf dropped core"; fi +echo x | $awk '/[/]/' 2>foo +grep 'nonterminated character class' foo >/dev/null || error 'BAD: T.misc nonterminated fails' +if test -r core; then echo 1>&2 "BAD: T.misc nonterminated dropped core"; fi + $awk ' function f() { return 12345 } BEGIN { printf "<%s>\n", f() } |