Bug 590834 - Clean up number-to-string code. r=jwalden.

This commit is contained in:
Nicholas Nethercote
2010-09-13 13:08:25 -07:00
parent 1ddc8aef07
commit bd4fd52236
12 changed files with 165 additions and 109 deletions

View File

@@ -2342,19 +2342,20 @@ date_toDateString(JSContext *cx, uintN argc, Value *vp)
#if JS_HAS_TOSOURCE
#include <string.h>
#include "jsdtoa.h"
#include "jsnum.h"
static JSBool
date_toSource(JSContext *cx, uintN argc, Value *vp)
{
jsdouble utctime;
char buf[DTOSTR_STANDARD_BUFFER_SIZE], *numStr, *bytes;
char *numStr, *bytes;
JSString *str;
if (!GetUTCTime(cx, ComputeThisFromVp(cx, vp), vp, &utctime))
return JS_FALSE;
numStr = js_dtostr(JS_THREAD_DATA(cx)->dtoaState, buf, sizeof buf, DTOSTR_STANDARD, 0, utctime);
ToCStringBuf cbuf;
numStr = NumberToCString(cx, &cbuf, utctime);
if (!numStr) {
JS_ReportOutOfMemory(cx);
return JS_FALSE;