aboutsummaryrefslogtreecommitdiff
path: root/b.c
diff options
context:
space:
mode:
authorCody Peter Mello <melloc@writev.io>2018-11-12 10:25:44 -0800
committerCody Peter Mello <melloc@writev.io>2018-11-12 10:25:44 -0800
commita6392ef31cbfee50d5b7dfd17dbfbbf2f49484b8 (patch)
tree4f4d78190abadb6033163152c76ce841cc7c40ee /b.c
parent2dc7e5ff1a4feeeb549f32706cf34e17aba89192 (diff)
downloadone-true-awk-a6392ef31cbfee50d5b7dfd17dbfbbf2f49484b8.tar.gz
Fix regular expressions containing [[:cntrl:]]
Diffstat (limited to 'b.c')
-rw-r--r--b.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/b.c b/b.c
index 89a7841..a54a234 100644
--- a/b.c
+++ b/b.c
@@ -823,7 +823,15 @@ int relex(void) /* lexical analyzer for reparse */
if (cc->cc_name != NULL && prestr[1 + cc->cc_namelen] == ':' &&
prestr[2 + cc->cc_namelen] == ']') {
prestr += cc->cc_namelen + 3;
- for (i = 0; i < NCHARS; i++) {
+ /*
+ * BUG: We begin at 1, instead of 0, since we
+ * would otherwise prematurely terminate the
+ * string for classes like [[:cntrl:]]. This
+ * means that we can't match the NUL character,
+ * not without first adapting the entire
+ * program to track each string's length.
+ */
+ for (i = 1; i < NCHARS; i++) {
if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, "relex2"))
FATAL("out of space for reg expr %.10s...", lastre);
if (cc->cc_func(i)) {