aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ldump.js2
-rw-r--r--src/lstrlib.js6
-rw-r--r--src/lundump.js4
-rw-r--r--tests/loadfile-test.bcbin138 -> 138 bytes
-rw-r--r--tests/test-suite/inprogress/tpack.js9
5 files changed, 10 insertions, 11 deletions
diff --git a/src/ldump.js b/src/ldump.js
index a2abbed..49372f9 100644
--- a/src/ldump.js
+++ b/src/ldump.js
@@ -170,7 +170,7 @@ const DumpHeader = function(D) {
let cdata = LUAC_DATA.split('').map(e => e.charCodeAt(0));
DumpBlock(cdata, cdata.length, D);
DumpByte(4, D); // intSize
- DumpByte(8, D); // size_tSize
+ DumpByte(4, D); // size_tSize
DumpByte(4, D); // instructionSize
DumpByte(4, D); // integerSize
DumpByte(8, D); // numberSize
diff --git a/src/lstrlib.js b/src/lstrlib.js
index e005bdc..0d67903 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -453,13 +453,13 @@ const getoption = function(h, fmt) {
case 'L'.charCodeAt(0): r.size = 4; r.opt = KOption.Kuint; return r;
case 'j'.charCodeAt(0): r.size = 4; r.opt = KOption.Kint; return r; // sizeof(lua_Integer): 4
case 'J'.charCodeAt(0): r.size = 4; r.opt = KOption.Kuint; return r;
- case 'T'.charCodeAt(0): r.size = 8; r.opt = KOption.Kuint; return r; // sizeof(size_t): 8
+ case 'T'.charCodeAt(0): r.size = 4; r.opt = KOption.Kuint; return r; // sizeof(size_t): 4
case 'f'.charCodeAt(0): r.size = 4; r.opt = KOption.Kfloat; return r; // sizeof(float): 4
case 'd'.charCodeAt(0): r.size = 8; r.opt = KOption.Kfloat; return r; // sizeof(double): 8
case 'n'.charCodeAt(0): r.size = 8; r.opt = KOption.Kfloat; return r; // sizeof(lua_Number): 8
case 'i'.charCodeAt(0): r.size = getnumlimit(h, fmt, 4); r.opt = KOption.Kint; return r; // sizeof(int): 4
case 'I'.charCodeAt(0): r.size = getnumlimit(h, fmt, 4); r.opt = KOption.Kuint; return r;
- case 's'.charCodeAt(0): r.size = getnumlimit(h, fmt, 8); r.opt = KOption.Kstring; return r;
+ case 's'.charCodeAt(0): r.size = getnumlimit(h, fmt, 4); r.opt = KOption.Kstring; return r;
case 'c'.charCodeAt(0): {
r.size = getnum(fmt, -1);
if (r.size === -1)
@@ -608,7 +608,7 @@ const str_pack = function(L) {
case KOption.Kstring: { /* strings with length count */
let s = lauxlib.luaL_checkstring(L, arg);
let len = s.length;
- lauxlib.luaL_argcheck(L, size >= 8 /* sizeof(size_t) */ ||
+ lauxlib.luaL_argcheck(L, size >= 4 /* sizeof(size_t) */ ||
len < (1 << (size * NB)),
arg, lua.to_luastring("string length does not fit in given size", true));
packint(b, len, h.islittle, size, 0); /* pack length */
diff --git a/src/lundump.js b/src/lundump.js
index 946efa6..17cdc70 100644
--- a/src/lundump.js
+++ b/src/lundump.js
@@ -17,7 +17,7 @@ class BytecodeParser {
constructor(L, Z, name) {
this.intSize = 4;
- this.size_tSize = 8;
+ this.size_tSize = 4;
this.instructionSize = 4;
this.integerSize = 4;
this.numberSize = 8;
@@ -237,7 +237,7 @@ class BytecodeParser {
this.numberSize = this.readByte();
this.checksize(this.intSize, 4, "int");
- this.checksize(this.size_tSize, 8, "size_t");
+ this.checksize(this.size_tSize, 4, "size_t");
this.checksize(this.instructionSize, 4, "instruction");
this.checksize(this.integerSize, 4, "integer");
this.checksize(this.numberSize, 8, "number");
diff --git a/tests/loadfile-test.bc b/tests/loadfile-test.bc
index db0ac05..f0e98da 100644
--- a/tests/loadfile-test.bc
+++ b/tests/loadfile-test.bc
Binary files differ
diff --git a/tests/test-suite/inprogress/tpack.js b/tests/test-suite/inprogress/tpack.js
index e624cce..f94ca40 100644
--- a/tests/test-suite/inprogress/tpack.js
+++ b/tests/test-suite/inprogress/tpack.js
@@ -487,11 +487,10 @@ test("[test-suite] tpack: testing pack/unpack of strings", function (t) {
checkerror("contains zeros", pack, "z", "alo\\0");
- -- TODO: << overflow in JS vs C
- -- for i = 2, NB do
- -- local s1 = pack("s" .. i, s)
- -- assert(unpack("s" .. i, s1) == s and #s1 == #s + i)
- -- end
+ for i = 2, NB do
+ local s1 = pack("s" .. i, s)
+ assert(unpack("s" .. i, s1) == s and #s1 == #s + i)
+ end
end
do