Reviewed by Maciej.
- fixed 28 Mozilla JavaScript tests
* kjs/array_object.cpp: (ArrayProtoFuncImp::call): Check for undefined rather than
checking the number of arguments for the join method.
* kjs/lexer.cpp: (Lexer::lex): Parse hexadecimal and octal constants in doubles rather
than integers, so we aren't limited to 32 bits.
* kjs/math_object.cpp: (MathFuncImp::call): Get rid of many unneeded special cases in
the implementation of the pow operation. Also simplied a case that was handling positive
and negative infinity separately.
* kjs/nodes.cpp: (ShiftNode::evaluate): Keep the result of shifts in a double instead of
putting them in a long, so that unsigned shift will work properly.
* kjs/number_object.cpp: Add the DontDelete and ReadOnly flags to the numeric constants.
* kjs/operations.cpp:
(KJS::isPosInf): Added an implementation inside APPLE_CHANGES that does not depend on the
sign of isinf; our isinf function returns +1 even for negative infinity.
(KJS::isNegInf): And again.
(KJS::relation): Put in a nice simple implementation of comparison inside APPLE_CHANGES.
Our floating point already handles the various infinity cases correctly.
* kjs/regexp_object.cpp:
(RegExpProtoFuncImp::call): Add missing return before Null() in Exec method.
(RegExpObjectImp::arrayOfMatches): Put undefined rather than an empty string into the
array in cases where we did not match.
(RegExpObjectImp::construct): Set the DontDelete, ReadOnly, and DontEnum flags for
"global", "ignoreCase", "multiline", and "source".
* kjs/string_object.cpp: (StringProtoFuncImp::call): For the match method, turn a null
string into undefined rather than an empty string. For the slice method, handle an
undefined parameter for the limit properly as decribed in the specification, and add
the limit to one case that didn't have the limit at all. For the methods that generate
HTML strings, use lowercase tags instead of uppercase.
* kjs/ustring.cpp:
(KJS::UChar::toLower): Use u_tolower from the ICU library.
(KJS::UChar::toUpper): Use u_toupper from the ICU library.
(KJS::UString::append): Fix some math that caused a buffer overflow.
(KJS::convertUTF16OffsetsToUTF8Offsets): Ignore negative numbers (-1 is used as a special
flag) rather than converting them all to 0.
(KJS::convertUTF8OffsetsToUTF16Offsets): Ditto.
* tests/mozilla/jsDriver.pl: Fixed the relative links to point to our actual test files.
* tests/mozilla/ecma/String/15.5.4.11-1.js: Fixed the Unicode table in this test to match
the Unicode specification in a few cases where it was wrong before.
* tests/mozilla/ecma/String/15.5.4.11-2.js: Ditto.
* tests/mozilla/ecma/String/15.5.4.11-3.js: Ditto.
* tests/mozilla/ecma/String/15.5.4.11-5.js: Ditto.
* tests/mozilla/ecma/String/15.5.4.11-6.js: Ditto.
* tests/mozilla/ecma/String/15.5.4.12-1.js: Ditto.
* tests/mozilla/ecma/String/15.5.4.12-2.js: Ditto.
* tests/mozilla/ecma/String/15.5.4.12-3.js: Ditto.
* tests/mozilla/ecma/String/15.5.4.12-4.js: Ditto.
* tests/mozilla/ecma/String/15.5.4.12-5.js: Ditto.
* JavaScriptCore.pbproj/project.pbxproj: Link to libicu.
* kjs/number_object.lut.h: Regenerated.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@7222 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/kjs/string_object.cpp b/JavaScriptCore/kjs/string_object.cpp
index a4110a2..8c902e9 100644
--- a/JavaScriptCore/kjs/string_object.cpp
+++ b/JavaScriptCore/kjs/string_object.cpp
@@ -296,7 +296,10 @@
List list;
int lastIndex = 0;
while (pos >= 0) {
- list.append(String(mstr));
+ if (mstr.isNull())
+ list.append(UndefinedImp::staticUndefined);
+ else
+ list.append(String(mstr));
lastIndex = pos;
pos += mstr.isEmpty() ? 1 : mstr.size();
delete [] *ovector;
@@ -417,7 +420,7 @@
result = res;
u = s;
i = p0 = 0;
- d = a1.toInteger(exec);
+ uint32_t limit = a1.type() == UndefinedType ? 0xFFFFFFFFU : a1.toUInt32(exec);
if (a0.type() == ObjectType && Object::dynamicCast(a0).inherits(&RegExpImp::info)) {
Object obj0 = Object::dynamicCast(a0);
RegExp reg(obj0.get(exec,"source").toString(exec));
@@ -427,7 +430,7 @@
break;
}
pos = 0;
- while (pos < u.size()) {
+ while (static_cast<uint32_t>(i) != limit && pos < u.size()) {
// TODO: back references
int mpos;
int *ovector = 0L;
@@ -442,7 +445,7 @@
i++;
}
}
- } else if (a0.type() != UndefinedType) {
+ } else {
u2 = a0.toString(exec);
if (u2.isEmpty()) {
if (u.isEmpty()) {
@@ -450,11 +453,11 @@
put(exec,lengthPropertyName, Number(0));
break;
} else {
- while (!(i == d) && i < u.size()-1) // !(i == d) returns true for NaN
+ while (static_cast<uint32_t>(i) != limit && i < u.size()-1)
res.put(exec, i++, String(u.substr(p0++, 1)));
}
} else {
- while (!(i == d) && (pos = u.find(u2, p0)) >= 0) { // !(i == d) returns true for NaN
+ while (static_cast<uint32_t>(i) != limit && (pos = u.find(u2, p0)) >= 0) {
res.put(exec, i, String(u.substr(p0, pos-p0)));
p0 = pos + u2.size();
i++;
@@ -462,7 +465,7 @@
}
}
// add remaining string, if any
- if (!(i == d)) // !(i == d) returns true for NaN
+ if (static_cast<uint32_t>(i) != limit)
res.put(exec, i++, String(u.substr(p0)));
res.put(exec,lengthPropertyName, Number(i));
}
@@ -525,39 +528,39 @@
break;
#ifndef KJS_PURE_ECMA
case Big:
- result = String("<BIG>" + s + "</BIG>");
+ result = String("<big>" + s + "</big>");
break;
case Small:
- result = String("<SMALL>" + s + "</SMALL>");
+ result = String("<small>" + s + "</small>");
break;
case Blink:
- result = String("<BLINK>" + s + "</BLINK>");
+ result = String("<blink>" + s + "</blink>");
break;
case Bold:
- result = String("<B>" + s + "</B>");
+ result = String("<b>" + s + "</b>");
break;
case Fixed:
- result = String("<TT>" + s + "</TT>");
+ result = String("<tt>" + s + "</tt>");
break;
case Italics:
- result = String("<I>" + s + "</I>");
+ result = String("<i>" + s + "</i>");
break;
case Strike:
- result = String("<STRIKE>" + s + "</STRIKE>");
+ result = String("<strike>" + s + "</strike>");
break;
case Sub:
- result = String("<SUB>" + s + "</SUB>");
+ result = String("<sub>" + s + "</sub>");
break;
case Sup:
- result = String("<SUP>" + s + "</SUP>");
+ result = String("<sup>" + s + "</sup>");
break;
case Fontcolor:
- result = String("<FONT COLOR=" + a0.toString(exec) + ">"
- + s + "</FONT>");
+ result = String("<font color=" + a0.toString(exec) + ">"
+ + s + "</font>");
break;
case Fontsize:
- result = String("<FONT SIZE=" + a0.toString(exec) + ">"
- + s + "</FONT>");
+ result = String("<font size=" + a0.toString(exec) + ">"
+ + s + "</font>");
break;
case Anchor:
result = String("<a name=" + a0.toString(exec) + ">"