aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLibravatar William Ahern <william@25thandclement.com> 2016-06-24 19:00:25 -0700
committerLibravatarLibravatar William Ahern <william@25thandclement.com> 2016-06-24 19:00:25 -0700
commita63e737bd12e466937223c848387d0b704f02e31 (patch)
tree6212f97965c01b783fc8153e3bba830d5176a032
parent82b9b3af389b70ed38963ca8d6e2aa9f69b16450 (diff)
downloadluaossl-a63e737bd12e466937223c848387d0b704f02e31.tar.gz
luaossl-a63e737bd12e466937223c848387d0b704f02e31.tar.bz2
luaossl-a63e737bd12e466937223c848387d0b704f02e31.zip
refactor and add ashb's regression test for #53
-rw-r--r--src/GNUmakefile1
-rw-r--r--src/openssl.auxlib.lua21
-rw-r--r--src/openssl.x509.altname.lua3
-rw-r--r--src/openssl.x509.name.lua3
4 files changed, 26 insertions, 2 deletions
diff --git a/src/GNUmakefile b/src/GNUmakefile
index 3aff30a..f0eefde 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -88,6 +88,7 @@ LUAC$(1)_$(d) = $$(or $$(call LUAPATH_$(d), $(1), luac), true)
MODS$(1)_$(d) = \
$$(DESTDIR)$(2)/_openssl.so \
$$(DESTDIR)$(3)/openssl.lua \
+ $$(DESTDIR)$(3)/openssl/auxlib.lua \
$$(DESTDIR)$(3)/openssl/bignum.lua \
$$(DESTDIR)$(3)/openssl/pkey.lua \
$$(DESTDIR)$(3)/openssl/pubkey.lua \
diff --git a/src/openssl.auxlib.lua b/src/openssl.auxlib.lua
new file mode 100644
index 0000000..4f00c25
--- /dev/null
+++ b/src/openssl.auxlib.lua
@@ -0,0 +1,21 @@
+local auxlib = {}
+
+if _VERSION == "Lua 5.1" then
+ local _pairs = pairs
+
+ function auxlib.pairs(t)
+ if type(t) == "userdata" then
+ local mt = getmetatable(t)
+
+ if mt and mt.__pairs then
+ return mt.__pairs(t)
+ else
+ return _pairs(t)
+ end
+ end
+ end
+else
+ auxlib.pairs = pairs
+end
+
+return auxlib
diff --git a/src/openssl.x509.altname.lua b/src/openssl.x509.altname.lua
index 66f16e7..e8222a0 100644
--- a/src/openssl.x509.altname.lua
+++ b/src/openssl.x509.altname.lua
@@ -1,9 +1,10 @@
local altname = require"_openssl.x509.altname"
+local auxlib = require"openssl.auxlib"
altname.interpose("__tostring", function (self)
local t = { }
- for k, v in pairs(self) do
+ for k, v in auxlib.pairs(self) do
t[#t + 1] = k .. ":" .. v
end
diff --git a/src/openssl.x509.name.lua b/src/openssl.x509.name.lua
index a531502..f33339a 100644
--- a/src/openssl.x509.name.lua
+++ b/src/openssl.x509.name.lua
@@ -1,9 +1,10 @@
local name = require"_openssl.x509.name"
+local auxlib = require"openssl.auxlib"
name.interpose("__tostring", function (self)
local t = { }
- for k, v in pairs(self) do
+ for k, v in auxlib.pairs(self) do
t[#t + 1] = k .. "=" .. v
end