aboutsummaryrefslogtreecommitdiff
path: root/cutl
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-08-28 14:53:07 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-08-28 14:53:07 +0200
commitbe8833cb1ac9ce81aa0e3cac4cbb319f6d8875d4 (patch)
treeb1b2deb5880d8c695ea4b50be8d4e34ad71e0a78 /cutl
parentd7db1649a63eb9e2e95bef7d2983281d1e859319 (diff)
Tighten up regex implementation
Diffstat (limited to 'cutl')
-rw-r--r--cutl/re/re.cxx36
1 files changed, 26 insertions, 10 deletions
diff --git a/cutl/re/re.cxx b/cutl/re/re.cxx
index c996f4e..95a6411 100644
--- a/cutl/re/re.cxx
+++ b/cutl/re/re.cxx
@@ -39,13 +39,19 @@ namespace cutl
{
typedef basic_string<C> string_type;
typedef tr1::basic_regex<C> regex_type;
+ typedef typename regex_type::flag_type flag_type;
impl () {}
- impl (string_type const& s, bool icase)
- : r (s,
- tr1::regex_constants::ECMAScript |
- (icase ? tr1::regex_constants::icase : 0)) {}
impl (regex_type const& r): r (r) {}
+ impl (string_type const& s, bool icase)
+ {
+ flag_type f (tr1::regex_constants::ECMAScript);
+
+ if (icase)
+ f |= tr1::regex_constants::icase;
+
+ r.assign (s, f);
+ }
regex_type r;
};
@@ -109,9 +115,14 @@ namespace cutl
if (impl_ == 0)
impl_ = s == 0 ? new impl : new impl (*s, icase);
else
- impl_->r.assign (*s,
- tr1::regex_constants::ECMAScript |
- (icase ? tr1::regex_constants::icase : 0));
+ {
+ impl::flag_type f (tr1::regex_constants::ECMAScript);
+
+ if (icase)
+ f |= tr1::regex_constants::icase;
+
+ impl_->r.assign (*s, f);
+ }
}
catch (tr1::regex_error const& e)
{
@@ -132,9 +143,14 @@ namespace cutl
if (impl_ == 0)
impl_ = s == 0 ? new impl : new impl (*s, icase);
else
- impl_->r.assign (*s,
- tr1::regex_constants::ECMAScript |
- (icase ? tr1::regex_constants::icase : 0));
+ {
+ impl::flag_type f (tr1::regex_constants::ECMAScript);
+
+ if (icase)
+ f |= tr1::regex_constants::icase;
+
+ impl_->r.assign (*s, f);
+ }
}
catch (tr1::regex_error const& e)
{