Skip to content

Commit b04f760

Browse files
authored
Merge pull request #6 from Lethja/compact
2 parents 630eff1 + 68f0b29 commit b04f760

File tree

6 files changed

+78
-60
lines changed

6 files changed

+78
-60
lines changed

.github/workflows/LuaWatcom.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ jobs:
1616
submodules: recursive
1717
fetch-depth: 0
1818

19+
- name: Patch Lua Source Code for Open Watcom
20+
run: |
21+
patch -p0 -i lua.pat
22+
1923
- name: Build Lua for DOS 16-bit
2024
run: |
2125
export INCLUDE=$WATCOM/h

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,9 @@ To build Lua with Open Watcom you will need the following:
7474
* Download the Lua 5.4.x sources tarballs from https://lua.org/ftp/, extract them and copy all files in `src` to `Lua`
7575
2) Patch the source code for Watcom (optional):
7676

77-
| GNU Patch | DifPat |
78-
|-------------------------------------|------------------------------------|
79-
| `patch lua/luaconf.h luaconf.pat` | `pat luaconf.pat lua\luaconf.h` |
80-
| `patch lua/lopcodes.h lopcodes.pat` | `pat lopcodes.pat lua\lopcodes.h ` |
81-
| `patch lua/lutf8lib.c lutf8lib.pat` | `pat lutf8lib.pat lua\lutf8lib.c` |
77+
| GNU Patch | DifPat |
78+
|------------------------|-----------------|
79+
| `patch -p0 -i lua.pat` | `pat lua.pat .` |
8280
> If no patching program is available mimic the changes in each `.pat` file manually.
8381
> Patch changes are minimal and only serve to silence Watcom compiler warnings
8482

lopcodes.pat

Lines changed: 0 additions & 14 deletions
This file was deleted.

lua.pat

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
--- lua/lopcodes.h
2+
+++ lua/lopcodes.h
3+
@@ -65,10 +65,16 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */
4+
*/
5+
6+
/* Check whether type 'int' has at least 'b' bits ('b' < 32) */
7+
+#if defined(_M_I86)
8+
+/* Hardcoded due to bugs in some 16-bit compilers */
9+
+#define L_INTHASBITS(b) ((0xFFFF >> ((b) - 1)) >= 1)
10+
+#else
11+
#define L_INTHASBITS(b) ((UINT_MAX >> ((b) - 1)) >= 1)
12+
+#endif
13+
14+
-
15+
-#if L_INTHASBITS(SIZE_Bx)
16+
+#if defined(_M_I86)
17+
+#define MAXARG_Bx 0xFFFF
18+
+#elif L_INTHASBITS(SIZE_Bx)
19+
#define MAXARG_Bx ((1<<SIZE_Bx)-1)
20+
#else
21+
#define MAXARG_Bx MAX_INT
22+
@@ -76,14 +82,17 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */
23+
24+
#define OFFSET_sBx (MAXARG_Bx>>1) /* 'sBx' is signed */
25+
26+
-
27+
-#if L_INTHASBITS(SIZE_Ax)
28+
+#if defined(_M_I86)
29+
+#define MAXARG_Ax 0xFFFF
30+
+#elif L_INTHASBITS(SIZE_Ax)
31+
#define MAXARG_Ax ((1<<SIZE_Ax)-1)
32+
#else
33+
#define MAXARG_Ax MAX_INT
34+
#endif
35+
36+
-#if L_INTHASBITS(SIZE_sJ)
37+
+#if defined(_M_I86)
38+
+#define MAXARG_sJ 0xFFFF
39+
+#elif L_INTHASBITS(SIZE_sJ)
40+
#define MAXARG_sJ ((1 << SIZE_sJ) - 1)
41+
#else
42+
#define MAXARG_sJ MAX_INT
43+
--- lua/luaconf.h
44+
+++ lua/luaconf.h
45+
@@ -79,7 +79,12 @@
46+
/*
47+
@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits.
48+
*/
49+
+#if defined(_M_I86)
50+
+/* Hardcoded due to bugs in some 16-bit compilers */
51+
+#define LUAI_IS32INT 0
52+
+#else
53+
#define LUAI_IS32INT ((UINT_MAX >> 30) >= 3)
54+
+#endif
55+
56+
/* }================================================================== */
57+
58+
59+
--- lua/lutf8lib.c
60+
+++ lua/lutf8lib.c
61+
@@ -31,7 +31,9 @@
62+
/*
63+
** Integer type for decoded UTF-8 values; MAXUTF needs 31 bits.
64+
*/
65+
-#if (UINT_MAX >> 30) >= 1
66+
+#if defined(_M_I86)
67+
+typedef unsigned long utfint;
68+
+#elif (UINT_MAX >> 30) >= 1
69+
typedef unsigned int utfint;
70+
#else
71+
typedef unsigned long utfint;

luaconf.pat

Lines changed: 0 additions & 21 deletions
This file was deleted.

lutf8lib.pat

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)