From 5aaa7476b5734c8d7611e7ebf2c6d609dea09064 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sat, 4 May 2013 17:09:58 +0200 Subject: Adding a few auxiliary functions for module availability and version checking --- luatexbase-modutils.dtx | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx index 0645e1b..2851286 100644 --- a/luatexbase-modutils.dtx +++ b/luatexbase-modutils.dtx @@ -229,6 +229,14 @@ See the aforementioned source file(s) for copyright and licensing information. % standard Lua function, so you may want to avoid overwriting it, hence the % use of |err| in the above example.) % +% \begin{qcode} +% local module_info = luatexbase.get_module_info(\meta{name}) +% local version = luatexbase.get_module_version(\meta{name}) +% local is_loaded = luatexbase.is_module_loaded(\meta{name}) +% \end{qcode} +% These functions check for the availability or version of a module, and can +% even return a copy of the |module_info| table. +% % \subsection{Templates} % % Let me emphasize again that, while |luatexbase.require_module()| is meant to @@ -587,6 +595,73 @@ end luatexbase.provides_module = provides_module % \end{macrocode} % +% \subsubsection{module availability and version checking} +% +% A simple table copy function. +% +% \begin{macrocode} +local fastcopy = table.fastcopy or function(old) + if old then + local new = { } + for k,v in next, old do + if type(v) == "table" then + new[k] = fastcopy(v) + else + new[k] = v + end + end + local mt = getmetatable(old) + if mt then + setmetatable(new,mt) + end + return new + else + return { } + end +end +% \end{macrocode} +% +% Gives the table of the infos on a module, as given in |provides_module|. +% +% \begin{macrocode} +local function get_module_info(name) + local module_table = modules[name] + if not module_table then + return nil + else + return fastcopy(module_table) + end +end +luatexbase.get_module_info = get_module_info +% \end{macrocode} +% +% Gives the version of a module, or nil if the module is not loaded. +% +% \begin{macrocode} +function get_module_version(name) + local module_table = modules[name] + if not module_table then + return nil + else + return module_table.version + end +end +luatexbase.get_module_version = get_module_version +% \end{macrocode} +% +% Returns true if the module is loaded, false otherwise. +% +% \begin{macrocode} +function is_module_loaded(name) + if modules[name] then + return true + else + return false + end +end +luatexbase.is_module_loaded = is_module_loaded +% \end{macrocode} +% % \begin{macrocode} % % \end{macrocode} @@ -605,6 +680,13 @@ local err, warn, info, log = luatexbase.provides_module { } info('It works!\nOh, rly?\nYeah rly!') log("I'm a one-line info.") +info("1 = "..luatexbase.get_module_version('test-modutils')) +if is_module_loaded('test-modutils') then + info("ok!") +else + err("problem!") +end +info("2000/01/01 = "..luatexbase.get_module_info('test-modutils').date) % % \end{macrocode} % -- cgit v1.2.3 From bf002f0dbf584aa4079905c34ac05f91282c8bad Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sat, 4 May 2013 17:18:46 +0200 Subject: Updating and simplifying --- lltxb-dtxstyle.tex | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lltxb-dtxstyle.tex b/lltxb-dtxstyle.tex index 115d4f2..d086326 100644 --- a/lltxb-dtxstyle.tex +++ b/lltxb-dtxstyle.tex @@ -56,19 +56,18 @@ % constant metadata \newif\ifluatexbase \author{% - Heiko Oberdiek (primary author of \pk{luatex}) \\ - \'Elie Roux (primary author of \pk{luatextra}) \\ - Manuel P\'egouri\'e-Gonnard (current developper)\thanks{% + Heiko Oberdiek (primary author of \pk{luatex})\\ + \'Elie Roux, Manuel P\'egouri\'e-Gonnard, Philipp Gesang\thanks{% See ``History'' \ifluatexbase\else in \href{luatexbase.pdf}{\file{luatexbase.pdf}} \fi for details.}% \\[1ex] - \url{https://github.com/mpg/luatexbase} \\ + \url{https://github.com/lualatex/luatexbase} \\ \email{lualatex-dev@tug.org}% } \hypersetup{% pdfsubject = {Basic resource management for LuaTeX}, - pdfauthor = {Manuel P\'egouri\'e-Gonnard, \'Elie Roux, Heiko Oberdiek}, + pdfauthor = {Manuel P\'egouri\'e-Gonnard, \'Elie Roux, Heiko Oberdiek, Philipp Gesang}, } % other metadata -- cgit v1.2.3 From 0f9a734bc3394928736cdddcd96a34db52ca8aef Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sat, 4 May 2013 17:23:27 +0200 Subject: Bump version and update documentation --- Changes | 8 +++++++- luatexbase-modutils.dtx | 2 +- luatexbase.dtx | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index 7b39c55..3a15578 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,12 @@ Changes in the luatexbase package/bundle -2013/04/22 v0.6 +2013/05/04 v0.6 + attr + - hack to make luatexbase and luatex.sty compatible for attribute + allocation + - adding whatsit nodes allocation functions (see doc) + modutils + - adding functions to check the availability and version of a module loader - do not output included file paths when called by texlua mcb diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx index 2851286..33fc974 100644 --- a/luatexbase-modutils.dtx +++ b/luatexbase-modutils.dtx @@ -111,7 +111,7 @@ See the aforementioned source file(s) for copyright and licensing information. % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} % -% \pkdate{luatexbase-modutils}{v0.5 2013-04-13} +% \pkdate{luatexbase-modutils}{v0.6 2013-05-04} % % \maketitle % diff --git a/luatexbase.dtx b/luatexbase.dtx index 49b0c07..2849818 100644 --- a/luatexbase.dtx +++ b/luatexbase.dtx @@ -93,7 +93,7 @@ See the aforementioned source file(s) for copyright and licensing information. % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} % -% \pkdate{luatexbase}{v0.5 2013-04-13} +% \pkdate{luatexbase}{v0.6 2013-05-04} % % \maketitle % @@ -116,7 +116,7 @@ See the aforementioned source file(s) for copyright and licensing information. % \subpk{regs} extented allocation scheme for registers and the like, % \emph{\`a la} \pk{etex}. % \subpk{cctb} catcode table allocation. -% \subpk{attr} attribute allocation. +% \subpk{attr} attribute and whatsit node allocation. % \subpk{mcb} callbacks extensions allowing to register many functions in a % single callback, and declare new callbacks for packages. % \subpk{modutils} Lua module declaration, including version checks. @@ -214,7 +214,7 @@ See the aforementioned source file(s) for copyright and licensing information. \let\x\ProvidesPackage \fi \expandafter\endgroup -\x{luatexbase}[2013/04/13 v0.5 Module utilities for LuaTeX] +\x{luatexbase}[2013/05/04 v0.6 Module utilities for LuaTeX] % \end{macrocode} % % Make sure \luatex is used. -- cgit v1.2.3 From 042c2bc11a83e56f3e4a3646b44de71c53a92bdf Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sat, 4 May 2013 17:32:33 +0200 Subject: Small doc update --- Changes | 2 +- README | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 3a15578..2d64579 100644 --- a/Changes +++ b/Changes @@ -3,7 +3,7 @@ 2013/05/04 v0.6 attr - hack to make luatexbase and luatex.sty compatible for attribute - allocation + allocation (same thing should be done for catcodetables) - adding whatsit nodes allocation functions (see doc) modutils - adding functions to check the availability and version of a module diff --git a/README b/README index 4424910..a6b6c9f 100644 --- a/README +++ b/README @@ -8,10 +8,13 @@ if desired: – luatexbase-compat: compatibility helpers; – luatexbase-loader: Lua module loading; – luatexbase-regs: allocation of registers and the like; -– luatexbase-attr: attribute allocation; +– luatexbase-attr: attribute and whatsit node allocation; – luatexbase-cctb: catcode table allocation; – luatexbase-modutils: Lua module declaration; and -- luatexbase-mcb: callbacks extensions. +– luatexbase-mcb: callbacks extensions. + +The development takes place on https://github.com/lualatex/luatexbase. + Installation ------------ @@ -34,6 +37,7 @@ Alternatively, try you Linux distribution's package management system. put files in './texmf', which is probably not what you want.) c. See 2c. + License ------- -- cgit v1.2.3 From ad717ef646940a985b6cb153f08faec691c425a1 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sat, 4 May 2013 18:02:12 +0200 Subject: Fixing small error in module date requirement --- luatexbase-modutils.dtx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx index 33fc974..9da5605 100644 --- a/luatexbase-modutils.dtx +++ b/luatexbase-modutils.dtx @@ -567,9 +567,8 @@ local function require_module(name, req_date) local info = modules[name] if not info then warn("module '%s' was not properly identified", name) - elseif req_date and info.version then - if not (info.date and date_to_int(info.date) > date_to_int(req_date)) - then + elseif req_date and info.date then + if date_to_int(info.date) < date_to_int(req_date) then warn("module '%s' required in version '%s'\n" .. "but found in version '%s'", name, req_date, info.date) end -- cgit v1.2.3 From 38188eb60b7eb7258cd2b784afc8314485751d38 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sat, 4 May 2013 18:02:50 +0200 Subject: Update Changes --- Changes | 1 + 1 file changed, 1 insertion(+) diff --git a/Changes b/Changes index 2d64579..8e7fc21 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,7 @@ - adding whatsit nodes allocation functions (see doc) modutils - adding functions to check the availability and version of a module + - fixing small error in module date requirement loader - do not output included file paths when called by texlua mcb -- cgit v1.2.3 From 29bee8c9edf934690e25816c001e8afefd942e94 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sun, 5 May 2013 15:00:23 +0200 Subject: Adding a few more accessors functions --- luatexbase-modutils.dtx | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx index 9da5605..1a50f24 100644 --- a/luatexbase-modutils.dtx +++ b/luatexbase-modutils.dtx @@ -468,6 +468,7 @@ See the aforementioned source file(s) for copyright and licensing information. %<*luamodule> luatexbase = luatexbase or { } local luatexbase = luatexbase +local string_gsub = string.gsub % \end{macrocode} % % \subsection{Internal functions and data} @@ -484,7 +485,8 @@ local modules = modules or {} % % \begin{macrocode} local function date_to_int(date) - local numbers = string.gsub(date, "(%d+)/(%d+)/(%d+)", "%1%2%3") + if date == '' then return -1 end + local numbers = string_gsub(date, "(%d+)/(%d+)/(%d+)", "%1%2%3") return tonumber(numbers) end % \end{macrocode} @@ -634,7 +636,8 @@ end luatexbase.get_module_info = get_module_info % \end{macrocode} % -% Gives the version of a module, or nil if the module is not loaded. +% Gives the version of a module, nil if the module is not loaded and empty +% string if the module did not set its date. % % \begin{macrocode} function get_module_version(name) @@ -648,6 +651,37 @@ end luatexbase.get_module_version = get_module_version % \end{macrocode} % +% Gives the date string of a module, nil if the module is not loaded and +% empty string of the modules did not set its date. +% +% \begin{macrocode} +function get_module_date(name) + local module_table = modules[name] + if not module_table then + return nil + else + return module_table.date + end +end +luatexbase.get_module_date = get_module_date +% \end{macrocode} +% +% Gives the date number of a module, for date comparison, nil if the +% module is not loaded and -1 if the module did not set its date. The number +% is formated as |yyyymmdd|. +% +% \begin{macrocode} +function get_module_date_int(name) + local module_table = modules[name] + if not module_table then + return nil + else + return module_table.date and date_to_int(module_table.date) + end +end +luatexbase.get_module_date_int = get_module_date_int +% \end{macrocode} +% % Returns true if the module is loaded, false otherwise. % % \begin{macrocode} @@ -677,6 +711,12 @@ local err, warn, info, log = luatexbase.provides_module { version = 1, description = 'dummy test package', } +luatexbase.provides_module { + name = 'test-modutils2', + date = '', + version = 1, + description = 'dummy test package', +} info('It works!\nOh, rly?\nYeah rly!') log("I'm a one-line info.") info("1 = "..luatexbase.get_module_version('test-modutils')) @@ -686,6 +726,8 @@ else err("problem!") end info("2000/01/01 = "..luatexbase.get_module_info('test-modutils').date) +info("20000101 = "..luatexbase.get_module_date_int('test-modutils')) +info("-1 = "..luatexbase.get_module_date_int('test-modutils2')) % % \end{macrocode} % -- cgit v1.2.3 From 32040496caa1dab0ce1bfd4da023ac5bb325efdb Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Sun, 5 May 2013 15:17:05 +0200 Subject: No .tds.zip on CTAN --- README | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/README b/README index a6b6c9f..cb3c8ba 100644 --- a/README +++ b/README @@ -22,16 +22,10 @@ Installation Here are the recommended installation methods (preferred first). 1. If you are using TeX Live 2010 or later, use 'tlmgr install luatexbase'. -If your are using MiKTeX, use the MiKTeX Package Manager. -Alternatively, try you Linux distribution's package management system. + If your are using MiKTeX, use the MiKTeX Package Manager. + Alternatively, try you Linux distribution's package management system. -2. a. Grab luatexbase.tds.zip on the CTAN. - b. Unzip it at the root of one or your TDS trees. - c. You may need to update some filename database after this, see your TeX - distribution's manual for details. (Hint: with TeX Live, run 'mktexlsr'; - with MikTeX, look for "Refresh FNDB" in the MikTeX menu.) - -3. a. Grab the sources from CTAN or github. +2. a. Grab the sources from CTAN or github. b. Run 'make install TEXMFROOT=/path/to/texmf'. (Warning: 'make install' without giving a TEXMFROOT will put files in './texmf', which is probably not what you want.) -- cgit v1.2.3 From b7f3f777b1c825e4b4e0c8d6ec5592090078f36b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 5 May 2013 15:32:28 +0200 Subject: fix scoping for fastcopy() --- luatexbase-modutils.dtx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx index 9da5605..d9fd34a 100644 --- a/luatexbase-modutils.dtx +++ b/luatexbase-modutils.dtx @@ -599,7 +599,8 @@ luatexbase.provides_module = provides_module % A simple table copy function. % % \begin{macrocode} -local fastcopy = table.fastcopy or function(old) +local fastcopy +fastcopy = table.fastcopy or function(old) if old then local new = { } for k,v in next, old do -- cgit v1.2.3