ext/re2/re2.cc in re2-1.1.1 vs ext/re2/re2.cc in re2-1.2.0
- old
+ new
@@ -256,11 +256,11 @@
if (matches[i].empty()) {
rb_ary_push(result, Qnil);
} else {
rb_ary_push(result, ENCODED_STR_NEW(matches[i].data(),
matches[i].size(),
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1"));
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1"));
}
}
/* Check whether we've exhausted the input yet. */
c->eof = new_input_size == 0;
@@ -359,11 +359,11 @@
return Qnil;
} else {
offset = reinterpret_cast<uintptr_t>(match->data()) - reinterpret_cast<uintptr_t>(StringValuePtr(m->text));
return ENCODED_STR_SUBLEN(StringValue(m->text), offset,
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1");
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1");
}
}
/*
* Returns the offset of the character following the end of the nth element of the matchdata.
@@ -390,11 +390,11 @@
return Qnil;
} else {
offset = reinterpret_cast<uintptr_t>(match->data()) - reinterpret_cast<uintptr_t>(StringValuePtr(m->text)) + match->size();
return ENCODED_STR_SUBLEN(StringValue(m->text), offset,
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1");
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1");
}
}
/*
* Returns the {RE2::Regexp} used in the match.
@@ -454,11 +454,11 @@
if (match->empty()) {
rb_ary_push(array, Qnil);
} else {
rb_ary_push(array, ENCODED_STR_NEW(match->data(), match->size(),
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1"));
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1"));
}
}
return array;
}
@@ -478,11 +478,11 @@
if (match->empty()) {
return Qnil;
} else {
return ENCODED_STR_NEW(match->data(), match->size(),
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1");
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1");
}
}
}
static VALUE re2_matchdata_named_match(const char* name, VALUE self) {
@@ -609,11 +609,11 @@
}
output << ">";
result = ENCODED_STR_NEW(output.str().data(), output.str().length(),
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1");
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1");
return result;
}
/*
@@ -682,11 +682,11 @@
RE2::Options re2_options;
utf8 = rb_hash_aref(options, ID2SYM(id_utf8));
if (!NIL_P(utf8)) {
- re2_options.set_utf8(RTEST(utf8));
+ re2_options.set_encoding(RTEST(utf8) ? RE2::Options::EncodingUTF8 : RE2::Options::EncodingLatin1);
}
posix_syntax = rb_hash_aref(options, ID2SYM(id_posix_syntax));
if (!NIL_P(posix_syntax)) {
re2_options.set_posix_syntax(RTEST(posix_syntax));
@@ -765,11 +765,11 @@
Data_Get_Struct(self, re2_pattern, p);
output << "#<RE2::Regexp /" << p->pattern->pattern() << "/>";
result = ENCODED_STR_NEW(output.str().data(), output.str().length(),
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1");
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1");
return result;
}
/*
@@ -783,11 +783,11 @@
static VALUE re2_regexp_to_s(VALUE self) {
re2_pattern *p;
Data_Get_Struct(self, re2_pattern, p);
return ENCODED_STR_NEW(p->pattern->pattern().data(),
p->pattern->pattern().size(),
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1");
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1");
}
/*
* Returns whether or not the regular expression +re2+
* was compiled successfully or not.
@@ -813,11 +813,11 @@
* re2.utf8? #=> true
*/
static VALUE re2_regexp_utf8(VALUE self) {
re2_pattern *p;
Data_Get_Struct(self, re2_pattern, p);
- return BOOL2RUBY(p->pattern->options().utf8());
+ return BOOL2RUBY(p->pattern->options().encoding() == RE2::Options::EncodingUTF8);
}
/*
* Returns whether or not the regular expression +re2+
* was compiled with the posix_syntax option set to true.
@@ -1010,11 +1010,11 @@
if (p->pattern->ok()) {
return Qnil;
} else {
return ENCODED_STR_NEW(p->pattern->error_arg().data(),
p->pattern->error_arg().size(),
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1");
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1");
}
}
/*
* Returns the program size, a very approximate measure
@@ -1041,11 +1041,11 @@
Data_Get_Struct(self, re2_pattern, p);
options = rb_hash_new();
rb_hash_aset(options, ID2SYM(id_utf8),
- BOOL2RUBY(p->pattern->options().utf8()));
+ BOOL2RUBY(p->pattern->options().encoding() == RE2::Options::EncodingUTF8));
rb_hash_aset(options, ID2SYM(id_posix_syntax),
BOOL2RUBY(p->pattern->options().posix_syntax()));
rb_hash_aset(options, ID2SYM(id_longest_match),
@@ -1111,11 +1111,11 @@
capturing_groups = rb_hash_new();
for (iterator = groups.begin(); iterator != groups.end(); iterator++) {
rb_hash_aset(capturing_groups,
ENCODED_STR_NEW(iterator->first.data(), iterator->first.size(),
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1"),
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1"),
INT2FIX(iterator->second));
}
return capturing_groups;
}
@@ -1282,11 +1282,11 @@
if (rb_obj_is_kind_of(pattern, re2_cRegexp)) {
Data_Get_Struct(pattern, re2_pattern, p);
RE2::Replace(&str_as_string, *p->pattern, StringValuePtr(rewrite));
return ENCODED_STR_NEW(str_as_string.data(), str_as_string.size(),
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1");
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1");
} else {
RE2::Replace(&str_as_string, StringValuePtr(pattern),
StringValuePtr(rewrite));
return ENCODED_STR_NEW2(str_as_string.data(), str_as_string.size(),
@@ -1319,10 +1319,10 @@
if (rb_obj_is_kind_of(pattern, re2_cRegexp)) {
Data_Get_Struct(pattern, re2_pattern, p);
RE2::GlobalReplace(&str_as_string, *p->pattern, StringValuePtr(rewrite));
return ENCODED_STR_NEW(str_as_string.data(), str_as_string.size(),
- p->pattern->options().utf8() ? "UTF-8" : "ISO-8859-1");
+ p->pattern->options().encoding() == RE2::Options::EncodingUTF8 ? "UTF-8" : "ISO-8859-1");
} else {
RE2::GlobalReplace(&str_as_string, StringValuePtr(pattern),
StringValuePtr(rewrite));
return ENCODED_STR_NEW2(str_as_string.data(), str_as_string.size(),