diff options
Diffstat (limited to 'tex/context/base/mkiv')
-rw-r--r-- | tex/context/base/mkiv/back-ini.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/core-con.lua | 45 | ||||
-rw-r--r-- | tex/context/base/mkiv/l-os.lua | 61 | ||||
-rw-r--r-- | tex/context/base/mkiv/lxml-tab.lua | 26 | ||||
-rw-r--r-- | tex/context/base/mkiv/mlib-pps.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/mult-prm.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/status-files.pdf | bin | 24713 -> 24705 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/status-lua.pdf | bin | 253745 -> 253744 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/syst-con.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/trac-fil.lua | 2 |
12 files changed, 108 insertions, 38 deletions
diff --git a/tex/context/base/mkiv/back-ini.lua b/tex/context/base/mkiv/back-ini.lua index d01be4a73..f2c22d3ba 100644 --- a/tex/context/base/mkiv/back-ini.lua +++ b/tex/context/base/mkiv/back-ini.lua @@ -132,7 +132,7 @@ end) backends.included = included function backends.timestamp() - return os.date("%Y-%m-%dT%X") .. os.timezone(true) + return os.date("%Y-%m-%dT%X") .. os.timezone() end -- Also here: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 1095d81f9..e5bd908d4 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.10.21 19:53} +\newcontextversion{2021.10.24 21:42} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 5bec8a08a..146d9b365 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -49,7 +49,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2021.10.21 19:53} +\edef\contextversion{2021.10.24 21:42} %D Kind of special: diff --git a/tex/context/base/mkiv/core-con.lua b/tex/context/base/mkiv/core-con.lua index 2d7423669..289a34b0e 100644 --- a/tex/context/base/mkiv/core-con.lua +++ b/tex/context/base/mkiv/core-con.lua @@ -17,7 +17,7 @@ slower but look nicer this way.</p> --ldx]]-- local floor = math.floor -local osdate, ostime = os.date, os.time +local osdate, ostime, ostimezone = os.date, os.time, os.timezone local concat, insert, reverse = table.concat, table.insert, table.reverse local lower, upper, rep, match, gsub = string.lower, string.upper, string.rep, string.match, string.gsub local utfchar, utfbyte = utf.char, utf.byte @@ -1971,14 +1971,37 @@ implement { actions = { formatters["U+%05X"], context }, } -local n = R("09")^1 / tonumber +-- totime might move to utilities.parsers as more general helper + +local n = R("09")^1 / tonumber -- lpegpatterns.digit local p = Cf( Ct("") - * Cg(Cc("year") * (n )) * P("-")^-1 - * Cg(Cc("month") * (n + Cc( 1))) * P("-")^-1 - * Cg(Cc("day") * (n + Cc( 1))) * whitespace^-1 - * Cg(Cc("hour") * (n + Cc( 0))) * P(":")^-1 - * Cg(Cc("min") * (n + Cc( 0))) + -- year is mandate, month and day are optional + * Cg(Cc("year") * n) + * S("-/")^-1 + * Cg(Cc("month") * (n + Cc(1))) + * S("-/")^-1 + * Cg(Cc("day") * (n + Cc(1))) + -- time is optional, hour and minuta are mandate, seconds are optional + * ( + whitespace^0 + * P("T")^-1 + * whitespace^0 + * Cg(Cc("hour") * n) + * P(":")^-1 + * Cg(Cc("min") * n) + * P(":")^-1 + * Cg(Cc("sec") * (n + Cc(0))) + )^-1 + -- zone is optional, hour is mandate, minutes are optional + * ( + whitespace^0 + * Cg(Cc("tzs") * (P("+") * Cc(1) + P("-") * Cc(-1) + Cc(1))) + * whitespace^0 + * Cg(Cc("tzh") * n) + * P(":")^-1 + * Cg(Cc("tzm") * (n + Cc(0))) + )^-1 , rawset) function converters.totime(s) @@ -1987,7 +2010,13 @@ function converters.totime(s) elseif type(s) == "table" then return s elseif type(s) == "string" then - return lpegmatch(p,s) + local t = lpegmatch(p,s) + if t.tzh then + local localtzh, localtzm = ostimezone(true) + t.hour = t.hour + localtzh - t.tzs * t.tzh + t.min = t.min + localtzm - t.tzs * t.tzm + end + return t end local n = tonumber(s) if n and n >= 0 then diff --git a/tex/context/base/mkiv/l-os.lua b/tex/context/base/mkiv/l-os.lua index e5a43c1d0..7f4f3876b 100644 --- a/tex/context/base/mkiv/l-os.lua +++ b/tex/context/base/mkiv/l-os.lua @@ -26,10 +26,10 @@ if not modules then modules = { } end modules ['l-os'] = { -- math.randomseed(tonumber(string.sub(string.reverse(tostring(math.floor(socket.gettime()*10000))),1,6))) local os = os -local date, time = os.date, os.time +local date, time, difftime = os.date, os.time, os.difftime local find, format, gsub, upper, gmatch = string.find, string.format, string.gsub, string.upper, string.gmatch local concat = table.concat -local random, ceil, randomseed = math.random, math.ceil, math.randomseed +local random, ceil, randomseed, modf = math.random, math.ceil, math.randomseed, math.modf local type, setmetatable, tonumber, tostring = type, setmetatable, tonumber, tostring -- This check needs to happen real early on. Todo: we can pick it up from the commandline @@ -434,23 +434,44 @@ end do - local d - - function os.timezone(delta) - d = d or ((tonumber(date("%H")) or 0) - (tonumber(date("!%H")) or 0)) - if delta then - if d > 0 then - return format("+%02i:00",d) - else - return format("-%02i:00",-d) - end + -- this is fragile because it depends on time and so we only check once during + -- a run (the computer doesn't move zones) .. Michal Vlasák made a better one + + -- local d + -- + -- function os.timezone() + -- d = d or ((tonumber(date("%H")) or 0) - (tonumber(date("!%H")) or 0)) + -- if d > 0 then + -- return format("+%02i:00",d) + -- else + -- return format("-%02i:00",-d) + -- end + -- end + + local hour, min + + function os.timezone(difference) + if not hour then + -- somehow looks too complex: + local current = time() + local utcdate = date("!*t", current) + local localdate = date("*t", current) + localdate.isdst = false + local timediff = difftime(time(localdate), time(utcdate)) + hour, min = modf(timediff / 3600) + min = min * 60 + end + if difference then + return hour, min else - return 1 + return format("%+03d:%02d",hour,min) -- %+ means: always show sign end end - local timeformat = format("%%s%s",os.timezone(true)) - local dateformat = "!%Y-%m-%d %H:%M:%S" + -- localtime with timezone: 2021-10-22 10:22:54+02:00 + + local timeformat = format("%%s%s",os.timezone()) + local dateformat = "%Y-%m-%d %H:%M:%S" local lasttime = nil local lastdate = nil @@ -470,6 +491,8 @@ do return lastdate end + -- localtime without timezone: 2021-10-22 10:22:54 + local dateformat = "%Y-%m-%d %H:%M:%S" local lasttime = nil local lastdate = nil @@ -499,12 +522,16 @@ do end end + -- table with values + function os.today() - return date("!*t") -- table with values + return date("!*t") end + -- utc time without timezone: 2021-10-22 08:22:54 + function os.now() - return date("!%Y-%m-%d %H:%M:%S") -- 2011-12-04 14:59:12 + return date("!%Y-%m-%d %H:%M:%S") end end diff --git a/tex/context/base/mkiv/lxml-tab.lua b/tex/context/base/mkiv/lxml-tab.lua index edc4e75eb..1f0ec33b1 100644 --- a/tex/context/base/mkiv/lxml-tab.lua +++ b/tex/context/base/mkiv/lxml-tab.lua @@ -369,8 +369,7 @@ end local function add_text(text) if text == "" then return - end - if cleanup then + elseif cleanup then if nt > 0 then local s = dt[nt] if type(s) == "string" then @@ -1022,6 +1021,7 @@ local function install(spacenewline,spacing,anything) local text_unparsed = Cs((anything-open)^1) local text_parsed = (Cs((anything-open-ampersand)^1)/add_text + Cs(entity_text)/add_text)^1 +-- local text_parsed = ((Cs(((anything-open-ampersand)^1) + entity_text))/add_text)^1 local somespace = (spacenewline)^1 local optionalspace = (spacenewline)^0 @@ -1043,10 +1043,16 @@ local function install(spacenewline,spacing,anything) local unparsedtext = text_unparsed / add_text local balanced = P { "[" * ((anything - S"[]") + V(1))^0 * "]" } -- taken from lpeg manual, () example + -- todo: combine empty and begin so that we scan attributes only once .. maybe also go for match time captures + local emptyelement = (spacing * open * name * attributes * optionalspace * slash * close) / add_empty local beginelement = (spacing * open * name * attributes * optionalspace * close) / add_begin local endelement = (spacing * open * slash * name * optionalspace * close) / add_end +-- local commonelement = spacing * open * name * attributes * optionalspace * +-- local cemptyelement = (slash * close) / add_empty +-- local cbeginelement = ( * close) / add_begin + -- todo: combine the opens in: local begincomment = open * P("!--") @@ -1103,11 +1109,7 @@ local function install(spacenewline,spacing,anything) local publicdoctype = doctypename * somespace * P("PUBLIC") * somespace * value * somespace * value * somespace * doctypeset local systemdoctype = doctypename * somespace * P("SYSTEM") * somespace * value * somespace * doctypeset local simpledoctype = (anything-close)^1 -- * balanced^0 - local somedoctype = C((somespace * ( - -publicentityfile + - - publicdoctype + systemdoctype + definitiondoctype + simpledoctype) * optionalspace)^0) + local somedoctype = C((somespace * (publicentityfile + publicdoctype + systemdoctype + definitiondoctype + simpledoctype) * optionalspace)^0) local instruction = (spacing * begininstruction * someinstruction * endinstruction) / function(...) add_special("@pi@",...) end local comment = (spacing * begincomment * somecomment * endcomment ) / function(...) add_special("@cm@",...) end @@ -1150,6 +1152,16 @@ publicentityfile + children = parsedtext + V("parent") + emptyelement + comment + cdata + instruction + parsedcrap, } +-- local grammar_parsed_text_two = P { "followup", +-- followup = beginelement * V("children")^0 * endelement * trailer, +-- children = parsedtext + beginelement * V("children")^0 * endelement + emptyelement + comment + cdata + instruction + parsedcrap, +-- } + +-- local grammar_parsed_text_two = P { "followup", +-- followup = commonelement * cbeginelement * V("children")^0 * endelement * trailer, +-- children = parsedtext + commonelement * (cbeginelement * V("children")^0 * endelement + cemptyelement) + comment + cdata + instruction + parsedcrap, +-- } + local grammar_unparsed_text = P { "preamble", preamble = utfbom^0 * instruction^0 * (doctype + comment + instruction)^0 * V("parent") * trailer, parent = beginelement * V("children")^0 * endelement, diff --git a/tex/context/base/mkiv/mlib-pps.lua b/tex/context/base/mkiv/mlib-pps.lua index c80777f5f..303c02fe6 100644 --- a/tex/context/base/mkiv/mlib-pps.lua +++ b/tex/context/base/mkiv/mlib-pps.lua @@ -377,7 +377,7 @@ function models.rgb(cr) elseif metapost.reducetogray then if n == 1 then local s = cr[1] - checked_color_pair(f_gray,s,s) + return checked_color_pair(f_gray,s,s) elseif n == 3 then local r = cr[1] local g = cr[2] diff --git a/tex/context/base/mkiv/mult-prm.lua b/tex/context/base/mkiv/mult-prm.lua index 01f14834b..d0312e18d 100644 --- a/tex/context/base/mkiv/mult-prm.lua +++ b/tex/context/base/mkiv/mult-prm.lua @@ -473,6 +473,7 @@ return { "numexpression", "orelse", "orphanpenalties", + "orphanpenalty", "orunless", "outputbox", "overloaded", @@ -833,6 +834,7 @@ return { "maxdeadcycles", "maxdepth", "meaning", + "meaningasis", "meaningfull", "meaningless", "medmuskip", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex f713ae6ba..894a4da54 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 6d1a2b9e6..fe34b4772 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/syst-con.lua b/tex/context/base/mkiv/syst-con.lua index 8f189d2f1..6a11fa8d3 100644 --- a/tex/context/base/mkiv/syst-con.lua +++ b/tex/context/base/mkiv/syst-con.lua @@ -74,7 +74,7 @@ implement { name = "tand", actions = { math.tand, nicenumber, context }, argumen function commands.format(fmt,...) context((gsub(fmt,"@","%%")),...) end implement { - name = "formatone", + name = "formatone", -- used as such so no name change here public = true, protected = true, arguments = "2 strings", diff --git a/tex/context/base/mkiv/trac-fil.lua b/tex/context/base/mkiv/trac-fil.lua index f422c9f6b..15aee6725 100644 --- a/tex/context/base/mkiv/trac-fil.lua +++ b/tex/context/base/mkiv/trac-fil.lua @@ -45,7 +45,7 @@ patterns.timestamp = timestamp loggers = loggers or { } -local timeformat = format("[%%s%s]",os.timezone(true)) +local timeformat = format("[%%s%s]",os.timezone()) local dateformat = "!%Y-%m-%d %H:%M:%S" function loggers.makeline(t) |