mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1025875 part 7 - Make Sprinter::putString work with Latin1 strings. r=njn
This commit is contained in:
parent
c4cc1b7253
commit
97e23847a2
22
js/src/jit-test/tests/latin1/decompiler.js
Normal file
22
js/src/jit-test/tests/latin1/decompiler.js
Normal file
@ -0,0 +1,22 @@
|
||||
var s = toLatin1("someName");
|
||||
|
||||
// Latin1
|
||||
function f(someName) {
|
||||
someName();
|
||||
}
|
||||
try {
|
||||
f(3);
|
||||
} catch(e) {
|
||||
assertEq(e.message.contains("someName"), true);
|
||||
}
|
||||
|
||||
// TwoByte
|
||||
function g(someName\u1200) {
|
||||
someName\u1200();
|
||||
}
|
||||
try {
|
||||
g(3);
|
||||
} catch(e) {
|
||||
// Note: string is deflated; don't check for the \u1200.
|
||||
assertEq(e.message.contains("someName"), true);
|
||||
}
|
@ -1198,21 +1198,24 @@ Sprinter::putString(JSString *s)
|
||||
InvariantChecker ic(this);
|
||||
|
||||
size_t length = s->length();
|
||||
const jschar *chars = s->getChars(context);
|
||||
if (!chars)
|
||||
return -1;
|
||||
|
||||
size_t size = length;
|
||||
if (size == (size_t) -1)
|
||||
return -1;
|
||||
|
||||
ptrdiff_t oldOffset = offset;
|
||||
char *buffer = reserve(size);
|
||||
if (!buffer)
|
||||
return -1;
|
||||
DeflateStringToBuffer(nullptr, chars, length, buffer, &size);
|
||||
buffer[size] = 0;
|
||||
|
||||
JSLinearString *linear = s->ensureLinear(context);
|
||||
if (!linear)
|
||||
return -1;
|
||||
|
||||
AutoCheckCannotGC nogc;
|
||||
if (linear->hasLatin1Chars())
|
||||
mozilla::PodCopy(reinterpret_cast<Latin1Char*>(buffer), linear->latin1Chars(nogc), length);
|
||||
else
|
||||
DeflateStringToBuffer(nullptr, linear->twoByteChars(nogc), length, buffer, &size);
|
||||
|
||||
buffer[size] = 0;
|
||||
return oldOffset;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user