зеркало из https://github.com/mozilla/gecko-dev.git
Bug 811264 - Use mozilla::Abs in jsnum.cpp, instead of open-coding it in ways that trigger warnings with some compilers. Also rename IntToCString to Int32ToCString, for accuracy. r=jorendorff
--HG-- extra : rebase_source : a138da4be25bcd8f6c7f99addb0027c4be88c413
This commit is contained in:
Родитель
087adaed14
Коммит
59a3616c36
|
@ -46,6 +46,7 @@
|
|||
using namespace js;
|
||||
using namespace js::types;
|
||||
|
||||
using mozilla::Abs;
|
||||
using mozilla::MinDoubleValue;
|
||||
using mozilla::NegativeInfinity;
|
||||
using mozilla::PodCopy;
|
||||
|
@ -581,7 +582,7 @@ JS_ALWAYS_INLINE
|
|||
static T *
|
||||
BackfillInt32InBuffer(int32_t si, T *buffer, size_t size, size_t *length)
|
||||
{
|
||||
uint32_t ui = mozilla::Abs(si);
|
||||
uint32_t ui = Abs(si);
|
||||
JS_ASSERT_IF(si == INT32_MIN, ui == uint32_t(INT32_MAX) + 1);
|
||||
|
||||
RangedPtr<T> end(buffer + size - 1, buffer, size);
|
||||
|
@ -642,9 +643,9 @@ js::Int32ToAtom(ExclusiveContext *cx, int32_t si)
|
|||
|
||||
/* Returns a non-nullptr pointer to inside cbuf. */
|
||||
static char *
|
||||
IntToCString(ToCStringBuf *cbuf, int i, size_t *len, int base = 10)
|
||||
Int32ToCString(ToCStringBuf *cbuf, int32_t i, size_t *len, int base = 10)
|
||||
{
|
||||
unsigned u = (i < 0) ? -unsigned(i) : i;
|
||||
uint32_t u = Abs(i);
|
||||
|
||||
RangedPtr<char> cp(cbuf->sbuf + ToCStringBuf::sbufSize - 1, cbuf->sbuf, ToCStringBuf::sbufSize);
|
||||
char *end = cp.get();
|
||||
|
@ -1305,7 +1306,7 @@ js::NumberToCString(JSContext *cx, ToCStringBuf *cbuf, double d, int base/* = 10
|
|||
int32_t i;
|
||||
size_t len;
|
||||
return mozilla::DoubleIsInt32(d, &i)
|
||||
? IntToCString(cbuf, i, &len, base)
|
||||
? Int32ToCString(cbuf, i, &len, base)
|
||||
: FracNumberToCString(cx, cbuf, d, base);
|
||||
}
|
||||
|
||||
|
@ -1346,7 +1347,7 @@ js_NumberToStringWithBase(ThreadSafeContext *cx, double d, int base)
|
|||
}
|
||||
|
||||
size_t len;
|
||||
numStr = IntToCString(&cbuf, i, &len, base);
|
||||
numStr = Int32ToCString(&cbuf, i, &len, base);
|
||||
JS_ASSERT(!cbuf.dbuf && numStr >= cbuf.sbuf && numStr < cbuf.sbuf + cbuf.sbufSize);
|
||||
} else {
|
||||
if (comp) {
|
||||
|
@ -1457,7 +1458,7 @@ js::NumberValueToStringBuffer(JSContext *cx, const Value &v, StringBuffer &sb)
|
|||
const char *cstr;
|
||||
size_t cstrlen;
|
||||
if (v.isInt32()) {
|
||||
cstr = IntToCString(&cbuf, v.toInt32(), &cstrlen);
|
||||
cstr = Int32ToCString(&cbuf, v.toInt32(), &cstrlen);
|
||||
JS_ASSERT(cstrlen == strlen(cstr));
|
||||
} else {
|
||||
cstr = NumberToCString(cx, &cbuf, v.toDouble());
|
||||
|
|
Загрузка…
Ссылка в новой задаче