diff --git a/src/cre2/cre2.cpp b/src/cre2/cre2.cpp index 51d0906..7f07a7f 100644 --- a/src/cre2/cre2.cpp +++ b/src/cre2/cre2.cpp @@ -22,6 +22,7 @@ OPT_bool(longest_match) OPT_bool(log_errors) OPT_bool(literal) OPT_bool(never_nl) +OPT_bool(dot_nl) OPT_bool(case_sensitive) OPT_bool(perl_classes) OPT_bool(word_boundary) diff --git a/src/cre2/cre2.cr b/src/cre2/cre2.cr index 00c3fb9..45fe6e5 100644 --- a/src/cre2/cre2.cr +++ b/src/cre2/cre2.cr @@ -14,6 +14,7 @@ lib LibCre2 fun opt_perl_classes = cre2_opt_perl_classes(op : Options, flag : Bool) : Nil fun opt_word_boundary = cre2_opt_word_boundary(op : Options, flag : Bool) : Nil fun opt_one_line = cre2_opt_one_line(op : Options, flag : Bool) : Nil + fun opt_dot_nl = cre2_opt_dot_nl(op : Options, flag : Bool) : Nil fun opt_encoding = cre2_opt_encoding(op : Options, encoding : Int32) : Nil fun opt_max_mem = cre2_opt_max_mem(op : Options, flag : Bool) : Nil diff --git a/src/cre2/cre2.h b/src/cre2/cre2.h index 7d29997..ccd7601 100644 --- a/src/cre2/cre2.h +++ b/src/cre2/cre2.h @@ -21,6 +21,7 @@ void cre2_opt_case_sensitive(cre2_options *opt, int flag); void cre2_opt_perl_classes(cre2_options *opt, int flag); void cre2_opt_word_boundary(cre2_options *opt, int flag); void cre2_opt_one_line(cre2_options *opt, int flag); +void cre2_opt_dot_nl(cre2_options *opt, int flag); void cre2_opt_encoding(cre2_options *opt, encoding_t enc); void cre2_opt_max_mem(cre2_options *opt, int m); diff --git a/src/cre2/cre2.o b/src/cre2/cre2.o index a87fe4f..a856296 100644 Binary files a/src/cre2/cre2.o and b/src/cre2/cre2.o differ diff --git a/src/rules.cr b/src/rules.cr index 5efb81a..e500ec6 100644 --- a/src/rules.cr +++ b/src/rules.cr @@ -125,12 +125,16 @@ module Tartrazine ignorecase = false, anchored = false) @opts = LibCre2.opt_new LibCre2.opt_posix_syntax(@opts, false) - LibCre2.opt_longest_match(@opts, true) - LibCre2.opt_perl_classes(@opts, true) + LibCre2.opt_longest_match(@opts, false) + # These 3 are ignored when posix_syntax is false + # LibCre2.opt_one_line(@opts, !multiline) + # LibCre2.opt_perl_classes(@opts, true) + # LibCre2.opt_word_boundary(@opts, true) LibCre2.opt_encoding(@opts, 1) - LibCre2.opt_one_line(@opts, !multiline) LibCre2.opt_case_sensitive(@opts, !ignorecase) + LibCre2.opt_dot_nl(@opts, dotall) pattern = "(m?)#{pattern}" if multiline + p! pattern @re = LibCre2.new(pattern, pattern.size, @opts) end @@ -142,6 +146,10 @@ module Tartrazine end end -re = Tartrazine::Re3.new("(require-instance|fraction-digits|error-app-tag|error-message|min-elements|max-elements|yin-element|ordered-by|position|modifier|default|pattern|length|status|units|value|range|type|path|enum|base|bit)(?=[^\w\-\:])") -p! re.match("value ", 0) + +# I can't find a combination of flags that makes this match "#foo" +# and without that this is never going to work. +re = Tartrazine::Re3.new("#.*$", multiline: true, dotall: false) +m = re.match("#foo\nbar", 0) +p m[0], m[1][0]