|
 |
074815 |
diff --git a/src/regcomp.c b/src/regcomp.c
|
|
 |
074815 |
index f953ed1..ae2caeb 100644
|
|
 |
074815 |
--- a/src/regcomp.c
|
|
 |
074815 |
+++ b/src/regcomp.c
|
|
 |
074815 |
@@ -1131,8 +1131,9 @@ compile_length_enclosure_node(EnclosureNode* node, regex_t* reg)
|
|
 |
074815 |
len += tlen;
|
|
 |
074815 |
}
|
|
 |
074815 |
|
|
 |
074815 |
+ len += SIZE_OP_JUMP + SIZE_OP_ATOMIC_END;
|
|
 |
074815 |
+
|
|
 |
074815 |
if (IS_NOT_NULL(Else)) {
|
|
 |
074815 |
- len += SIZE_OP_JUMP;
|
|
 |
074815 |
tlen = compile_length_tree(Else, reg);
|
|
 |
074815 |
if (tlen < 0) return tlen;
|
|
 |
074815 |
len += tlen;
|
|
 |
074815 |
@@ -1274,7 +1275,7 @@ compile_enclosure_node(EnclosureNode* node, regex_t* reg, ScanEnv* env)
|
|
 |
074815 |
|
|
 |
074815 |
case ENCLOSURE_IF_ELSE:
|
|
 |
074815 |
{
|
|
 |
074815 |
- int cond_len, then_len, jump_len;
|
|
 |
074815 |
+ int cond_len, then_len, else_len, jump_len;
|
|
 |
074815 |
Node* cond = NODE_ENCLOSURE_BODY(node);
|
|
 |
074815 |
Node* Then = node->te.Then;
|
|
 |
074815 |
Node* Else = node->te.Else;
|
|
 |
074815 |
@@ -1291,8 +1292,7 @@ compile_enclosure_node(EnclosureNode* node, regex_t* reg, ScanEnv* env)
|
|
 |
074815 |
else
|
|
 |
074815 |
then_len = 0;
|
|
 |
074815 |
|
|
 |
074815 |
- jump_len = cond_len + then_len + SIZE_OP_ATOMIC_END;
|
|
 |
074815 |
- if (IS_NOT_NULL(Else)) jump_len += SIZE_OP_JUMP;
|
|
 |
074815 |
+ jump_len = cond_len + then_len + SIZE_OP_ATOMIC_END + SIZE_OP_JUMP;
|
|
 |
074815 |
|
|
 |
074815 |
r = add_opcode_rel_addr(reg, OP_PUSH, jump_len);
|
|
 |
074815 |
if (r != 0) return r;
|
|
 |
074815 |
@@ -1307,9 +1307,19 @@ compile_enclosure_node(EnclosureNode* node, regex_t* reg, ScanEnv* env)
|
|
 |
074815 |
}
|
|
 |
074815 |
|
|
 |
074815 |
if (IS_NOT_NULL(Else)) {
|
|
 |
074815 |
- int else_len = compile_length_tree(Else, reg);
|
|
 |
074815 |
- r = add_opcode_rel_addr(reg, OP_JUMP, else_len);
|
|
 |
074815 |
- if (r != 0) return r;
|
|
 |
074815 |
+ else_len = compile_length_tree(Else, reg);
|
|
 |
074815 |
+ if (else_len < 0) return else_len;
|
|
 |
074815 |
+ }
|
|
 |
074815 |
+ else
|
|
 |
074815 |
+ else_len = 0;
|
|
 |
074815 |
+
|
|
 |
074815 |
+ r = add_opcode_rel_addr(reg, OP_JUMP, SIZE_OP_ATOMIC_END + else_len);
|
|
 |
074815 |
+ if (r != 0) return r;
|
|
 |
074815 |
+
|
|
 |
074815 |
+ r = add_opcode(reg, OP_ATOMIC_END);
|
|
 |
074815 |
+ if (r != 0) return r;
|
|
 |
074815 |
+
|
|
 |
074815 |
+ if (IS_NOT_NULL(Else)) {
|
|
 |
074815 |
r = compile_tree(Else, reg, env);
|
|
 |
074815 |
}
|
|
 |
074815 |
}
|