X-Git-Url: https://git.webkit.org/?p=WebKit-https.git;a=blobdiff_plain;f=WebCore%2Fplatform%2FCString.cpp;h=7c33adb816b1321a4787fbaa703d0cc36a4f30ce;hp=6e0285ee067883c8f76766759f9b7b57e7a19d2c;hb=6dd6f4e5db154cd978104fc1826397541e98811c;hpb=f98cad3dbea4a311e8be2df029bd51a306c69837 diff --git a/WebCore/platform/CString.cpp b/WebCore/platform/CString.cpp index 6e0285ee0678..7c33adb816b1 100644 --- a/WebCore/platform/CString.cpp +++ b/WebCore/platform/CString.cpp @@ -55,6 +55,11 @@ void CString::init(const char* str, unsigned length) m_buffer->data()[length] = '\0'; } +const char* CString::data() const +{ + return m_buffer ? m_buffer->data() : 0; +} + char* CString::mutableData() { copyBufferIfNeeded(); @@ -94,36 +99,4 @@ void CString::copyBufferIfNeeded() memcpy(m_buffer->data(), m_temp->data(), len); } -int CString::find(const char* substring, int index) const -{ - const char* str = data(); - - if(str && str[0] && substring && index >=0) { // don't search empty strings - // advance until we get to index - int pos = 0; - while(pos < index) - if(str[pos++] == 0) - return -1; // index is beyond end of str - - // now search from index onward - while(str[index] != 0) { - char a, b; - - // compare until we reach the end or a mismatch - pos = 0; - - while((a = substring[pos]) && (b = str[index]) && a == b) - pos++, index++; - - // reached the end of our compare string without a mismatch? - if(substring[pos] == 0) - return index - pos; - - index ++; - } - } - - return -1; -} - }