lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


With this test from main.lua:

-- first-line comment with binary file
prepfile("#comment\n" .. string.dump(load("print(3)")))
RUN('lua %s > %s', prog, out)
checkout('3\n')

==>

2: Running '"C:/Users/rleigh/code/lua-cmake/cmake-build-debug-visual-studio-2022-shared/src/lua.exe" C:\Users\rleigh\AppData\Local\Temp\sfn0_0 > C:\Users\rleigh\AppData\Local\Temp\sfn0.2'
2: C:/Users/rleigh/code/lua-cmake/cmake-build-debug-visual-studio-2022-shared/src/lua.exe: C:\Users\rleigh\AppData\Local\Temp\sfn0_0: bad binary format (corrupted chunk)
2: C:/Users/rleigh/code/lua-cmake/cmake-build-debug-visual-studio-2022-shared/src/lua.exe: C:/Users/rleigh/code/lua-cmake/tests\main.lua:77: assertion failed!
2: stack traceback:
2: 	[C]: in function 'assert'
2: 	C:/Users/rleigh/code/lua-cmake/tests\main.lua:77: in local 'RUN'
2: 	C:/Users/rleigh/code/lua-cmake/tests\main.lua:545: in main chunk
2: 	(...tail calls...)
2: 	C:/Users/rleigh/code/lua-cmake/tests/all.lua:157: in main chunk
2: 	[C]: in ?

With the attached files using the input for this test:

C:\Users\rleigh\code\lua-cmake\cmake-build-debug-visual-studio-2022-shared\src\lua.exe: C:\Users\rleigh\code\lua-cmake\test-comment.lua: bad binary format (corrupted chunk)

C:\Users\rleigh\code\lua-cmake\cmake-build-debug-visual-studio-2022-shared\src\lua.exe: C:\Users\rleigh\code\lua-cmake\test-comment2.lua: bad binary format (corrupted chunk)

The LUAC_DATA_sequence appears to be incorrect:
    19 93 0d 0d 0a 1a 0d 0a

It looks like the "\n" has been replaced with "\r\n", giving "\r\r\n" and "\r\n" where "\r\n" and "\n" were expected, respectively.

Looks like it is due to io.output/io.write using text mode rather than binary?

Changing

static int io_output (lua_State *L) {
  return g_iofile(L, IO_OUTPUT, "w");
}

to

static int io_output (lua_State *L) {
  return g_iofile(L, IO_OUTPUT, "wb");
}

Makes this test pass.  However, it makes some of the files.lua tests fail, likely because those ones need text mode and not binary.

Likely these tests should be using io.open with "wb" rather than "io.output"?

Kind regards,
Roger


Attachment: test-comment.lua
Description: test-comment.lua

Attachment: test-comment2.lua
Description: test-comment2.lua