aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-22 23:42:37 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-22 23:42:37 +0000
commit3dff7b48a4c922e5606ee09d80130f7e4e4fbcf1 (patch)
tree7a62c223a073cac6175925a89527a4ae758cbf02
parent4ea38620d285277f4aa1f6d68a5b6fd2cab1a384 (diff)
downloadpaludis-3dff7b48a4c922e5606ee09d80130f7e4e4fbcf1.tar.gz
paludis-3dff7b48a4c922e5606ee09d80130f7e4e4fbcf1.tar.xz
This frickin' g++-3.4 bug is even weirder when -O2 kicks in. Change the workaround again.
-rw-r--r--paludis/match_sequence.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/paludis/match_sequence.cc b/paludis/match_sequence.cc
index cc53ba8..34ff9e9 100644
--- a/paludis/match_sequence.cc
+++ b/paludis/match_sequence.cc
@@ -25,13 +25,12 @@ using namespace paludis;
* never return when in fact they will. this is a nasty workaround. */
#if defined(__GNUC__)
# if __GNUC__ < 4
-# define WORK_AROUND_BROKEN_COMPILER do { std::string s; \
- if (! s.empty()) return s.size(); } while (false)
+# define BROKEN_COMPILER(x) (x).raw_pointer()
# else
-# define WORK_AROUND_BROKEN_COMPILER
+# define BROKEN_COMPILER(x) x
# endif
#else
-# define WORK_AROUND_BROKEN_COMPILER
+# define BROKEN_COMPILER(x) x
#endif
struct MatchRule::Rule :
@@ -76,13 +75,11 @@ struct MatchRule::SequenceRule :
std::string::size_type
local_match(const std::string & t, std::string::size_type p) const
{
- WORK_AROUND_BROKEN_COMPILER;
-
- std::string::size_type l1(r1._rule->local_match(t, p)), l2(0);
+ std::string::size_type l1(BROKEN_COMPILER(r1._rule)->local_match(t, p)), l2(0);
if (std::string::npos == l1)
return l1;
- l2 = r2._rule->local_match(t, p + l1);
+ l2 = BROKEN_COMPILER(r2._rule)->local_match(t, p + l1);
return (std::string::npos == l2) ? l2 : l1 + l2;
}
};
@@ -101,12 +98,10 @@ struct MatchRule::EitherRule :
std::string::size_type
local_match(const std::string & t, std::string::size_type p) const
{
- WORK_AROUND_BROKEN_COMPILER;
-
- std::string::size_type l1(r1._rule->local_match(t, p));
+ std::string::size_type l1(BROKEN_COMPILER(r1._rule)->local_match(t, p));
if (std::string::npos != l1)
return l1;
- return r2._rule->local_match(t, p);
+ return BROKEN_COMPILER(r2._rule)->local_match(t, p);
}
};
@@ -123,10 +118,8 @@ struct MatchRule::ZeroOrMoreRule :
std::string::size_type
local_match(const std::string & t, std::string::size_type p) const
{
- WORK_AROUND_BROKEN_COMPILER;
-
std::string::size_type result(p), q;
- while (std::string::npos != ((q = r1._rule->local_match(t, result))))
+ while (std::string::npos != ((q = BROKEN_COMPILER(r1._rule)->local_match(t, result))))
result += q;
return result - p;
@@ -189,7 +182,6 @@ MatchRule::operator* () const
bool
MatchRule::match(const std::string & s) const
{
- WORK_AROUND_BROKEN_COMPILER;
- return (std::string::npos != _rule->local_match(s, 0));
+ return (std::string::npos != BROKEN_COMPILER(_rule)->local_match(s, 0));
}