summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/text/mac
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-10-08 17:19:54 +0100
committerSteve Block <steveblock@google.com>2009-10-20 00:41:58 +0100
commit231d4e3152a9c27a73b6ac7badbe6be673aa3ddf (patch)
treea6c7e2d6cd7bfa7011cc39abbb436142d7a4a7c8 /WebCore/platform/text/mac
parente196732677050bd463301566a68a643b6d14b907 (diff)
downloadexternal_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.zip
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.gz
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.bz2
Merge webkit.org at R49305 : Automatic merge by git.
Change-Id: I8968561bc1bfd72b8923b7118d3728579c6dbcc7
Diffstat (limited to 'WebCore/platform/text/mac')
-rw-r--r--WebCore/platform/text/mac/TextCodecMac.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/WebCore/platform/text/mac/TextCodecMac.cpp b/WebCore/platform/text/mac/TextCodecMac.cpp
index 93b9da2..a1750c9 100644
--- a/WebCore/platform/text/mac/TextCodecMac.cpp
+++ b/WebCore/platform/text/mac/TextCodecMac.cpp
@@ -36,7 +36,7 @@
#include <wtf/PassOwnPtr.h>
#include <wtf/Threading.h>
-using std::min;
+using namespace std;
namespace WebCore {
@@ -141,7 +141,7 @@ OSStatus TextCodecMac::decode(const unsigned char* inputBuffer, int inputBufferL
// First, fill the partial character buffer with as many bytes as are available.
ASSERT(m_numBufferedBytes < sizeof(m_bufferedBytes));
const int spaceInBuffer = sizeof(m_bufferedBytes) - m_numBufferedBytes;
- const int bytesToPutInBuffer = MIN(spaceInBuffer, inputBufferLength);
+ const int bytesToPutInBuffer = min(spaceInBuffer, inputBufferLength);
ASSERT(bytesToPutInBuffer != 0);
memcpy(m_bufferedBytes + m_numBufferedBytes, inputBuffer, bytesToPutInBuffer);
@@ -283,28 +283,28 @@ CString TextCodecMac::encode(const UChar* characters, size_t length, Unencodable
// Encoding will change the yen sign back into a backslash.
String copy(characters, length);
copy.replace('\\', m_backslashAsCurrencySymbol);
- CFStringRef cfs = copy.createCFString();
+ RetainPtr<CFStringRef> cfs(AdoptCF, copy.createCFString());
CFIndex startPos = 0;
- CFIndex charactersLeft = CFStringGetLength(cfs);
+ CFIndex charactersLeft = CFStringGetLength(cfs.get());
Vector<char> result;
size_t size = 0;
UInt8 lossByte = handling == QuestionMarksForUnencodables ? '?' : 0;
while (charactersLeft > 0) {
CFRange range = CFRangeMake(startPos, charactersLeft);
CFIndex bufferLength;
- CFStringGetBytes(cfs, range, m_encoding, lossByte, false, NULL, 0x7FFFFFFF, &bufferLength);
+ CFStringGetBytes(cfs.get(), range, m_encoding, lossByte, false, NULL, 0x7FFFFFFF, &bufferLength);
result.grow(size + bufferLength);
unsigned char* buffer = reinterpret_cast<unsigned char*>(result.data() + size);
- CFIndex charactersConverted = CFStringGetBytes(cfs, range, m_encoding, lossByte, false, buffer, bufferLength, &bufferLength);
+ CFIndex charactersConverted = CFStringGetBytes(cfs.get(), range, m_encoding, lossByte, false, buffer, bufferLength, &bufferLength);
size += bufferLength;
if (charactersConverted != charactersLeft) {
- unsigned badChar = CFStringGetCharacterAtIndex(cfs, startPos + charactersConverted);
+ unsigned badChar = CFStringGetCharacterAtIndex(cfs.get(), startPos + charactersConverted);
++charactersConverted;
if ((badChar & 0xFC00) == 0xD800 && charactersConverted != charactersLeft) { // is high surrogate
- UniChar low = CFStringGetCharacterAtIndex(cfs, startPos + charactersConverted);
+ UniChar low = CFStringGetCharacterAtIndex(cfs.get(), startPos + charactersConverted);
if ((low & 0xFC00) == 0xDC00) { // is low surrogate
badChar <<= 10;
badChar += low;
@@ -322,7 +322,6 @@ CString TextCodecMac::encode(const UChar* characters, size_t length, Unencodable
startPos += charactersConverted;
charactersLeft -= charactersConverted;
}
- CFRelease(cfs);
return CString(result.data(), size);
}