diff options
Diffstat (limited to 'indexing/xindex/lualatex/xindex-baselib.lua')
-rw-r--r-- | indexing/xindex/lualatex/xindex-baselib.lua | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/indexing/xindex/lualatex/xindex-baselib.lua b/indexing/xindex/lualatex/xindex-baselib.lua index 0ff33a591e..4e5c09a87d 100644 --- a/indexing/xindex/lualatex/xindex-baselib.lua +++ b/indexing/xindex/lualatex/xindex-baselib.lua @@ -5,11 +5,11 @@ -- AUTHOR: Herbert Voß -- LICENSE: LPPL1.3 -- --- $Id: xindex-baselib.lua 19 2022-01-22 09:59:15Z hvoss $ +-- $Id: xindex-baselib.lua 22 2022-02-07 12:18:15Z hvoss $ ----------------------------------------------------------------------- if not modules then modules = { } end modules ['xindex-baselib'] = { - version = 0.35, + version = 0.40, comment = "base library to xindex.lua", author = "Herbert Voss", copyright = "Herbert Voss", @@ -128,12 +128,36 @@ function romanToNumber(s) return ret end +function toNumber(s) -- number as string or a roman number to arabic number + if s == nil then return s end + if type(s) == "number" then return s end -- it is already a number + local rnum = romanToNumber(s) -- check if roman + if rnum then return rnum end -- if yes, return converted roman + return tonumber(s) -- return string to number +end + +--[[ function string:split() local sep, fields = " ", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end +]] + +function string:split(s) + local D + if not s then + D = '%s' + else + D = tostring(s) + end + local sep, fields = " ", {} + local pattern = string.format("([^"..D.."]+)", sep) + self:gsub(pattern, function(c) fields[#fields+1] = c end) + return fields +end + function shellsort(a) local inc = math.ceil( #a / 2 ) |