aboutsummaryrefslogtreecommitdiff
path: root/compat53.lua
diff options
context:
space:
mode:
authorPhilipp Janda <siffiejoe@gmx.net>2015-01-21 14:37:41 +0100
committerPhilipp Janda <siffiejoe@gmx.net>2015-01-21 14:37:41 +0100
commiteec3f9e44bee334542348bdd1d428417e22ed5e5 (patch)
tree82fe996fb72ee5a86b9f872fcf57df8fb888a280 /compat53.lua
parentc57750c925553f627701f2c4897ee6bd6488c7c1 (diff)
downloadlua-compat-5.3-eec3f9e44bee334542348bdd1d428417e22ed5e5.tar.gz
lua-compat-5.3-eec3f9e44bee334542348bdd1d428417e22ed5e5.tar.bz2
lua-compat-5.3-eec3f9e44bee334542348bdd1d428417e22ed5e5.zip
use Lua 5.3's source for string packing
Diffstat (limited to 'compat53.lua')
-rw-r--r--compat53.lua27
1 files changed, 18 insertions, 9 deletions
diff --git a/compat53.lua b/compat53.lua
index 67a8c8f..4a78260 100644
--- a/compat53.lua
+++ b/compat53.lua
@@ -46,15 +46,24 @@ if lua_version < "5.3" then
46 end 46 end
47 47
48 48
49 -- use Roberto's struct module for string packing/unpacking for now 49 -- load string packing functions
50 -- maybe we'll later extract the functions from the 5.3 string 50 local str_ok, strlib = pcall(require, "compat53.string")
51 -- library for greater compatiblity, but it uses the 5.3 buffer API 51 if str_ok then
52 -- which cannot easily be backported to Lua 5.1. 52 for k,v in pairs(strlib) do
53 local struct_ok, struct = pcall(require, "struct") 53 string[k] = v
54 if struct_ok then 54 end
55 string.pack = struct.pack 55 end
56 string.packsize = struct.size 56
57 string.unpack = struct.unpack 57
58 -- try Roberto's struct module for string packing/unpacking if
59 -- compat53.string is unavailable
60 if not str_ok then
61 local struct_ok, struct = pcall(require, "struct")
62 if struct_ok then
63 string.pack = struct.pack
64 string.packsize = struct.size
65 string.unpack = struct.unpack
66 end
58 end 67 end
59 68
60 69