Ignore:
Timestamp:
Aug 13, 2010, 6:28:27 PM (15 years ago)
Author:
[email protected]
Message:

Switch String::/UString::ascii() to return a CString.

Rubber stamped by Sam Weinig.

JavaScriptCore:

(JSC::CodeBlock::dump):

  • bytecode/SamplingTool.cpp:

(JSC::SamplingTool::dump):

  • interpreter/CallFrame.cpp:

(JSC::CallFrame::dumpCaller):

  • jsc.cpp:

(runWithScripts):
(runInteractive):

  • runtime/Identifier.h:

(JSC::Identifier::ascii):

  • runtime/ScopeChain.cpp:

(JSC::ScopeChainNode::print):

  • runtime/UString.cpp:

(JSC::UString::ascii):
(JSC::UString::latin1):

  • runtime/UString.h:
  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::asciiOLD):

  • wtf/text/StringImpl.h:
  • wtf/text/WTFString.cpp:

(WTF::String::ascii):
(WTF::String::latin1):

  • wtf/text/WTFString.h:

WebCore:

  • WebCore.xcodeproj/project.pbxproj:
  • bridge/c/c_class.cpp:

(JSC::Bindings::CClass::methodsNamed):
(JSC::Bindings::CClass::fieldNamed):

  • bridge/jni/jsc/JNIBridgeJSC.cpp:

(JavaField::valueFromInstance):
(JavaField::setValueToInstance):

  • bridge/jni/jsc/JavaInstanceJSC.cpp:

(JavaInstance::invokeMethod):

  • bridge/objc/objc_class.mm:

(JSC::Bindings::ObjcClass::methodsNamed):
(JSC::Bindings::ObjcClass::fieldNamed):

  • bridge/objc/objc_instance.mm:

(ObjcInstance::setValueOfUndefinedField):
(ObjcInstance::getValueOfUndefinedField):

  • loader/icon/IconRecord.cpp:
  • platform/sql/SQLiteDatabase.cpp:
  • platform/sql/SQLiteStatement.cpp:
  • storage/SQLStatement.cpp:

WebKit:

  • WebKit.xcodeproj/project.pbxproj:

WebKit/mac:

  • Plugins/Hosted/ProxyInstance.mm:

(WebKit::ProxyInstance::methodsNamed):
(WebKit::ProxyInstance::fieldNamed):

File:
1 edited

Legend:

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

    r65305 r65344  
    205205}
    206206
    207 char* UString::ascii() const
    208 {
    209     static char* asciiBuffer = 0;
    210 
    211     unsigned len = length();
    212     unsigned neededSize = len + 1;
    213     delete[] asciiBuffer;
    214     asciiBuffer = new char[neededSize];
    215 
    216     const UChar* p = characters();
    217     char* q = asciiBuffer;
    218     const UChar* limit = p + len;
    219     while (p != limit) {
    220         *q = static_cast<char>(p[0]);
    221         ++p;
    222         ++q;
    223     }
    224     *q = '\0';
    225 
    226     return asciiBuffer;
    227 }
    228 
    229207static inline bool isInfinity(double number)
    230208{
     
    584562}
    585563
     564CString UString::ascii() const
     565{
     566    // Basic Latin1 (ISO) encoding - Unicode characters 0..255 are
     567    // preserved, characters outside of this range are converted to '?'.
     568
     569    unsigned length = this->length();
     570    const UChar* characters = this->characters();
     571
     572    char* characterBuffer;
     573    CString result = CString::newUninitialized(length, characterBuffer);
     574
     575    for (unsigned i = 0; i < length; ++i) {
     576        UChar ch = characters[i];
     577        characterBuffer[i] = ch && (ch < 0x20 || ch >= 0x7f) ? '?' : ch;
     578    }
     579
     580    return result;
     581}
     582
     583CString UString::latin1() const
     584{
     585    // Basic Latin1 (ISO) encoding - Unicode characters 0..255 are
     586    // preserved, characters outside of this range are converted to '?'.
     587
     588    unsigned length = this->length();
     589    const UChar* characters = this->characters();
     590
     591    char* characterBuffer;
     592    CString result = CString::newUninitialized(length, characterBuffer);
     593
     594    for (unsigned i = 0; i < length; ++i) {
     595        UChar ch = characters[i];
     596        characterBuffer[i] = ch > 0xff ? '?' : ch;
     597    }
     598
     599    return result;
     600}
     601
    586602// Helper to write a three-byte UTF-8 code point to the buffer, caller must check room is available.
    587603static inline void putUTF8Triple(char*& buffer, UChar ch)
Note: See TracChangeset for help on using the changeset viewer.