Merge TM -> JM
This commit is contained in:
@@ -752,7 +752,7 @@ ndigits(size_t n, size_t *result, const jschar *s, size_t* i, size_t limit)
|
||||
*/
|
||||
|
||||
static JSBool
|
||||
date_parseISOString(JSString *str, jsdouble *result, JSContext *cx)
|
||||
date_parseISOString(JSLinearString *str, jsdouble *result, JSContext *cx)
|
||||
{
|
||||
jsdouble msec;
|
||||
|
||||
@@ -794,7 +794,8 @@ date_parseISOString(JSString *str, jsdouble *result, JSContext *cx)
|
||||
if (!ndigits(n, &field, s, &i, limit)) { goto syntax; } \
|
||||
JS_END_MACRO
|
||||
|
||||
str->getCharsAndLength(s, limit);
|
||||
s = str->chars();
|
||||
limit = str->length();
|
||||
|
||||
if (PEEK('+') || PEEK('-')) {
|
||||
if (PEEK('-'))
|
||||
@@ -885,7 +886,7 @@ date_parseISOString(JSString *str, jsdouble *result, JSContext *cx)
|
||||
}
|
||||
|
||||
static JSBool
|
||||
date_parseString(JSString *str, jsdouble *result, JSContext *cx)
|
||||
date_parseString(JSLinearString *str, jsdouble *result, JSContext *cx)
|
||||
{
|
||||
jsdouble msec;
|
||||
|
||||
@@ -909,7 +910,8 @@ date_parseString(JSString *str, jsdouble *result, JSContext *cx)
|
||||
if (date_parseISOString(str, result, cx))
|
||||
return JS_TRUE;
|
||||
|
||||
str->getCharsAndLength(s, limit);
|
||||
s = str->chars();
|
||||
limit = str->length();
|
||||
if (limit == 0)
|
||||
goto syntax;
|
||||
while (i < limit) {
|
||||
@@ -1169,7 +1171,11 @@ date_parse(JSContext *cx, uintN argc, Value *vp)
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
vp[2].setString(str);
|
||||
if (!date_parseString(str, &result, cx)) {
|
||||
JSLinearString *linearStr = str->ensureLinear(cx);
|
||||
if (!linearStr)
|
||||
return false;
|
||||
|
||||
if (!date_parseString(linearStr, &result, cx)) {
|
||||
vp->setDouble(js_NaN);
|
||||
return true;
|
||||
}
|
||||
@@ -2390,11 +2396,10 @@ date_toSource(JSContext *cx, uintN argc, Value *vp)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
str = JS_NewString(cx, bytes, strlen(bytes));
|
||||
if (!str) {
|
||||
js_free(bytes);
|
||||
str = JS_NewStringCopyZ(cx, bytes);
|
||||
js_free(bytes);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
}
|
||||
vp->setString(str);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -2413,8 +2418,6 @@ date_toString(JSContext *cx, uintN argc, Value *vp)
|
||||
static JSBool
|
||||
date_valueOf(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
JSString *str, *number_str;
|
||||
|
||||
/* It is an error to call date_valueOf on a non-date object, but we don't
|
||||
* need to check for that explicitly here because every path calls
|
||||
* GetUTCTime, which does the check.
|
||||
@@ -2425,11 +2428,14 @@ date_valueOf(JSContext *cx, uintN argc, Value *vp)
|
||||
return date_getTime(cx, argc, vp);
|
||||
|
||||
/* Convert to number only if the hint was given, otherwise favor string. */
|
||||
str = js_ValueToString(cx, vp[2]);
|
||||
JSString *str = js_ValueToString(cx, vp[2]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
number_str = ATOM_TO_STRING(cx->runtime->atomState.typeAtoms[JSTYPE_NUMBER]);
|
||||
if (js_EqualStrings(str, number_str))
|
||||
JSLinearString *linear_str = str->ensureLinear(cx);
|
||||
if (!linear_str)
|
||||
return JS_FALSE;
|
||||
JSAtom *number_str = cx->runtime->atomState.typeAtoms[JSTYPE_NUMBER];
|
||||
if (EqualStrings(linear_str, number_str))
|
||||
return date_getTime(cx, argc, vp);
|
||||
return date_toString(cx, argc, vp);
|
||||
}
|
||||
@@ -2523,8 +2529,11 @@ js_Date(JSContext *cx, uintN argc, Value *vp)
|
||||
if (!str)
|
||||
return false;
|
||||
argv[0].setString(str);
|
||||
JSLinearString *linearStr = str->ensureLinear(cx);
|
||||
if (!linearStr)
|
||||
return false;
|
||||
|
||||
if (!date_parseString(str, &d, cx))
|
||||
if (!date_parseString(linearStr, &d, cx))
|
||||
d = js_NaN;
|
||||
else
|
||||
d = TIMECLIP(d);
|
||||
|
||||
Reference in New Issue
Block a user