aboutsummaryrefslogtreecommitdiff
path: root/compat53.lua
diff options
context:
space:
mode:
Diffstat (limited to 'compat53.lua')
-rw-r--r--compat53.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/compat53.lua b/compat53.lua
new file mode 100644
index 0000000..98e1a3d
--- /dev/null
+++ b/compat53.lua
@@ -0,0 +1,24 @@
1local lua_version = _VERSION:sub(-3)
2
3if lua_version ~= "5.3" then
4
5 -- load utf8 library
6 utf8 = require("compat53.utf8")
7 package.loaded["utf8"] = utf8
8 if lua_version == "5.1" then
9 utf8.charpattern = "[%z\1-\127\194-\244][\128-\191]*"
10 end
11
12 -- use Roberto's struct module for string packing/unpacking for now
13 -- maybe we'll later extract the functions from the 5.3 string
14 -- library for greater compatiblity, but it uses the 5.3 buffer API
15 -- which cannot easily be backported to Lua 5.1.
16 local ok, struct = pcall(require, "struct")
17 if ok then
18 string.pack = struct.pack
19 string.packsize = struct.size
20 string.unpack = struct.unpack
21 end
22
23end
24