From e4a0575aa7854548b4f881925f7477f12f3bc696 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= <mpg@elzevir.fr>
Date: Mon, 29 Mar 2010 18:16:22 +0200
Subject: compat: support for version testing

---
 luatexbase-compat.dtx | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

(limited to 'luatexbase-compat.dtx')

diff --git a/luatexbase-compat.dtx b/luatexbase-compat.dtx
index c413bab..4d7f987 100644
--- a/luatexbase-compat.dtx
+++ b/luatexbase-compat.dtx
@@ -121,9 +121,9 @@ See source file '\inFileName' for details.
 %
 % \section{Documentation}
 %
-% Two problems are currently addressed by this package: changes in the syntax
-% of |\directlua|, and variable policies for primitives activation and naming
-% (in \luatex itself as well as in \texlive).
+% Three problems are currently addressed by this package: changes in the
+% syntax of |\directlua|, version information, and variable policies for
+% primitives activation and naming (in \luatex itself as well as in \texlive).
 %
 % \medskip
 %
@@ -141,6 +141,14 @@ See source file '\inFileName' for details.
 %
 % \medskip
 %
+% Current versions of \luatex make the version available directly from Lua as
+% |tex.luatexversion| and |tex.luatexrevision|. However, older versions (such
+% as 0.25.4) didn't, which makes it particularly uneasy to test the version
+% from within Lua. The present package makes this information available as
+% |luatexbase.luatexversion| and |luatexbase.luatexrevision|.
+%
+% \medskip
+%
 % Starting with \luatex 0.39.0, the only primitives available in Ini\tex mode
 % are the basic primitives from \tex{}82 and |\directlua|. All other
 % primitives are hidden by default and have to be activated using a Lua
@@ -298,6 +306,17 @@ See source file '\inFileName' for details.
 \the\toks0
 %    \end{macrocode}
 %
+%    \subsection{Version information}
+%
+%    Make |\luatexversion| and |\luatexrevision| available from Lua.
+%
+%    \begin{macrocode}
+\luatexbase@directlua{%
+  luatexbase = luatexbase or {}
+  luatexbase.luatexversion = \number\luatexversion\space
+  luatexbase.luatexrevision = \number\luatexrevision\space}
+%    \end{macrocode}
+%
 %    \subsection{Primitives}
 %
 %    Try reasonably hard to activate a primitive. First, check if it is
@@ -379,6 +398,8 @@ See source file '\inFileName' for details.
 \luatexbase@directlua{local answer = 42}
 \luatexbase@ensure@primitive{primitive}
 \luatexprimitive\relax
+\luatexbase@directlua{assert(type(luatexbase.luatexversion) == 'number')}
+\luatexbase@directlua{assert(type(luatexbase.luatexrevision) == 'number')}
 %</testplain,testlatex>
 %<testplain>\bye
 %<testlatex>\stop
-- 
cgit v1.2.3

