summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/API
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/API')
-rw-r--r--Source/JavaScriptCore/API/JSStringRef.cpp3
-rw-r--r--Source/JavaScriptCore/API/JSStringRefCF.cpp6
-rw-r--r--Source/JavaScriptCore/API/JSValueRef.cpp4
-rw-r--r--Source/JavaScriptCore/API/tests/minidom.c1
-rw-r--r--Source/JavaScriptCore/API/tests/testapi.c1
5 files changed, 10 insertions, 5 deletions
diff --git a/Source/JavaScriptCore/API/JSStringRef.cpp b/Source/JavaScriptCore/API/JSStringRef.cpp
index da1a3057a..7f2168dc2 100644
--- a/Source/JavaScriptCore/API/JSStringRef.cpp
+++ b/Source/JavaScriptCore/API/JSStringRef.cpp
@@ -47,9 +47,10 @@ JSStringRef JSStringCreateWithUTF8CString(const char* string)
Vector<UChar, 1024> buffer(length);
UChar* p = buffer.data();
bool sourceIsAllASCII;
+ const LChar* stringStart = reinterpret_cast<const LChar*>(string);
if (conversionOK == convertUTF8ToUTF16(&string, string + length, &p, p + length, &sourceIsAllASCII)) {
if (sourceIsAllASCII)
- return OpaqueJSString::create(reinterpret_cast<const LChar*>(string), length).leakRef();
+ return OpaqueJSString::create(stringStart, length).leakRef();
return OpaqueJSString::create(buffer.data(), p - buffer.data()).leakRef();
}
}
diff --git a/Source/JavaScriptCore/API/JSStringRefCF.cpp b/Source/JavaScriptCore/API/JSStringRefCF.cpp
index 69cf3f8c4..fd72a593c 100644
--- a/Source/JavaScriptCore/API/JSStringRefCF.cpp
+++ b/Source/JavaScriptCore/API/JSStringRefCF.cpp
@@ -41,6 +41,12 @@ JSStringRef JSStringCreateWithCFString(CFStringRef string)
// it can hold. (<rdar://problem/6806478>)
size_t length = CFStringGetLength(string);
if (length) {
+ Vector<LChar, 1024> lcharBuffer(length);
+ CFIndex usedBufferLength;
+ CFIndex convertedSize = CFStringGetBytes(string, CFRangeMake(0, length), kCFStringEncodingISOLatin1, 0, false, lcharBuffer.data(), length, &usedBufferLength);
+ if (static_cast<size_t>(convertedSize) == length && static_cast<size_t>(usedBufferLength) == length)
+ return OpaqueJSString::create(lcharBuffer.data(), length).leakRef();
+
OwnArrayPtr<UniChar> buffer = adoptArrayPtr(new UniChar[length]);
CFStringGetCharacters(string, CFRangeMake(0, length), buffer.get());
COMPILE_ASSERT(sizeof(UniChar) == sizeof(UChar), unichar_and_uchar_must_be_same_size);
diff --git a/Source/JavaScriptCore/API/JSValueRef.cpp b/Source/JavaScriptCore/API/JSValueRef.cpp
index de84508c1..5ff7c03c6 100644
--- a/Source/JavaScriptCore/API/JSValueRef.cpp
+++ b/Source/JavaScriptCore/API/JSValueRef.cpp
@@ -217,7 +217,7 @@ JSValueRef JSValueMakeNumber(JSContextRef ctx, double value)
// generated internally to JavaScriptCore naturally have that representation,
// but an external NaN might not.
if (isnan(value))
- value = std::numeric_limits<double>::quiet_NaN();
+ value = QNaN;
return toRef(exec, jsNumber(value));
}
@@ -282,7 +282,7 @@ double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
- number = std::numeric_limits<double>::quiet_NaN();
+ number = QNaN;
}
return number;
}
diff --git a/Source/JavaScriptCore/API/tests/minidom.c b/Source/JavaScriptCore/API/tests/minidom.c
index bd3e119e5..43ae2c1a8 100644
--- a/Source/JavaScriptCore/API/tests/minidom.c
+++ b/Source/JavaScriptCore/API/tests/minidom.c
@@ -30,7 +30,6 @@
#include "JSStringRef.h"
#include <stdio.h>
#include <stdlib.h>
-#include <wtf/Platform.h>
#include <wtf/Assertions.h>
#include <wtf/UnusedParam.h>
diff --git a/Source/JavaScriptCore/API/tests/testapi.c b/Source/JavaScriptCore/API/tests/testapi.c
index b52a2b440..c2400f7ec 100644
--- a/Source/JavaScriptCore/API/tests/testapi.c
+++ b/Source/JavaScriptCore/API/tests/testapi.c
@@ -29,7 +29,6 @@
#include "JSObjectRefPrivate.h"
#include <math.h>
#define ASSERT_DISABLED 0
-#include <wtf/Platform.h>
#include <wtf/Assertions.h>
#include <wtf/UnusedParam.h>