[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:17:54 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 0a2c7b8203471e6d10070affb79e7d3a09776f6f
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Dec 11 04:55:12 2003 +0000
Reviewed by Maciej.
- fixed regression in JavaScript tests reported by the KDE guys
- fixed 3506345: REGRESSION (115-116): VIP: chordfind.com no longer displays chords
* kjs/ustring.h: Add tolerateEmptyString parameter to toDouble and toULong.
* kjs/ustring.cpp:
(KJS::UString::toDouble): Separate the "tolerant" parameter into two separate ones:
tolerateTrailingJunk and tolerateEmptyString. Add new overloads; better for code size
and binary compatibility than default parameter values.
(KJS::UString::toULong): Pass tolerateEmptyString down to toDouble. Add new overload.
* kjs/string_object.cpp: (StringProtoFuncImp::call): Pass false for the new
"tolerate empty string" parameter.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5753 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 60d72c8..3f59337 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,20 @@
+2003-12-10 Darin Adler <darin at apple.com>
+
+ Reviewed by Maciej.
+
+ - fixed regression in JavaScript tests reported by the KDE guys
+ - fixed 3506345: REGRESSION (115-116): VIP: chordfind.com no longer displays chords
+
+ * kjs/ustring.h: Add tolerateEmptyString parameter to toDouble and toULong.
+ * kjs/ustring.cpp:
+ (KJS::UString::toDouble): Separate the "tolerant" parameter into two separate ones:
+ tolerateTrailingJunk and tolerateEmptyString. Add new overloads; better for code size
+ and binary compatibility than default parameter values.
+ (KJS::UString::toULong): Pass tolerateEmptyString down to toDouble. Add new overload.
+
+ * kjs/string_object.cpp: (StringProtoFuncImp::call): Pass false for the new
+ "tolerate empty string" parameter.
+
2003-12-10 Richard Williamson <rjw at apple.com>
Added code to manage reference counting of JavaScript
diff --git a/JavaScriptCore/kjs/string_object.cpp b/JavaScriptCore/kjs/string_object.cpp
index 06535f7..df2acc2 100644
--- a/JavaScriptCore/kjs/string_object.cpp
+++ b/JavaScriptCore/kjs/string_object.cpp
@@ -338,7 +338,7 @@ Value StringProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &arg
continue;
}
// Assume number part is one char exactly
- unsigned long pos = rstr.substr(i+1,1).toULong(&ok);
+ unsigned long pos = rstr.substr(i+1,1).toULong(&ok, false /* tolerate empty string */);
if (ok && pos <= (unsigned)reg->subPatterns()) {
rstr = rstr.substr(0,i)
+ u.substr((*ovector)[2*pos],
diff --git a/JavaScriptCore/kjs/ustring.cpp b/JavaScriptCore/kjs/ustring.cpp
index 02e3d80..c6ee008 100644
--- a/JavaScriptCore/kjs/ustring.cpp
+++ b/JavaScriptCore/kjs/ustring.cpp
@@ -617,10 +617,12 @@ UCharReference UString::operator[](int pos)
return UCharReference(this, pos);
}
-double UString::toDouble( bool tolerant ) const
+double UString::toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const
{
double d;
+ // FIXME: If tolerateTrailingJunk is true, then we want to tolerate non-8-bit junk
+ // after the number, so is8Bit is too strict a check.
if (!is8Bit())
return NaN;
@@ -632,7 +634,7 @@ double UString::toDouble( bool tolerant ) const
// empty string ?
if (*c == '\0')
- return tolerant ? 0.0 : NaN;
+ return tolerateEmptyString ? 0.0 : NaN;
// hex number ?
if (*c == '0' && (*(c+1) == 'x' || *(c+1) == 'X')) {
@@ -672,15 +674,25 @@ double UString::toDouble( bool tolerant ) const
while (isspace(*c))
c++;
// don't allow anything after - unless tolerant=true
- if ( !tolerant && *c != '\0')
+ if (!tolerateTrailingJunk && *c != '\0')
d = NaN;
return d;
}
-unsigned long UString::toULong(bool *ok) const
+double UString::toDouble(bool tolerateTrailingJunk) const
{
- double d = toDouble();
+ return toDouble(tolerateTrailingJunk, true);
+}
+
+double UString::toDouble() const
+{
+ return toDouble(false, true);
+}
+
+unsigned long UString::toULong(bool *ok, bool tolerateEmptyString) const
+{
+ double d = toDouble(false, tolerateEmptyString);
bool b = true;
if (isNaN(d) || d != static_cast<unsigned long>(d)) {
@@ -694,6 +706,11 @@ unsigned long UString::toULong(bool *ok) const
return static_cast<unsigned long>(d);
}
+unsigned long UString::toULong(bool *ok) const
+{
+ return toULong(ok, true);
+}
+
uint32_t UString::toUInt32(bool *ok) const
{
double d = toDouble();
diff --git a/JavaScriptCore/kjs/ustring.h b/JavaScriptCore/kjs/ustring.h
index 5765674..ef1e335 100644
--- a/JavaScriptCore/kjs/ustring.h
+++ b/JavaScriptCore/kjs/ustring.h
@@ -391,13 +391,18 @@ namespace KJS {
* the algorithm will recognize hexadecimal representations (as
* indicated by a 0x or 0X prefix) and +/- Infinity.
* Returns NaN if the conversion failed.
- * @param tolerant if true, toDouble can tolerate garbage after the number.
+ * @param tolerateTrailingJunk if true, toDouble can tolerate garbage after the number.
+ * @param tolerateEmptyString if false, toDouble will turn an empty string into NaN rather than 0.
*/
- double toDouble(bool tolerant=false) const;
+ double toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const;
+ double toDouble(bool tolerateTrailingJunk) const;
+ double toDouble() const;
/**
* Attempts an conversion to an unsigned long integer. ok will be set
* according to the success.
+ * @param tolerateEmptyString if false, toULong will return false for *ok for an empty string.
*/
+ unsigned long toULong(bool *ok, bool tolerateEmptyString) const;
unsigned long toULong(bool *ok = 0) const;
uint32_t toUInt32(bool *ok = 0) const;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list