diff options
Diffstat (limited to 'compat53.lua')
| -rw-r--r-- | compat53.lua | 27 |
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 | ||
