aboutsummaryrefslogtreecommitdiff
path: root/pattern.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-05-20 18:30:30 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-05-20 18:30:30 -0700
commitcc6e25a06fdebbabe4b170ca5f43c399cfa0f70e (patch)
tree4500372b307a519c4f127d6b6afbdbe7b9f328f0 /pattern.c
parent78695e2aee9ad0e718842bc794f65a03279f3069 (diff)
Fix for broken escapes
Diffstat (limited to 'pattern.c')
-rw-r--r--pattern.c9
1 files 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 <ctype.h>
#include <err.h>
#include <stdbool.h>
@@ -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;