[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/3.5/kdelibs/kjs
From: Harri Porten <porten () kde ! org>
Date: 2007-02-20 22:33:38
Message-ID: 1172010818.502875.2829.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 635792 by porten:
(for now) non-localized localeCompare() function
M +4 -0 ChangeLog
M +13 -3 string_object.cpp
M +1 -1 string_object.h
--- branches/KDE/3.5/kdelibs/kjs/ChangeLog #635791:635792
@@ -1,3 +1,7 @@
+2007-02-20 Harri Porten <porten@kde.org>
+
+ * string_object.cpp: basic String localeCompare() function
+
2007-02-17 Harri Porten <porten@kde.org>
* lexer.cpp: parse code with null characters in them
--- branches/KDE/3.5/kdelibs/kjs/string_object.cpp #635791:635792
@@ -146,6 +146,7 @@
toUpperCase StringProtoFuncImp::ToUpperCase DontEnum|Function 0
toLocaleLowerCase StringProtoFuncImp::ToLocaleLowerCase DontEnum|Function 0
toLocaleUpperCase StringProtoFuncImp::ToLocaleUpperCase DontEnum|Function 0
+ localeCompare StringProtoFuncImp::LocaleCompare DontEnum|Function 1
#
# Under here: html extension, should only exist if KJS_PURE_ECMA is not defined
# I guess we need to generate two hashtables in the .lut.h file, and use #ifdef
@@ -197,6 +198,13 @@
return true;
}
+// ### use as fallback only. implement locale aware version.
+static inline int localeCompare(const UString &a, const UString &b)
+{
+ // ### other browsers have more detailed return values than -1, 0 and 1
+ return compare(a, b);
+}
+
// ECMA 15.5.4.2 - 15.5.4.20
Value StringProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
{
@@ -340,7 +348,7 @@
u3 = a1.toString(exec); // 2nd arg is the replacement string
UString out;
-
+
// This is either a loop (if global is set) or a one-way (if not).
reg->prepareMatch(s);
do {
@@ -349,7 +357,7 @@
regExpObj->setSubPatterns(reg->subPatterns());
if (pos == -1)
break;
-
+
len = mstr.size();
UString rstr;
@@ -395,7 +403,7 @@
// Append the replacement..
out += rstr;
-
+
lastIndex = pos + len; // Skip over the matched stuff...
} while (global);
@@ -555,6 +563,8 @@
s[i] = s[i].toUpper();
result = String(s);
break;
+ case LocaleCompare:
+ return Number(localeCompare(s, a0.toString(exec)));
#ifndef KJS_PURE_ECMA
case Big:
result = String("<big>" + s + "</big>");
--- branches/KDE/3.5/kdelibs/kjs/string_object.h #635791:635792
@@ -73,7 +73,7 @@
enum { ToString, ValueOf, CharAt, CharCodeAt, Concat, IndexOf, LastIndexOf,
Match, Replace, Search, Slice, Split,
Substr, Substring, FromCharCode, ToLowerCase, ToUpperCase,
- ToLocaleLowerCase, ToLocaleUpperCase
+ ToLocaleLowerCase, ToLocaleUpperCase, LocaleCompare
#ifndef KJS_PURE_ECMA
, Big, Small, Blink, Bold, Fixed, Italics, Strike, Sub, Sup,
Fontcolor, Fontsize, Anchor, Link
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic