aboutsummaryrefslogtreecommitdiff
path: root/compiler.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-12 18:41:31 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-12 18:41:31 -0800
commitdbe3f0b7269fa28ff459586ac25d765395cace16 (patch)
tree4129acee4d4749690dd07e928eee044bc84429d2 /compiler.c
parent38bfd5ce0e6381954221c2a4d0b19c7c3ebcdf7d (diff)
Added some comments
Diffstat (limited to 'compiler.c')
-rw-r--r--compiler.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler.c b/compiler.c
index 0c8444c..1ed2481 100644
--- a/compiler.c
+++ b/compiler.c
@@ -268,6 +268,8 @@ vm_op_t *bp_simplepattern(file_t *f, const char *str)
size_t len = (size_t)(str - start);
char *literal = xcalloc(sizeof(char), len+1);
memcpy(literal, start, len);
+ // Note: an unescaped string is guaranteed to be no longer than the
+ // escaped string, so this is safe to do inplace.
len = unescape_string(literal, literal, len);
op->op = VM_STRING;
@@ -529,6 +531,8 @@ vm_op_t *bp_stringpattern(file_t *f, const char *str)
size_t len = (size_t)(str - start);
char *literal = xcalloc(sizeof(char), len+1);
memcpy(literal, start, len);
+ // Note: an unescaped string is guaranteed to be no longer than the
+ // escaped string, so this is safe to do inplace.
len = unescape_string(literal, literal, len);
strop->len = (ssize_t)len;
strop->args.s = literal;