diff options
-rw-r--r-- | README | 12 | ||||
-rw-r--r-- | luatexbase-modutils.dtx | 46 |
2 files changed, 47 insertions, 11 deletions
@@ -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.) diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx index d9fd34a..84c893c 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} @@ -635,7 +637,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) @@ -649,6 +652,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} @@ -678,6 +712,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')) @@ -687,6 +727,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')) %</testdummy> % \end{macrocode} % |