aboutsummaryrefslogtreecommitdiff
path: root/pattern.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-05-20 17:39:27 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-05-20 17:39:27 -0700
commit78695e2aee9ad0e718842bc794f65a03279f3069 (patch)
tree09cd7d680d3a343bafd835db6fe30ab8e87cb2f7 /pattern.c
parent8df68fa86959e18b9b1ac2898f5293a6eab91a29 (diff)
Fixed backslash escape for single utf8 chars.
Diffstat (limited to 'pattern.c')
-rw-r--r--pattern.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/pattern.c b/pattern.c
index d11fdcb..98f2c27 100644
--- a/pattern.c
+++ b/pattern.c
@@ -301,9 +301,11 @@ static pat_t *_bp_simplepattern(file_t *f, const char *str)
esc->args.range.high = e2;
return esc;
} else {
- pat_t *esc = new_pat(f, opstart, str, 1, 1, BP_STRING);
- char *s = xcalloc(sizeof(char), 2);
- s[0] = (char)e;
+ 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);
+ char *s = xcalloc(sizeof(char), 1+len);
+ memcpy(s, opstart, len);
esc->args.string = s;
return esc;
}