summaryrefslogtreecommitdiff
path: root/luatexbase-modutils.dtx
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-05-12 22:48:53 +0200
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-05-12 23:05:54 +0200
commitafa56afc7e47859afad818e79fcc0cb8fd545b6a (patch)
tree1c70b261aa1b8114746cf2ba1b4fe27b7f79ad0a /luatexbase-modutils.dtx
parent486533d41096bf942313f8041024efe86b7a2134 (diff)
downloadluatexbase-afa56afc7e47859afad818e79fcc0cb8fd545b6a.tar.gz
Revert part of 8aa37e31 that broke things.
Diffstat (limited to 'luatexbase-modutils.dtx')
-rw-r--r--luatexbase-modutils.dtx23
1 files changed, 16 insertions, 7 deletions
diff --git a/luatexbase-modutils.dtx b/luatexbase-modutils.dtx
index 24f09bd..79bdb5f 100644
--- a/luatexbase-modutils.dtx
+++ b/luatexbase-modutils.dtx
@@ -355,13 +355,23 @@ local modules = modules or {}
local requiredversions = {}
% \end{macrocode}
%
-% If the given string begins with a date in YYYY/MM/DD format, return the
-% date as the number YYYYMMDD; otherwise, return nil.
+% Convert a date in YYYY/MM/DD format into a number
%
% \begin{macrocode}
local function datetonumber(date)
- local datenum, ok = version:gsub("^(%d%d%d%d)/(%d%d)/(%d%d).*", "%1%2%3")
- return (ok == 1) and tonumber(datenum) or nil
+ numbers = string.gsub(date, "(%d+)/(%d+)/(%d+)", "%1%2%3")
+ return tonumber(numbers)
+end
+% \end{macrocode}
+%
+% Say if a string is a date in YYYY//MM/DD format.
+%
+% \begin{macrocode}
+local function isdate(date)
+ for _, _ in string.gmatch(date, "%d+/%d+/%d+") do
+ return true
+ end
+ return false
end
% \end{macrocode}
%
@@ -371,9 +381,8 @@ end
% \begin{macrocode}
local date, number = 1, 2
local function parse_version(version)
- local datenum = datetonumber(date)
- if ok == 1 then
- return {type = date, version = tonumber(datenum), orig = version}
+ if isdate(version) then
+ return {type = date, version = datetonumber(version), orig = version}
else
return {type = number, version = tonumber(version), orig = version}
end