From f6e7648f6126ffe087071531f03c674be32930f1 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Tue, 20 Aug 2019 19:19:52 +0200 Subject: 2019-08-20 17:28:00 --- tex/context/base/mkiv/util-str.lua | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'tex/context/base/mkiv/util-str.lua') diff --git a/tex/context/base/mkiv/util-str.lua b/tex/context/base/mkiv/util-str.lua index 92e17b550..432b39ec5 100644 --- a/tex/context/base/mkiv/util-str.lua +++ b/tex/context/base/mkiv/util-str.lua @@ -633,7 +633,7 @@ local environment = { stripzeros = patterns.stripzeros, escapedquotes = string.escapedquotes, - FORMAT = string.f9, + FORMAT = string.f6, } -- -- -- @@ -938,13 +938,30 @@ end -- end -- end -local format_N = function(f) -- strips leading and trailing zeros - n = n + 1 - -- stripzero (singular) as we only have a number - if not f or f == "" then - f = ".9" - end -- always a leading number ! - return format("(((a%s %% 1 == 0) and format('%%i',a%s)) or lpegmatch(stripzero,format('%%%sf',a%s)))",n,n,f,n) +local format_N if environment.FORMAT then + + format_N = function(f) + n = n + 1 + if not f or f == "" then + return format("FORMAT(a%s,'%%.9f')",n) + elseif f == ".6" then + return format("FORMAT(a%s)",n) + else + return format("FORMAT(a%s,'%%%sf')",n,f) + end + end + +else + + format_N = function(f) -- strips leading and trailing zeros + n = n + 1 + -- stripzero (singular) as we only have a number + if not f or f == "" then + f = ".9" + end -- always a leading number ! + return format("(((a%s %% 1 == 0) and format('%%i',a%s)) or lpegmatch(stripzero,format('%%%sf',a%s)))",n,n,f,n) + end + end local format_a = function(f) -- cgit v1.2.3