diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-05-20 18:30:30 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-05-20 18:30:30 -0700 |
| commit | cc6e25a06fdebbabe4b170ca5f43c399cfa0f70e (patch) | |
| tree | 4500372b307a519c4f127d6b6afbdbe7b9f328f0 | |
| parent | 78695e2aee9ad0e718842bc794f65a03279f3069 (diff) | |
Fix for broken escapes
| -rw-r--r-- | pattern.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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; |
