aboutsummaryrefslogtreecommitdiffstats
path: root/yarp
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2023-09-19 15:25:13 -0400
committerKevin Newton <kddnewton@gmail.com>2023-09-27 11:25:53 -0400
commit2bc243b3dcd10d6de3efd80c3e91413d83b476fe (patch)
treeb8d79c3654c77e9d3e152a5058932eb67c9c64f1 /yarp
parent2000cf918358460f9d7da86fb253318fcdbe8e57 (diff)
downloadruby-2bc243b3dcd10d6de3efd80c3e91413d83b476fe.tar.gz
[YARP] Implement regex flags
This fixes the TODO in the code that was passing 0 instead of the regex flags.
Diffstat (limited to 'yarp')
-rw-r--r--yarp/yarp_compiler.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/yarp/yarp_compiler.c b/yarp/yarp_compiler.c
index a3994e387e..4b3e6ec11b 100644
--- a/yarp/yarp_compiler.c
+++ b/yarp/yarp_compiler.c
@@ -1795,8 +1795,21 @@ yp_compile_node(rb_iseq_t *iseq, const yp_node_t *node, LINK_ANCHOR *const ret,
if (!popped) {
yp_regular_expression_node_t *regular_expression_node = (yp_regular_expression_node_t *) node;
VALUE regex_str = parse_string(&regular_expression_node->unescaped);
- // TODO: Replace 0 with regex options
- VALUE regex = rb_reg_new(RSTRING_PTR(regex_str), RSTRING_LEN(regex_str), 0);
+ int flags = 0;
+
+ if (regular_expression_node->base.flags & YP_REGULAR_EXPRESSION_FLAGS_IGNORE_CASE) {
+ flags |= ONIG_OPTION_IGNORECASE;
+ }
+
+ if (regular_expression_node->base.flags & YP_REGULAR_EXPRESSION_FLAGS_MULTI_LINE) {
+ flags |= ONIG_OPTION_MULTILINE;
+ }
+
+ if (regular_expression_node->base.flags & YP_REGULAR_EXPRESSION_FLAGS_EXTENDED) {
+ flags |= ONIG_OPTION_EXTEND;
+ }
+
+ VALUE regex = rb_reg_new(RSTRING_PTR(regex_str), RSTRING_LEN(regex_str), flags);
ADD_INSN1(ret, &dummy_line_node, putobject, regex);
}
return;