* 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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17865
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-11-20 Anders Carlsson <acarlsson@apple.com>
+
+ 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.
+
2006-11-20 Anders Carlsson <acarlsson@apple.com>
Reviewed by Maciej.
}
// Returns the position of the encoding string.
-static int findXMLEncoding(const DeprecatedCString &str, int &encodingLength)
+static int findXMLEncoding(const CString& str, int &encodingLength)
{
int len = str.length();
m_buffer->data()[length] = '\0';
}
-const char* CString::data() const
-{
- return m_buffer ? m_buffer->data() : 0;
-}
-
char* CString::mutableData()
{
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;
+}
+
}
CString(const char*, unsigned length);
static CString newUninitialized(size_t length, char*& characterBuffer);
- const char* data() const;
+ const char* data() const { return m_buffer ? m_buffer->data() : 0; }
char* mutableData();
unsigned length() const;
operator const char*() const { return data(); }
-
+
bool isNull() const { return !m_buffer; }
CString(const DeprecatedCString&);
DeprecatedCString deprecatedCString() const;
+ int find(const char*, int index=0) const;
+
private:
void copyBufferIfNeeded();
void init(const char*, unsigned length);
return *this;
}
-TextStream& TextStream::operator<<(const DeprecatedCString& qcs)
-{
- const char *s = qcs;
- return *this << s;
-}
-
TextStream& TextStream::operator<<(const DeprecatedString& s)
{
if (m_hasByteArray) {
namespace WebCore {
class DeprecatedChar;
-class DeprecatedCString;
class DeprecatedString;
class String;
class TextStream;
TextStream& operator<<(const char*);
TextStream& operator<<(const String&);
TextStream& operator<<(const DeprecatedString&);
- TextStream& operator<<(const DeprecatedCString&);
TextStream& operator<<(void*);
TextStream& operator<<(const TextStreamManipulator&);