Changeset 17865 in webkit


Ignore:
Timestamp:
Nov 20, 2006 3:27:46 PM (17 years ago)
Author:
andersca
Message:

Reviewed by Maciej.

  • loader/TextResourceDecoder.cpp: (WebCore::findXMLEncoding): Use CString instead of DeprecatedCString.


  • platform/CString.cpp: (WebCore::CString::find):
  • platform/CString.h: (WebCore::CString::data): Add find method, make data method inline.


  • platform/TextStream.cpp:
  • platform/TextStream.h: Remove DeprecatedCString functions.
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r17864 r17865  
     12006-11-20  Anders Carlsson  <acarlsson@apple.com>
     2
     3        Reviewed by Maciej.
     4
     5        * loader/TextResourceDecoder.cpp:
     6        (WebCore::findXMLEncoding):
     7        Use CString instead of DeprecatedCString.
     8       
     9        * platform/CString.cpp:
     10        (WebCore::CString::find):
     11        * platform/CString.h:
     12        (WebCore::CString::data):
     13        Add find method, make data method inline.
     14       
     15        * platform/TextStream.cpp:
     16        * platform/TextStream.h:
     17        Remove DeprecatedCString functions.
     18
    1192006-11-20  Anders Carlsson  <acarlsson@apple.com>
    220
  • trunk/WebCore/loader/TextResourceDecoder.cpp

    r17652 r17865  
    297297
    298298// Returns the position of the encoding string.
    299 static int findXMLEncoding(const DeprecatedCString &str, int &encodingLength)
     299static int findXMLEncoding(const CString& str, int &encodingLength)
    300300{
    301301    int len = str.length();
  • trunk/WebCore/platform/CString.cpp

    r16385 r17865  
    5656}
    5757
    58 const char* CString::data() const
    59 {
    60     return m_buffer ? m_buffer->data() : 0;
    61 }
    62 
    6358char* CString::mutableData()
    6459{
     
    10095}
    10196
     97int CString::find(const char* substring, int index) const
     98{
     99    const char* str = data();
     100 
     101    if(str && str[0] && substring && index >=0) { // don't search empty strings
     102        // advance until we get to index
     103        int pos = 0;
     104        while(pos < index)
     105            if(str[pos++] == 0)
     106                return -1;                  // index is beyond end of str
     107       
     108        // now search from index onward
     109        while(str[index] != 0) {
     110            char a, b;
     111           
     112            // compare until we reach the end or a mismatch
     113            pos = 0;
     114
     115            while((a = substring[pos]) && (b = str[index]) && a == b)
     116                pos++, index++;
     117           
     118            // reached the end of our compare string without a mismatch?
     119            if(substring[pos] == 0)
     120                return index - pos;
     121           
     122            index ++;
     123        }
     124    }
     125   
     126    return -1;
    102127}
     128
     129}
  • trunk/WebCore/platform/CString.h

    r16385 r17865  
    5252        static CString newUninitialized(size_t length, char*& characterBuffer);
    5353
    54         const char* data() const;
     54        const char* data() const { return m_buffer ? m_buffer->data() : 0; }
    5555        char* mutableData();
    5656        unsigned length() const;
    5757
    5858        operator const char*() const { return data(); }       
    59 
     59       
    6060        bool isNull() const { return !m_buffer; }
    6161
    6262        CString(const DeprecatedCString&);
    6363        DeprecatedCString deprecatedCString() const;
     64
     65        int find(const char*, int index=0) const;
    6466
    6567    private:
  • trunk/WebCore/platform/TextStream.cpp

    r15286 r17865  
    123123}
    124124
    125 TextStream& TextStream::operator<<(const DeprecatedCString& qcs)
    126 {
    127     const char *s = qcs;
    128     return *this << s;
    129 }
    130 
    131125TextStream& TextStream::operator<<(const DeprecatedString& s)
    132126{
  • trunk/WebCore/platform/TextStream.h

    r15286 r17865  
    3232
    3333class DeprecatedChar;
    34 class DeprecatedCString;
    3534class DeprecatedString;
    3635class String;
     
    5857    TextStream& operator<<(const String&);
    5958    TextStream& operator<<(const DeprecatedString&);
    60     TextStream& operator<<(const DeprecatedCString&);
    6159    TextStream& operator<<(void*);
    6260
Note: See TracChangeset for help on using the changeset viewer.