From cc6e25a06fdebbabe4b170ca5f43c399cfa0f70e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 20 May 2021 18:30:30 -0700 Subject: Fix for broken escapes --- pattern.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pattern.c b/pattern.c index 98f2c27..7459cd5 100644 --- a/pattern.c +++ b/pattern.c @@ -1,7 +1,6 @@ // // pattern.c - Compile strings into BP pattern objects that can be matched against. // - #include #include #include @@ -300,10 +299,16 @@ static pat_t *_bp_simplepattern(file_t *f, const char *str) esc->args.range.low = e; esc->args.range.high = e2; return esc; + } else if (str > opstart) { + pat_t *esc = new_pat(f, start, str, 1, 1, BP_STRING); + char *s = xcalloc(sizeof(char), 2); + s[0] = (char)e; + esc->args.string = s; + return esc; } else { const char *next = next_char(f, opstart); size_t len = (size_t)(next-opstart); - pat_t *esc = new_pat(f, opstart, next, len, (ssize_t)len, BP_STRING); + pat_t *esc = new_pat(f, start, next, len, (ssize_t)len, BP_STRING); char *s = xcalloc(sizeof(char), 1+len); memcpy(s, opstart, len); esc->args.string = s; -- cgit v1.2.3