This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [libstdc++/61227] Support regex like "[\w]"
- From: Tim Shen <timshen91 at gmail dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>, Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 19 May 2014 20:38:14 -0400
- Subject: Re: [libstdc++/61227] Support regex like "[\w]"
- Authentication-results: sourceware.org; auth=none
- References: <CAPrifD=M_HiwPuzCs=TEzg9_hB_xnpp4KbGG6VgFwd_zdYnD7Q at mail dot gmail dot com> <20140519184959 dot GL29145 at redhat dot com>
On Mon, May 19, 2014 at 11:28 AM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
> I suggest rewording this or avoiding it completely.
Sorry, I just can't tolerate my former quick & dirty code.
On Mon, May 19, 2014 at 2:49 PM, Jonathan Wakely <jwakely@redhat.com> wrote:
> I'm going to check in my factoring patches soon, so there's no need to
> add this comment.
Oops, but I already make another patch before reading this email. I
suppose it's not needed?
--
Regards,
Tim Shen
commit 7d75ac590f1a7d160c098f94604b55ba0a598b4d
Author: tim <timshen91@gmail.com>
Date: Mon May 19 14:13:18 2014 -0400
temp
diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h
index 52f7235..1663ee0 100644
--- a/libstdc++-v3/include/bits/regex_compiler.h
+++ b/libstdc++-v3/include/bits/regex_compiler.h
@@ -416,7 +416,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private:
bool
- _M_apply(_CharT __ch, false_type) const;
+ _M_apply_impl(_CharT __ch) const;
+
+ bool
+ _M_apply(_CharT __ch, false_type) const
+ { return _M_apply_impl(__ch) ^ _M_is_non_matching; }
bool
_M_apply(_CharT __ch, true_type) const
diff --git a/libstdc++-v3/include/bits/regex_compiler.tcc b/libstdc++-v3/include/bits/regex_compiler.tcc
index 472cf1f..bfc2489 100644
--- a/libstdc++-v3/include/bits/regex_compiler.tcc
+++ b/libstdc++-v3/include/bits/regex_compiler.tcc
@@ -509,42 +509,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _TraitsT, bool __icase, bool __collate>
bool
_BracketMatcher<_TraitsT, __icase, __collate>::
- _M_apply(_CharT __ch, false_type) const
+ _M_apply_impl(_CharT __ch) const
{
- bool __ret = false;
if (std::find(_M_char_set.begin(), _M_char_set.end(),
_M_translator._M_translate(__ch))
!= _M_char_set.end())
- __ret = true;
- else
- {
- auto __s = _M_translator._M_transform(__ch);
- for (auto& __it : _M_range_set)
- if (__it.first <= __s && __s <= __it.second)
- {
- __ret = true;
- break;
- }
- if (_M_traits.isctype(__ch, _M_class_set))
- __ret = true;
- else if (std::find(_M_equiv_set.begin(), _M_equiv_set.end(),
- _M_traits.transform_primary(&__ch, &__ch+1))
- != _M_equiv_set.end())
- __ret = true;
- else
- {
- for (auto& __it : _M_neg_class_set)
- if (!_M_traits.isctype(__ch, __it))
- {
- __ret = true;
- break;
- }
- }
- }
- if (_M_is_non_matching)
- return !__ret;
- else
- return __ret;
+ return true;
+
+ auto __s = _M_translator._M_transform(__ch);
+ for (auto& __it : _M_range_set)
+ if (__it.first <= __s && __s <= __it.second)
+ return true;
+
+ if (_M_traits.isctype(__ch, _M_class_set))
+ return true;
+
+ if (std::find(_M_equiv_set.begin(), _M_equiv_set.end(),
+ _M_traits.transform_primary(&__ch, &__ch+1))
+ != _M_equiv_set.end())
+ return true;
+
+ for (auto& __it : _M_neg_class_set)
+ if (!_M_traits.isctype(__ch, __it))
+ return true;
+
+ return false;
}
_GLIBCXX_END_NAMESPACE_VERSION