commit: 20690cf030363e7cdae309640f97e09592e7991f
parent 8d3c3d22c6be60664d7936ef47a0b9eae70ea778
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 30 Sep 2022 01:24:46 +0200
Add support for Lua bytecode files
Diffstat:
6 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
@@ -14,7 +14,7 @@ CFLAGS ?= -Os -s
MANDOC ?= mandoc
EXE = deblob
-TEST_BLOBS = test/fixtures/hello test/fixtures/hello.a test/fixtures/hello.o test/fixtures/hello.exe
+TEST_BLOBS = test/fixtures/hello test/fixtures/hello.a test/fixtures/hello.o test/fixtures/hello.exe test/fixtures/hello.luac53 test/fixtures/hello.luac54
all: $(EXE)
@@ -37,6 +37,12 @@ test/fixtures/hello: test/fixtures/hello.c
test/fixtures/hello.exe: test/fixtures/hello.cs
$(MCS) test/fixtures/hello.cs
+test/fixtures/hello.luac53: test/fixtures/hello.lua
+ luac5.3 -o $@ test/fixtures/hello.lua
+
+test/fixtures/hello.luac54: test/fixtures/hello.lua
+ luac5.4 -o $@ test/fixtures/hello.lua
+
.PHONY: test
test: all $(TEST_BLOBS)
rm -fr test/check_dir-fixtures
diff --git a/deblob.1 b/deblob.1
@@ -50,6 +50,8 @@ Java Class files
Python 2.7 & 3.8/3.9/3.10 bytecode files, typically *.pyc
.It
Portable Executable (PE) files, typically *.exe and *.dll
+.It
+Lua bytecode
.El
.Sh EXAMPLES
The following code block show how it is intended to be used in Gentoo's
diff --git a/main.ha b/main.ha
@@ -26,6 +26,7 @@ const magic: [_][]u8 = [
[0x55, 0x0D, '\r', '\n'], // (3413i litte-endian) Python 3.8
[0x61, 0x0D, '\r', '\n'], // (3425i litte-endian) Python 3.9
[0x6F, 0x0D, '\r', '\n'], // (3439i litte-endian) Python 3.10
+ [0x1B, 'L', 'u', 'a'], // Lua bytecode
];
fn is_blob(filename: str) (bool | fs::error | io::error) = {
@@ -54,7 +55,10 @@ fn is_blob(filename: str) (bool | fs::error | io::error) = {
("test/fixtures/hello.1", false),
("test/fixtures/hello.c", false),
("test/fixtures/hello.cs", false),
+ ("test/fixtures/hello.lua", false),
("test/fixtures/hello", true),
+ ("test/fixtures/hello.luac53", true),
+ ("test/fixtures/hello.luac54", true),
("test/fixtures/hello.o", true),
("test/fixtures/hello.a", true),
("test/fixtures/hello.exe", true),
@@ -162,7 +166,7 @@ fn check_dir(dirname: str) (void | errors::invalid) = {
case let e: fs::error =>
fmt::fatalf("os::readdir({}): {}", dirname, fs::strerror(e));
};
- assert(len(files_before) == 17);
+ assert(len(files_before) == 20);
const ret = check_dir(dirname);
assert(ret is void);
@@ -173,7 +177,7 @@ fn check_dir(dirname: str) (void | errors::invalid) = {
case let e: fs::error =>
fmt::fatalf("os::readdir({}): {}", dirname, fs::strerror(e));
};
- assert(len(files_after) == 11);
+ assert(len(files_after) == 12);
};
export fn main() void = {
diff --git a/test/fixtures/hello.lua b/test/fixtures/hello.lua
@@ -0,0 +1,4 @@
+-- SPDX-FileCopyrightText: 2019-2022 deblob Authors <https://hacktivis.me/projects/deblob>
+-- SPDX-License-Identifier: BSD-3-Clause
+
+print("Hello, World!")
+\ No newline at end of file
diff --git a/test/fixtures/hello.luac53 b/test/fixtures/hello.luac53
Binary files differ.
diff --git a/test/fixtures/hello.luac54 b/test/fixtures/hello.luac54
Binary files differ.