summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-04-16 13:13:20 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2018-04-16 13:13:20 +0200
commitd57683f5f67d6651f7b3353ff347ae57a409e0d4 (patch)
tree1ffc5bda90e3eedad0a35eaa8937472f5563c796 /tex/context/base/mkiv
parentd5d5a39dc16881d098a99b74cba9020d96be4e11 (diff)
downloadcontext-d57683f5f67d6651f7b3353ff347ae57a409e0d4.tar.gz
2018-04-16 12:13:00
Diffstat (limited to 'tex/context/base/mkiv')
-rw-r--r--tex/context/base/mkiv/cont-new.mkiv2
-rw-r--r--tex/context/base/mkiv/context.mkiv2
-rw-r--r--tex/context/base/mkiv/l-os.lua2
-rw-r--r--tex/context/base/mkiv/mlib-ctx.lua6
-rw-r--r--tex/context/base/mkiv/mlib-lua.lua47
-rw-r--r--tex/context/base/mkiv/status-files.pdfbin26106 -> 26106 bytes
-rw-r--r--tex/context/base/mkiv/status-lua.pdfbin255834 -> 256772 bytes
-rw-r--r--tex/context/base/mkiv/util-sto.lua3
-rw-r--r--tex/context/base/mkiv/util-str.lua65
9 files changed, 84 insertions, 43 deletions
diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv
index cc45fc559..e0353b955 100644
--- a/tex/context/base/mkiv/cont-new.mkiv
+++ b/tex/context/base/mkiv/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2018.04.15 23:11}
+\newcontextversion{2018.04.16 12:05}
%D This file is loaded at runtime, thereby providing an excellent place for
%D hacks, patches, extensions and new features.
diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv
index b08b78ef4..9a05525a1 100644
--- a/tex/context/base/mkiv/context.mkiv
+++ b/tex/context/base/mkiv/context.mkiv
@@ -42,7 +42,7 @@
%D has to match \type {YYYY.MM.DD HH:MM} format.
\edef\contextformat {\jobname}
-\edef\contextversion{2018.04.15 23:11}
+\edef\contextversion{2018.04.16 12:05}
\edef\contextkind {beta}
%D For those who want to use this:
diff --git a/tex/context/base/mkiv/l-os.lua b/tex/context/base/mkiv/l-os.lua
index bf13baaa6..b4b1a8645 100644
--- a/tex/context/base/mkiv/l-os.lua
+++ b/tex/context/base/mkiv/l-os.lua
@@ -254,7 +254,7 @@ elseif name == "linux" then
function resolvers.platform(t,k)
-- we sometimes have HOSTTYPE set so let's check that first
local architecture = os.getenv("HOSTTYPE") or resultof("uname -m") or ""
- local platform = os.getenv("MTX_PLATFORM")
+ local platform = os.getenv("MTX_PLATFORM") or ""
local musl = find(os.selfdir or "","linuxmusl")
if platform ~= "" then
-- we're done
diff --git a/tex/context/base/mkiv/mlib-ctx.lua b/tex/context/base/mkiv/mlib-ctx.lua
index c568b92a3..b51c4fd9d 100644
--- a/tex/context/base/mkiv/mlib-ctx.lua
+++ b/tex/context/base/mkiv/mlib-ctx.lua
@@ -337,17 +337,17 @@ implement {
}
}
-statistics.register("metapost processing time", function()
+statistics.register("metapost", function()
local n = metapost.n
if n and n > 0 then
local nofconverted = metapost.makempy.nofconverted
local elapsedtime = statistics.elapsedtime
local elapsed = statistics.elapsed
local instances, memory = metapost.getstatistics(true)
- local str = format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, memory: %0.3f M",
+ local str = format("%s seconds, loading: %s, execution: %s, n: %s, average: %s, instances: %i, luacalls: %i, memory: %0.3f M",
elapsedtime(metapost), elapsedtime(mplib), elapsedtime(metapost.exectime), n,
elapsedtime((elapsed(metapost) + elapsed(mplib) + elapsed(metapost.exectime)) / n),
- instances, memory/(1024*1024))
+ instances, metapost.nofscriptruns(),memory/(1024*1024))
if nofconverted > 0 then
return format("%s, external: %s (%s calls)",
str, elapsedtime(metapost.makempy), nofconverted)
diff --git a/tex/context/base/mkiv/mlib-lua.lua b/tex/context/base/mkiv/mlib-lua.lua
index d934e6472..189f207c7 100644
--- a/tex/context/base/mkiv/mlib-lua.lua
+++ b/tex/context/base/mkiv/mlib-lua.lua
@@ -359,35 +359,36 @@ end
-- endfor ;
-- \stopMPpage
-local cache, n = { }, 0 -- todo: when > n then reset cache or make weak
+local runs = 0
+
+function metapost.nofscriptruns()
+ return runs
+end
+
+-- local cache = table.makeweak()
+--
+-- f = cache[code]
+-- if not f then
+-- f = loadstring(f_code(code))
+-- if f then
+-- cache[code] = f
+-- elseif be_tolerant then
+-- f = loadstring(code)
+-- if f then
+-- cache[code] = f
+-- end
+-- end
+-- end
function metapost.runscript(code)
local trace = trace_enabled and trace_luarun
if trace then
report_luarun("code: %s",code)
end
- local f
- if n > 100 then
- cache = nil -- forget about caching
- f = loadstring(f_code(code))
- if not f and be_tolerant then
- f = loadstring(code)
- end
- else
- f = cache[code]
- if not f then
- f = loadstring(f_code(code))
- if f then
- n = n + 1
- cache[code] = f
- elseif be_tolerant then
- f = loadstring(code)
- if f then
- n = n + 1
- cache[code] = f
- end
- end
- end
+ runs = runs + 1
+ local f = loadstring(f_code(code))
+ if not f and be_tolerant then
+ f = loadstring(code)
end
if f then
local result = f()
diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf
index 44f2a3e83..489383f73 100644
--- a/tex/context/base/mkiv/status-files.pdf
+++ b/tex/context/base/mkiv/status-files.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf
index 6ac2e451c..f0e3e40b0 100644
--- a/tex/context/base/mkiv/status-lua.pdf
+++ b/tex/context/base/mkiv/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/mkiv/util-sto.lua b/tex/context/base/mkiv/util-sto.lua
index 0da685e9f..a08d25ced 100644
--- a/tex/context/base/mkiv/util-sto.lua
+++ b/tex/context/base/mkiv/util-sto.lua
@@ -197,6 +197,9 @@ function table.getmetatablekey(t,key,value)
end
function table.makeweak(t)
+ if not t then
+ t = { }
+ end
local m = getmetatable(t)
if m then
m.__mode = "v"
diff --git a/tex/context/base/mkiv/util-str.lua b/tex/context/base/mkiv/util-str.lua
index 05ff9f304..56c5b011c 100644
--- a/tex/context/base/mkiv/util-str.lua
+++ b/tex/context/base/mkiv/util-str.lua
@@ -412,25 +412,46 @@ end
local digit = patterns.digit
local period = patterns.period
-local three = digit * digit * digit
+local two = digit * digit
+local three = two * digit
+local prefix = (Carg(1) * three)^1
+
local splitter = Cs (
- (((1 - (three^1 * period))^1 + C(three)) * (Carg(1) * three)^1 + C((1-period)^1))
+ (((1 - (three^1 * period))^1 + C(three)) * prefix + C((1-period)^1))
* (P(1)/"" * Carg(2)) * C(2)
)
+local splitter3 = Cs (
+ three * prefix * P(-1) +
+ two * prefix * P(-1) +
+ digit * prefix * P(-1) +
+ three +
+ two +
+ digit
+)
+
patterns.formattednumber = splitter
function number.formatted(n,sep1,sep2)
- local s = type(s) == "string" and n or format("%0.2f",n)
- if sep1 == true then
- return lpegmatch(splitter,s,1,".",",")
- elseif sep1 == "." then
- return lpegmatch(splitter,s,1,sep1,sep2 or ",")
- elseif sep1 == "," then
- return lpegmatch(splitter,s,1,sep1,sep2 or ".")
+ if sep1 == false then
+ if type(n) == "number" then
+ n = tostring(n)
+ end
+ return lpegmatch(splitter3,n,1,sep2 or ".")
else
- return lpegmatch(splitter,s,1,sep1 or ",",sep2 or ".")
+ if type(n) == "number" then
+ n = format("%0.2f",n)
+ end
+ if sep1 == true then
+ return lpegmatch(splitter,n,1,".",",")
+ elseif sep1 == "." then
+ return lpegmatch(splitter,n,1,sep1,sep2 or ",")
+ elseif sep1 == "," then
+ return lpegmatch(splitter,n,1,sep1,sep2 or ".")
+ else
+ return lpegmatch(splitter,n,1,sep1 or ",",sep2 or ".")
+ end
end
end
@@ -443,6 +464,14 @@ end
-- print(number.formatted(1234567))
-- print(number.formatted(12345678))
-- print(number.formatted(12345678,true))
+-- print(number.formatted(1,false))
+-- print(number.formatted(12,false))
+-- print(number.formatted(123,false))
+-- print(number.formatted(1234,false))
+-- print(number.formatted(12345,false))
+-- print(number.formatted(123456,false))
+-- print(number.formatted(1234567,false))
+-- print(number.formatted(12345678,false))
-- print(number.formatted(1234.56,"!","?"))
local p = Cs(
@@ -882,7 +911,11 @@ local format_m = function(f)
if not f or f == "" then
f = ","
end
- return format([[formattednumber(a%s,%q,".")]],n,f)
+ if f == "0" then
+ return format([[formattednumber(a%s,false)]],n)
+ else
+ return format([[formattednumber(a%s,%q,".")]],n,f)
+ end
end
local format_M = function(f)
@@ -890,7 +923,11 @@ local format_M = function(f)
if not f or f == "" then
f = "."
end
- return format([[formattednumber(a%s,%q,",")]],n,f)
+ if f == "0" then
+ return format([[formattednumber(a%s,false)]],n)
+ else
+ return format([[formattednumber(a%s,%q,",")]],n,f)
+ end
end
--
@@ -1029,8 +1066,8 @@ local builder = Cs { "start",
["j"] = (prefix_any * P("j")) / format_j, -- %j => %e (float) stripped exponent (irrational)
["J"] = (prefix_any * P("J")) / format_J, -- %J => %E (float) stripped exponent (irrational)
--
- ["m"] = (prefix_tab * P("m")) / format_m, -- %m => xxx.xxx.xxx,xx (optional prefix instead of .)
- ["M"] = (prefix_tab * P("M")) / format_M, -- %M => xxx,xxx,xxx.xx (optional prefix instead of ,)
+ ["m"] = (prefix_any * P("m")) / format_m, -- %m => xxx.xxx.xxx,xx (optional prefix instead of .)
+ ["M"] = (prefix_any * P("M")) / format_M, -- %M => xxx,xxx,xxx.xx (optional prefix instead of ,)
--
["z"] = (prefix_any * P("z")) / format_z, -- %z => skip n arguments
--