aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-12 18:08:27 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-12 18:08:27 -0800
commitd7a9dec0df88afce06d6b6bf4060a7362682e13c (patch)
treebfefaba763ee777b35feaf23995273e9c95fd728
parent775d672c867ab68d7152d0f0ad58f548bbfda461 (diff)
Fixed issue where code relied on chain_together(NULL, ...)
-rw-r--r--compiler.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler.c b/compiler.c
index 5435a0d..0c8444c 100644
--- a/compiler.c
+++ b/compiler.c
@@ -14,7 +14,7 @@
__attribute__((nonnull)) static vm_op_t *expand_chain(file_t *f, vm_op_t *first);
__attribute__((nonnull)) static vm_op_t *expand_choices(file_t *f, vm_op_t *first);
-__attribute__((nonnull)) static vm_op_t *chain_together(vm_op_t *first, vm_op_t *second);
+static vm_op_t *chain_together(vm_op_t *first, vm_op_t *second);
__attribute__((nonnull(1,4))) static void set_range(vm_op_t *op, ssize_t min, ssize_t max, vm_op_t *pat, vm_op_t *sep);
/*
@@ -115,6 +115,8 @@ static vm_op_t *expand_choices(file_t *f, vm_op_t *first)
static vm_op_t *chain_together(vm_op_t *first, vm_op_t *second)
{
+ if (first == NULL) return second;
+ if (second == NULL) return first;
check(first->op != VM_CHAIN, "A chain should not be the first item in a chain.\n");
vm_op_t *chain = new(vm_op_t);
chain->op = VM_CHAIN;