r38826 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38825‎ | r38826 | r38827 >
Date:00:35, 8 August 2008
Author:river
Status:old
Tags:
Comment:
implement === and !== properly
Modified paths:
  • /trunk/extensions/AbuseFilter/parser_native/aftypes.cpp (modified) (history)
  • /trunk/extensions/AbuseFilter/parser_native/makefile (modified) (history)
  • /trunk/extensions/AbuseFilter/parser_native/parser.cpp (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/parser_native/aftypes.cpp
@@ -361,6 +361,14 @@
362362 }
363363
364364 bool
 365+AFPData::compare_with_type(AFPData const &other) const {
 366+ if (value_.which() != other.value_.which())
 367+ return false;
 368+
 369+ return boost::apply_visitor(compare_visitor<std::equal_to>(), value_, other.value_);
 370+}
 371+
 372+bool
365373 AFPData::less_than(AFPData const &other) const {
366374 return boost::apply_visitor(arith_compare_visitor<std::less>(), value_, other.value_);
367375 }
Index: trunk/extensions/AbuseFilter/parser_native/makefile
@@ -3,7 +3,7 @@
44 CPPFLAGS = $(EXTRA_CPPFLAGS)
55 LDFLAGS = $(EXTRA_LDFLAGS)
66
7 -LIBS = -lboost_regex$(BOOST_TAG) -licuuc -licui18n -licudata -licui18n
 7+LIBS = -lboost_regex$(BOOST_TAG) -licuuc -licui18n -licudata
88
99 expr: CPPFLAGS+=-DTEST_PARSER
1010
Index: trunk/extensions/AbuseFilter/parser_native/parser.cpp
@@ -111,6 +111,7 @@
112112 /* a sequence of uppercase letters is a variable */
113113 variable =
114114 self.variables[variable.val = arg1]
 115+ | (+upper_p)[variable.val = ""]
115116 ;
116117
117118 /* func(value) */
@@ -171,8 +172,10 @@
172173 >> *(
173174 "==" >> eq_expr[eq2_expr.val = eq2_expr.val == arg1]
174175 | "!=" >> eq_expr[eq2_expr.val = eq2_expr.val != arg1]
175 - | "===" >> eq_expr[eq2_expr.val = eq2_expr.val == arg1]
176 - | "!==" >> eq_expr[eq2_expr.val = eq2_expr.val != arg1]
 176+ | "===" >> eq_expr[eq2_expr.val =
 177+ bind(&AFPData::compare_with_type)(eq2_expr.val, arg1)]
 178+ | "!==" >> eq_expr[eq2_expr.val =
 179+ !bind(&AFPData::compare_with_type)(eq2_expr.val, arg1)]
177180 )
178181 ;
179182

Status & tagging log