Ignore:
Timestamp:
Aug 12, 2009, 1:58:30 AM (16 years ago)
Author:
Simon Hausmann
Message:

Fix compile error on 64Bit Windows, when UString::from
is called with an intptr_t.

Patch by Prasanth Ullattil <[email protected]> on 2009-08-12
Reviewed by Simon Hausmann.

Added new UString::From overload with long long parameter.

Thanks to Holger for the long long idea.

  • runtime/UString.cpp:

(JSC::UString::from):

  • runtime/UString.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/UString.cpp

    r47092 r47096  
    923923        char minBuf[1 + sizeof(i) * 3];
    924924        sprintf(minBuf, "%d", INT_MIN);
     925        return UString(minBuf);
     926    } else {
     927        bool negative = false;
     928        if (i < 0) {
     929            negative = true;
     930            i = -i;
     931        }
     932        while (i) {
     933            *--p = static_cast<unsigned short>((i % 10) + '0');
     934            i /= 10;
     935        }
     936        if (negative)
     937            *--p = '-';
     938    }
     939
     940    return UString(p, static_cast<int>(end - p));
     941}
     942
     943UString UString::from(long long i)
     944{
     945    UChar buf[1 + sizeof(i) * 3];
     946    UChar* end = buf + sizeof(buf) / sizeof(UChar);
     947    UChar* p = end;
     948
     949    if (i == 0)
     950        *--p = '0';
     951    else if (i == LLONG_MIN) {
     952        char minBuf[1 + sizeof(i) * 3];
     953        snprintf(minBuf, sizeof(minBuf) - 1, "%I64d", LLONG_MIN);
    925954        return UString(minBuf);
    926955    } else {
Note: See TracChangeset for help on using the changeset viewer.