r38187 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38186‎ | r38187 | r38188 >
Date:15:11, 29 July 2008
Author:vasilievvv
Status:old
Tags:
Comment:
Support Unicode via ICU in parser_native
Modified paths:
  • /trunk/extensions/AbuseFilter/parser_native/affunctions.cpp (modified) (history)
  • /trunk/extensions/AbuseFilter/parser_native/makefile (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/parser_native/affunctions.cpp
@@ -5,6 +5,7 @@
66 #include <ios>
77 #include <iostream>
88 #include <ctype.h>
 9+#include <unicode/unistr.h>
910
1011 #define EQUIVSET_LOC "equivset.txt"
1112
@@ -86,8 +87,9 @@
8788 if (!args.size()) {
8889 throw new AFPException( "Not enough arguments to lcase" );
8990 }
90 -
91 - return AFPData( (long int)args[0].toString().size() );
 91+
 92+ UnicodeString ustr = UnicodeString( (UChar*)args[0].toString().c_str() );
 93+ return AFPData( (long int)ustr.length() );
9294 }
9395
9496 AFPData af_lcase( vector<AFPData> args ) {
@@ -95,11 +97,13 @@
9698 throw new AFPException( "Not enough arguments to lcase" );
9799 }
98100
99 - string s = args[0].toString();
 101+ int initlen = args[0].toString().length();
 102+ UnicodeString us = UnicodeString( args[0].toString().c_str() );
 103+ us = us.toLower();
 104+ char* result = (char*)malloc(initlen);
 105+ us.extract(0, us.length(), result);
100106
101 - transform( s.begin(), s.end(), s.begin(), (int(*)(int)) tolower );
102 -
103 - return AFPData(s);
 107+ return AFPData(string(result));
104108 }
105109
106110 string confusable_character_normalise( string orig ) {
Index: trunk/extensions/AbuseFilter/parser_native/makefile
@@ -3,7 +3,7 @@
44 all: check
55
66 check: afeval.o affunctions.o afparser.o aftypes.o afutils.o main.o
7 - g++ -g -o check -lboost_regex afeval.o affunctions.o afparser.o aftypes.o afutils.o main.o
 7+ g++ -g -o check -lboost_regex -licudata afeval.o affunctions.o afparser.o aftypes.o afutils.o main.o
88
99 .cpp.o:
1010 g++ -g -c $<

Follow-up revisions

RevisionCommit summaryAuthorDate
r38305AbuseFilter native parser:...werdna16:28, 31 July 2008

Status & tagging log