summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/text
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/text')
-rw-r--r--WebCore/platform/text/Base64.cpp11
-rw-r--r--WebCore/platform/text/Base64.h1
-rw-r--r--WebCore/platform/text/CharacterNames.h1
-rw-r--r--WebCore/platform/text/StringImpl.cpp12
-rw-r--r--WebCore/platform/text/StringImpl.h5
-rw-r--r--WebCore/platform/text/haiku/StringHaiku.cpp17
6 files changed, 36 insertions, 11 deletions
diff --git a/WebCore/platform/text/Base64.cpp b/WebCore/platform/text/Base64.cpp
index be19164..82ec9fa 100644
--- a/WebCore/platform/text/Base64.cpp
+++ b/WebCore/platform/text/Base64.cpp
@@ -62,21 +62,24 @@ static const char base64DecMap[128] = {
void base64Encode(const Vector<char>& in, Vector<char>& out, bool insertLFs)
{
+ base64Encode(in.data(), in.size(), out, insertLFs);
+}
+
+void base64Encode(const char* data, unsigned len, Vector<char>& out, bool insertLFs)
+{
out.clear();
- if (in.isEmpty())
+ if (!len)
return;
// If the input string is pathologically large, just return nothing.
// Note: Keep this in sync with the "out_len" computation below.
// Rather than being perfectly precise, this is a bit conservative.
const unsigned maxInputBufferSize = UINT_MAX / 77 * 76 / 4 * 3 - 2;
- if (in.size() > maxInputBufferSize)
+ if (len > maxInputBufferSize)
return;
unsigned sidx = 0;
unsigned didx = 0;
- const char* data = in.data();
- const unsigned len = in.size();
unsigned out_len = ((len + 2) / 3) * 4;
diff --git a/WebCore/platform/text/Base64.h b/WebCore/platform/text/Base64.h
index 0b176e6..53b29b0 100644
--- a/WebCore/platform/text/Base64.h
+++ b/WebCore/platform/text/Base64.h
@@ -31,6 +31,7 @@
namespace WebCore {
void base64Encode(const Vector<char>&, Vector<char>&, bool insertLFs = false);
+void base64Encode(const char*, unsigned, Vector<char>&, bool insertLFs = false);
// this decoder is not general purpose - it returns an error if it encounters a linefeed, as needed for window.atob
bool base64Decode(const Vector<char>&, Vector<char>&);
diff --git a/WebCore/platform/text/CharacterNames.h b/WebCore/platform/text/CharacterNames.h
index ebaa1f1..c0b1750 100644
--- a/WebCore/platform/text/CharacterNames.h
+++ b/WebCore/platform/text/CharacterNames.h
@@ -41,6 +41,7 @@ namespace WebCore {
const UChar hebrewPunctuationGeresh = 0x05F3;
const UChar hebrewPunctuationGershayim = 0x05F4;
const UChar horizontalEllipsis = 0x2026;
+ const UChar hyphenMinus = 0x002D;
const UChar ideographicComma = 0x3001;
const UChar ideographicFullStop = 0x3002;
const UChar ideographicSpace = 0x3000;
diff --git a/WebCore/platform/text/StringImpl.cpp b/WebCore/platform/text/StringImpl.cpp
index 3b61a0b..db6152d 100644
--- a/WebCore/platform/text/StringImpl.cpp
+++ b/WebCore/platform/text/StringImpl.cpp
@@ -97,6 +97,16 @@ inline StringImpl::StringImpl(const UChar* characters, unsigned length)
{
ASSERT(characters);
ASSERT(length);
+ ASSERT(!bufferIsInternal());
+}
+
+inline StringImpl::StringImpl(unsigned length)
+ : m_data(reinterpret_cast<const UChar*>(this + 1))
+ , m_length(length)
+ , m_hash(0)
+{
+ ASSERT(length);
+ ASSERT(bufferIsInternal());
}
StringImpl::~StringImpl()
@@ -927,7 +937,7 @@ PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, UChar*&
size_t size = sizeof(StringImpl) + length * sizeof(UChar);
StringImpl* string = static_cast<StringImpl*>(fastMalloc(size));
data = reinterpret_cast<UChar*>(string + 1);
- string = new (string) StringImpl(data, length);
+ string = new (string) StringImpl(length);
return adoptRef(string);
}
diff --git a/WebCore/platform/text/StringImpl.h b/WebCore/platform/text/StringImpl.h
index f7a9d06..21f936d 100644
--- a/WebCore/platform/text/StringImpl.h
+++ b/WebCore/platform/text/StringImpl.h
@@ -66,9 +66,12 @@ private:
friend class ThreadGlobalData;
StringImpl();
- // This adopts the UChar* without copying the buffer.
+ // This constructor adopts the UChar* without copying the buffer.
StringImpl(const UChar*, unsigned length);
+ // This constructor assumes that 'this' was allocated with a UChar buffer of size 'length' at the end.
+ StringImpl(unsigned length);
+
// For use only by AtomicString's XXXTranslator helpers.
void setHash(unsigned hash) { ASSERT(!m_hash); m_hash = hash; }
diff --git a/WebCore/platform/text/haiku/StringHaiku.cpp b/WebCore/platform/text/haiku/StringHaiku.cpp
index 9e0fd3f..fe32215 100644
--- a/WebCore/platform/text/haiku/StringHaiku.cpp
+++ b/WebCore/platform/text/haiku/StringHaiku.cpp
@@ -24,19 +24,26 @@
*/
#include "config.h"
-#include "CString.h"
-
#include "PlatformString.h"
+#include "CString.h"
#include <String.h>
-
namespace WebCore {
// String conversions
-String::String(const BString& str)
+String::String(const BString& bstring)
{
- m_impl = String::fromUTF8(str.String(), str.Length()).impl();
+ const UChar* str = reinterpret_cast<const UChar*>(bstring.String());
+ const size_t size = bstring.Length();
+
+ if (!str)
+ return;
+
+ if (!size)
+ m_impl = StringImpl::empty();
+ else
+ m_impl = StringImpl::create(str, size);
}
String::operator BString() const