aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua/Compat.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2017-03-24 21:19:55 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2017-03-24 21:31:35 +0100
commit1e13e98ecfba2d78a88ba42bb54c8cdc15929e2d (patch)
treeb61810b5eeba033c49963f67a0984227cfa26677 /src/Text/Pandoc/Lua/Compat.hs
parent14e7d3dbfff30af2ffde149dac860a736030673b (diff)
downloadpandoc-1e13e98ecfba2d78a88ba42bb54c8cdc15929e2d.tar.gz
Ensure compatibility with hslua 0.5.*
The 0.5.0 release of hslua fixes problems with lua C modules on linux. The signature of the `loadstring` function changed, so a compatibility wrapper is introduced to allow both 0.4.* and 0.5.* versions to be used.
Diffstat (limited to 'src/Text/Pandoc/Lua/Compat.hs')
-rw-r--r--src/Text/Pandoc/Lua/Compat.hs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Lua/Compat.hs b/src/Text/Pandoc/Lua/Compat.hs
new file mode 100644
index 000000000..998d8d032
--- /dev/null
+++ b/src/Text/Pandoc/Lua/Compat.hs
@@ -0,0 +1,40 @@
+{-
+Copyright © 2017 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+{-# LANGUAGE CPP #-}
+{- |
+ Module : Text.Pandoc.Lua.Compat
+ Copyright : Copyright © 2017 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+ Stability : alpha
+
+Compatibility helpers for hslua
+-}
+module Text.Pandoc.Lua.Compat ( loadstring ) where
+
+import Scripting.Lua ( LuaState )
+import qualified Scripting.Lua as Lua
+
+-- | Interpret string as lua code and load into the lua environment.
+loadstring :: LuaState -> String -> String -> IO Int
+#if MIN_VERSION_hslua(0,5,0)
+loadstring lua script _ = Lua.loadstring lua script
+#else
+loadstring lua script cn = Lua.loadstring lua script cn
+#endif