Skip to content

Commit

Permalink
Merge pull request lh3#23 from melloc/cntrl-class
Browse files Browse the repository at this point in the history
Fix regular expressions containing [[:cntrl:]]
  • Loading branch information
onetrueawk authored Jan 21, 2019
2 parents d3d7d3d + a6392ef commit 55d20ec
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion b.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 55d20ec

Please sign in to comment.