[latex3-commits] [git/LaTeX3-latex3-lualibs] v2.74-20210520: import new context files (e169fde)

Ulrike Fischer fischer at troubleshooting-tex.de
Thu May 20 23:35:04 CEST 2021


Repository : https://github.com/latex3/lualibs
On branch  : v2.74-20210520
Link       : https://github.com/latex3/lualibs/commit/e169fde631faaac8c0c62db5aaddaf50aff697c2

>---------------------------------------------------------------

commit e169fde631faaac8c0c62db5aaddaf50aff697c2
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Thu May 20 23:35:04 2021 +0200

    import new context files


>---------------------------------------------------------------

e169fde631faaac8c0c62db5aaddaf50aff697c2
 CTANREADME.md               |   6 +--
 README.md                   |   6 +--
 build.lua                   |   6 +--
 lualibs-basic-merged.lua    |  28 +++++++++----
 lualibs-extended-merged.lua |  60 ++++++++++++++++++++++----
 lualibs-lpeg.lua            |   2 +-
 lualibs-number.lua          |  52 +----------------------
 lualibs-os.lua              |   2 +-
 lualibs-package.lua         |  22 +++++++++-
 lualibs-trac-inf.lua        |   2 -
 lualibs-url.lua             | 100 ++++++++++++++++++++++----------------------
 lualibs-util-str.lua        |  70 +++++++++++++++++++++++++++----
 lualibs.dtx                 |  18 ++++----
 13 files changed, 226 insertions(+), 148 deletions(-)

diff --git a/CTANREADME.md b/CTANREADME.md
index cf330df..e2cd6be 100644
--- a/CTANREADME.md
+++ b/CTANREADME.md
@@ -1,10 +1,10 @@
 # The Lualibs Package
 
-VERSION: 2.73
+VERSION: 2.74
 
-DATE: 2020-12-30
+DATE: 2021-05-20
 
-FONTLOADERDATE: 2020-12-30
+FONTLOADERDATE: 2021-05-20
 
 Lualibs is a collection of Lua modules useful for general programming.
 
diff --git a/README.md b/README.md
index c27df49..78f068c 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 # The Lualibs Package
 
-![Version: 2.73](https://img.shields.io/badge/current_version-2.73-blue.svg?style=flat-square)
-![Date: 2020-12-30](https://img.shields.io/badge/date-2020--12--30-blue.svg?style=flat-square)
+![Version: 2.74](https://img.shields.io/badge/current_version-2.74-blue.svg?style=flat-square)
+![Date: 2021-05-20](https://img.shields.io/badge/date-2021--05--20-blue.svg?style=flat-square)
 [![License: GNU GPLv2](https://img.shields.io/badge/license-GNU_GPLv2-blue.svg?style=flat-square)](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 
 
@@ -15,7 +15,7 @@ This package has been developed by the LuaLaTeX development team on
 <http://github.com/lualatex/lualibs>. 
 
 The current version has been build by the LaTeX3 Project Team on
-<https://github.com/latex3/lualibs/> from context 2020-12-30. 
+<https://github.com/latex3/lualibs/> from context 2021-05-20. 
 
 Please see the documentation lualibs.pdf for more information.
 
diff --git a/build.lua b/build.lua
index 7b7e7d7..5d44553 100644
--- a/build.lua
+++ b/build.lua
@@ -1,7 +1,7 @@
 -- Build script for lualibs
-packageversion= "2.73"
-packagedate= "2020-12-30"
-fontloaderdate= "2020-12-30" -- only as record.
+packageversion= "2.74"
+packagedate= "2021-05-20"
+fontloaderdate= "2021-05-20" -- only as record.
 
 module   = "lualibs"
 ctanpkg  = "lualibs"
diff --git a/lualibs-basic-merged.lua b/lualibs-basic-merged.lua
index 92e571a..ac98df3 100644
--- a/lualibs-basic-merged.lua
+++ b/lualibs-basic-merged.lua
@@ -1,6 +1,6 @@
 -- merged file : lualibs-basic-merged.lua
 -- parent file : lualibs-basic.lua
--- merge date  : Wed Dec 30 17:55:54 2020
+-- merge date  : 2021-05-20 23:14
 
 do -- begin closure to overcome local limits and interference
 
@@ -133,7 +133,7 @@ if not modules then modules={} end modules ['l-package']={
  copyright="PRAGMA ADE / ConTeXt Development Team",
  license="see context related readme files"
 }
-local type=type
+local type,unpack=type,unpack
 local gsub,format,find=string.gsub,string.format,string.find
 local insert,remove=table.insert,table.remove
 local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match
@@ -163,6 +163,7 @@ local helpers=package.helpers or {
  },
  methods={},
  sequence={
+  "reset loaded",
   "already loaded",
   "preload table",
   "qualified path",
@@ -179,6 +180,7 @@ local methods=helpers.methods
 local builtin=helpers.builtin
 local extraluapaths={}
 local extralibpaths={}
+local checkedfiles={}
 local luapaths=nil 
 local libpaths=nil 
 local oldluapath=nil
@@ -312,10 +314,16 @@ end
 local function loadedaslib(resolved,rawname) 
  local base=gsub(rawname,"%.","_")
  local init="luaopen_"..gsub(base,"%.","_")
+ local data={ resolved,init,"" }
+ checkedfiles[#checkedfiles+1]=data
  if helpers.trace then
   helpers.report("calling loadlib with '%s' with init '%s'",resolved,init)
  end
- return package.loadlib(resolved,init)
+ local a,b,c=package.loadlib(resolved,init)
+ if not a and type(b)=="string" then
+  data[3]=string.fullstrip(b or "unknown error")
+ end
+ return a,b,c 
 end
 helpers.loadedaslib=loadedaslib
 local function loadedbypath(name,rawname,paths,islib,what)
@@ -354,6 +362,10 @@ local function loadedbyname(name,rawname)
  end
 end
 helpers.loadedbyname=loadedbyname
+methods["reset loaded"]=function(name)
+ checkedfiles={}
+ return false
+end
 methods["already loaded"]=function(name)
  return package.loaded[name]
 end
@@ -395,6 +407,9 @@ end
 methods["not loaded"]=function(name)
  if helpers.trace then
   helpers.report("unable to locate '%s'",name or "?")
+  for i=1,#checkedfiles do
+   helpers.report("checked file '%s', initializer '%s', message '%s'",unpack(checkedfiles[i]))
+  end
  end
  return nil
 end
@@ -2591,13 +2606,13 @@ do -- begin closure to overcome local limits and interference
 
 if not modules then modules={} end modules ['l-number']={
  version=1.001,
- comment="companion to luat-lib.mkiv",
+ comment="companion to luat-lib.mkxl",
  author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
  copyright="PRAGMA ADE / ConTeXt Development Team",
  license="see context related readme files"
 }
 local tostring,tonumber=tostring,tonumber
-local format,floor,match,rep=string.format,math.floor,string.match,string.rep
+local format,match,rep=string.format,string.match,string.rep
 local concat,insert=table.concat,table.insert
 local lpegmatch=lpeg.match
 local floor=math.floor
@@ -3371,7 +3386,7 @@ elseif name=="macosx" then
   elseif find(architecture,"x86_64",1,true) then
    platform="osx-64"
   elseif find(architecture,"arm64",1,true) then
-   platform="osx-64"
+   platform="osx-arm"
   else
    platform="osx-ppc"
   end
@@ -4698,7 +4713,6 @@ if not modules then modules={} end modules ['l-unicode']={
  license="see context related readme files"
 }
 utf=utf or {}
--- unicode=nil
 if not string.utfcharacters then
  local gmatch=string.gmatch
  function string.characters(str)
diff --git a/lualibs-extended-merged.lua b/lualibs-extended-merged.lua
index cac8889..9cd4487 100644
--- a/lualibs-extended-merged.lua
+++ b/lualibs-extended-merged.lua
@@ -1,6 +1,6 @@
 -- merged file : lualibs-extended-merged.lua
 -- parent file : lualibs-extended.lua
--- merge date  : Wed Dec 30 17:55:44 2020
+-- merge date  : 2021-05-20 23:14
 
 do -- begin closure to overcome local limits and interference
 
@@ -54,25 +54,59 @@ local function points(n)
  n=n*ptf
  if n%1==0 then
   return format("%ipt",n)
+ else
+  return lpegmatch(stripzeros,format("%.5fpt",n)) 
+ end
+end
+local function nupoints(n)
+ if n==0 then
+  return "0"
+ end
+ n=tonumber(n)
+ if not n or n==0 then
+  return "0"
+ end
+ n=n*ptf
+ if n%1==0 then
+  return format("%i",n)
+ else
+  return format("%.5f",n) 
  end
- return lpegmatch(stripzeros,format("%.5fpt",n)) 
 end
 local function basepoints(n)
  if n==0 then
-  return "0pt"
+  return "0bp"
  end
  n=tonumber(n)
  if not n or n==0 then
-  return "0pt"
+  return "0bp"
  end
  n=n*bpf
  if n%1==0 then
   return format("%ibp",n)
+ else
+  return lpegmatch(stripzeros,format("%.5fbp",n)) 
+ end
+end
+local function nubasepoints(n)
+ if n==0 then
+  return "0"
+ end
+ n=tonumber(n)
+ if not n or n==0 then
+  return "0"
+ end
+ n=n*bpf
+ if n%1==0 then
+  return format("%i",n)
+ else
+  return format("%.5f",n) 
  end
- return lpegmatch(stripzeros,format("%.5fbp",n)) 
 end
 number.points=points
+number.nupoints=nupoints
 number.basepoints=basepoints
+number.nubasepoints=nubasepoints
 local rubish=spaceortab^0*newline
 local anyrubish=spaceortab+newline
 local stripped=(spaceortab^1/"")*newline
@@ -350,7 +384,9 @@ local environment={
  concat=table.concat,
  signed=number.signed,
  points=number.points,
+ nupoints=number.nupoints,
  basepoints=number.basepoints,
+ nubasepoints=number.nubasepoints,
  utfchar=utf.char,
  utfbyte=utf.byte,
  lpegmatch=lpeg.match,
@@ -545,10 +581,18 @@ local format_p=function()
  n=n+1
  return format("points(a%s)",n)
 end
+local format_P=function()
+ n=n+1
+ return format("nupoints(a%s)",n)
+end
 local format_b=function()
  n=n+1
  return format("basepoints(a%s)",n)
 end
+local format_B=function()
+ n=n+1
+ return format("nubasepoints(a%s)",n)
+end
 local format_t=function(f)
  n=n+1
  if f and f~="" then
@@ -701,7 +745,7 @@ local builder=Cs { "start",
 +V("n") 
 +V("N") 
 +V("k")
-+V("r")+V("h")+V("H")+V("u")+V("U")+V("p")+V("b")+V("t")+V("T")+V("l")+V("L")+V("I")+V("w") 
++V("r")+V("h")+V("H")+V("u")+V("U")+V("p")+V("P")+V("b")+V("B")+V("t")+V("T")+V("l")+V("L")+V("I")+V("w") 
 +V("W") 
 +V("a") 
 +V("A") 
@@ -739,7 +783,9 @@ local builder=Cs { "start",
  ["u"]=(prefix_any*P("u"))/format_u,
  ["U"]=(prefix_any*P("U"))/format_U,
  ["p"]=(prefix_any*P("p"))/format_p,
+ ["P"]=(prefix_any*P("P"))/format_P,
  ["b"]=(prefix_any*P("b"))/format_b,
+ ["B"]=(prefix_any*P("B"))/format_B,
  ["t"]=(prefix_tab*P("t"))/format_t,
  ["T"]=(prefix_tab*P("T"))/format_T,
  ["l"]=(prefix_any*P("l"))/format_l,
@@ -3312,10 +3358,8 @@ local function stoptiming(instance)
    timer.loadtime=timer.loadtime+loadtime
    timer.timing=0
    timer.starttime=0
-   return loadtime
   end
  end
- return 0
 end
 local function benchmarktimer(instance)
  local timer=timers[instance or "notimer"]
diff --git a/lualibs-lpeg.lua b/lualibs-lpeg.lua
index b0868ba..50306e4 100644
--- a/lualibs-lpeg.lua
+++ b/lualibs-lpeg.lua
@@ -507,7 +507,7 @@ end
 
 -- todo: cache when string
 
-function lpeg.replacer(one,two,makefunction,isutf) -- in principle we should sort the keys
+function lpeg.replacer(one,two,makefunction,isutf) -- in principle we should sort the keys but we have a better one anyway
     local pattern
     local u = isutf and utf8char or 1
     if type(one) == "table" then
diff --git a/lualibs-number.lua b/lualibs-number.lua
index 9fd2f82..0ec6088 100644
--- a/lualibs-number.lua
+++ b/lualibs-number.lua
@@ -1,16 +1,13 @@
 if not modules then modules = { } end modules ['l-number'] = {
     version   = 1.001,
-    comment   = "companion to luat-lib.mkiv",
+    comment   = "companion to luat-lib.mkxl",
     author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
     copyright = "PRAGMA ADE / ConTeXt Development Team",
     license   = "see context related readme files"
 }
 
--- this module will be replaced when we have the bit library .. the number based sets
--- might go away
-
 local tostring, tonumber = tostring, tonumber
-local format, floor, match, rep = string.format, math.floor, string.match, string.rep
+local format, match, rep = string.format, string.match, string.rep
 local concat, insert = table.concat, table.insert
 local lpegmatch = lpeg.match
 local floor = math.floor
@@ -18,51 +15,6 @@ local floor = math.floor
 number       = number or { }
 local number = number
 
--- begin obsolete code --
-
--- if bit32 then
---
---     local btest, bor = bit32.btest, bit32.bor
---
---     function number.bit(p)
---         return 2 ^ (p - 1) -- 1-based indexing
---     end
---
---     number.hasbit = btest
---     number.setbit = bor
---
---     function number.setbit(x,p) -- why not bor?
---         return btest(x,p) and x or x + p
---     end
---
---     function number.clearbit(x,p)
---         return btest(x,p) and x - p or x
---     end
---
--- else
---
---     -- http://ricilake.blogspot.com/2007/10/iterating-bits-in-lua.html
---
---     function number.bit(p)
---         return 2 ^ (p - 1) -- 1-based indexing
---     end
---
---     function number.hasbit(x, p) -- typical call: if hasbit(x, bit(3)) then ...
---         return x % (p + p) >= p
---     end
---
---     function number.setbit(x, p)
---         return (x % (p + p) >= p) and x or x + p
---     end
---
---     function number.clearbit(x, p)
---         return (x % (p + p) >= p) and x - p or x
---     end
---
--- end
-
--- end obsolete code --
-
 -- print(number.tobitstring(8))
 -- print(number.tobitstring(14))
 -- print(number.tobitstring(66))
diff --git a/lualibs-os.lua b/lualibs-os.lua
index 7384107..c7584cc 100644
--- a/lualibs-os.lua
+++ b/lualibs-os.lua
@@ -359,7 +359,7 @@ elseif name == "macosx" then
         elseif find(architecture,"x86_64",1,true) then
             platform = "osx-64"
         elseif find(architecture,"arm64",1,true) then
-            platform = "osx-64"
+            platform = "osx-arm"
         else
             platform = "osx-ppc"
         end
diff --git a/lualibs-package.lua b/lualibs-package.lua
index a35ec3e..ef37aeb 100644
--- a/lualibs-package.lua
+++ b/lualibs-package.lua
@@ -16,7 +16,7 @@ if not modules then modules = { } end modules ['l-package'] = {
 -- -- local mylib = require("libtest")
 -- -- local mysql = require("luasql.mysql")
 
-local type = type
+local type, unpack = type, unpack
 local gsub, format, find = string.gsub, string.format, string.find
 local insert, remove = table.insert, table.remove
 
@@ -70,6 +70,7 @@ local helpers = package.helpers or {
     methods    = {
     },
     sequence   = {
+        "reset loaded",
         "already loaded",
         "preload table",
         "qualified path", -- beware, lua itself doesn't handle qualified paths (prepends ./)
@@ -91,6 +92,7 @@ local builtin = helpers.builtin
 
 local extraluapaths = { }
 local extralibpaths = { }
+local checkedfiles  = { }
 local luapaths      = nil -- delayed
 local libpaths      = nil -- delayed
 local oldluapath    = nil
@@ -245,10 +247,17 @@ local function loadedaslib(resolved,rawname) -- todo: strip all before first -
  -- so, we can do a require("foo/bar") and initialize bar
  -- local base = gsub(file.basename(rawname),"%.","_")
     local init = "luaopen_" .. gsub(base,"%.","_")
+    local data = { resolved, init, "" }
+    checkedfiles[#checkedfiles+1] = data
     if helpers.trace then
         helpers.report("calling loadlib with '%s' with init '%s'",resolved,init)
     end
-    return package.loadlib(resolved,init)
+    local a, b, c = package.loadlib(resolved,init)
+    if not a and type(b) == "string" then
+--         data[3] = gsub(b or "unknown error","[\n\r]","")
+        data[3] = string.fullstrip(b or "unknown error")
+    end
+    return a, b, c -- c can be 'init'
 end
 
 helpers.loadedaslib = loadedaslib
@@ -295,6 +304,12 @@ end
 
 helpers.loadedbyname = loadedbyname
 
+methods["reset loaded"] = function(name)
+    checkedfiles = { }
+    return false
+end
+
+
 methods["already loaded"] = function(name)
     return package.loaded[name]
 end
@@ -344,6 +359,9 @@ end
 methods["not loaded"] = function(name)
     if helpers.trace then
         helpers.report("unable to locate '%s'",name or "?")
+        for i=1,#checkedfiles do
+            helpers.report("checked file '%s', initializer '%s', message '%s'",unpack(checkedfiles[i]))
+        end
     end
     return nil
 end
diff --git a/lualibs-trac-inf.lua b/lualibs-trac-inf.lua
index 3db912b..e2736cf 100644
--- a/lualibs-trac-inf.lua
+++ b/lualibs-trac-inf.lua
@@ -129,10 +129,8 @@ local function stoptiming(instance)
             timer.loadtime  = timer.loadtime + loadtime
             timer.timing    = 0
             timer.starttime = 0
-            return loadtime
         end
     end
-    return 0
 end
 
 local function benchmarktimer(instance)
diff --git a/lualibs-url.lua b/lualibs-url.lua
index 6f834d7..2e01ad4 100644
--- a/lualibs-url.lua
+++ b/lualibs-url.lua
@@ -379,53 +379,53 @@ end
 -- print(url.barepath("/test"),url.barepath("test/"),url.barepath("/test/"),url.barepath("test"))
 -- print(url.barepath("/x/yz"),url.barepath("x/yz/"),url.barepath("/x/yz/"),url.barepath("x/yz"))
 
---~ print(url.filename("file:///c:/oeps.txt"))
---~ print(url.filename("c:/oeps.txt"))
---~ print(url.filename("file:///oeps.txt"))
---~ print(url.filename("file:///etc/test.txt"))
---~ print(url.filename("/oeps.txt"))
-
---~ from the spec on the web (sort of):
-
---~ local function test(str)
---~     local t = url.hashed(str)
---~     t.constructed = url.construct(t)
---~     print(table.serialize(t))
---~ end
-
---~ inspect(url.hashed("http://www.pragma-ade.com/test%20test?test=test%20test&x=123%3d45"))
---~ inspect(url.hashed("http://www.pragma-ade.com/test%20test?test=test%20test&x=123%3d45"))
-
---~ test("sys:///./colo-rgb")
-
---~ test("/data/site/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733/figuur-cow.jpg")
---~ test("file:///M:/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733")
---~ test("M:/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733")
---~ test("file:///q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733")
---~ test("/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733")
-
---~ test("file:///cow%20with%20spaces")
---~ test("file:///cow%20with%20spaces.pdf")
---~ test("cow%20with%20spaces.pdf")
---~ test("some%20file")
---~ test("/etc/passwords")
---~ test("http://www.myself.com/some%20words.html")
---~ test("file:///c:/oeps.txt")
---~ test("file:///c|/oeps.txt")
---~ test("file:///etc/oeps.txt")
---~ test("file://./etc/oeps.txt")
---~ test("file:////etc/oeps.txt")
---~ test("ftp://ftp.is.co.za/rfc/rfc1808.txt")
---~ test("http://www.ietf.org/rfc/rfc2396.txt")
---~ test("ldap://[2001:db8::7]/c=GB?objectClass?one#what")
---~ test("mailto:John.Doe at example.com")
---~ test("news:comp.infosystems.www.servers.unix")
---~ test("tel:+1-816-555-1212")
---~ test("telnet://192.0.2.16:80/")
---~ test("urn:oasis:names:specification:docbook:dtd:xml:4.1.2")
---~ test("http://www.pragma-ade.com/spaced%20name")
-
---~ test("zip:///oeps/oeps.zip#bla/bla.tex")
---~ test("zip:///oeps/oeps.zip?bla/bla.tex")
-
---~ table.print(url.hashed("/test?test"))
+-- print(url.filename("file:///c:/oeps.txt"))
+-- print(url.filename("c:/oeps.txt"))
+-- print(url.filename("file:///oeps.txt"))
+-- print(url.filename("file:///etc/test.txt"))
+-- print(url.filename("/oeps.txt"))
+
+-- from the spec on the web (sort of):
+
+-- local function test(str)
+--     local t = url.hashed(str)
+--     t.constructed = url.construct(t)
+--     print(table.serialize(t))
+-- end
+
+-- inspect(url.hashed("http://www.pragma-ade.com/test%20test?test=test%20test&x=123%3d45"))
+-- inspect(url.hashed("http://www.pragma-ade.com/test%20test?test=test%20test&x=123%3d45"))
+
+-- test("sys:///./colo-rgb")
+
+-- test("/data/site/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733/figuur-cow.jpg")
+-- test("file:///M:/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733")
+-- test("M:/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733")
+-- test("file:///q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733")
+-- test("/q2p/develop/output/q2p-develop/resources/ecaboperception4_res/topicresources/58313733")
+
+-- test("file:///cow%20with%20spaces")
+-- test("file:///cow%20with%20spaces.pdf")
+-- test("cow%20with%20spaces.pdf")
+-- test("some%20file")
+-- test("/etc/passwords")
+-- test("http://www.myself.com/some%20words.html")
+-- test("file:///c:/oeps.txt")
+-- test("file:///c|/oeps.txt")
+-- test("file:///etc/oeps.txt")
+-- test("file://./etc/oeps.txt")
+-- test("file:////etc/oeps.txt")
+-- test("ftp://ftp.is.co.za/rfc/rfc1808.txt")
+-- test("http://www.ietf.org/rfc/rfc2396.txt")
+-- test("ldap://[2001:db8::7]/c=GB?objectClass?one#what")
+-- test("mailto:John.Doe at example.com")
+-- test("news:comp.infosystems.www.servers.unix")
+-- test("tel:+1-816-555-1212")
+-- test("telnet://192.0.2.16:80/")
+-- test("urn:oasis:names:specification:docbook:dtd:xml:4.1.2")
+-- test("http://www.pragma-ade.com/spaced%20name")
+
+-- test("zip:///oeps/oeps.zip#bla/bla.tex")
+-- test("zip:///oeps/oeps.zip?bla/bla.tex")
+
+-- table.print(url.hashed("/test?test"))
diff --git a/lualibs-util-str.lua b/lualibs-util-str.lua
index 2d3f4d6..0d1f39d 100644
--- a/lualibs-util-str.lua
+++ b/lualibs-util-str.lua
@@ -70,27 +70,63 @@ local function points(n)
     n = n * ptf
     if n % 1 == 0 then
         return format("%ipt",n)
+    else
+        return lpegmatch(stripzeros,format("%.5fpt",n)) -- plural as we need to keep the pt
+    end
+end
+
+local function nupoints(n)
+    if n == 0 then
+        return "0"
+    end
+    n = tonumber(n)
+    if not n or n == 0 then
+        return "0"
+    end
+    n = n * ptf
+    if n % 1 == 0 then
+        return format("%i",n)
+    else
+        return format("%.5f",n) -- no strip
     end
-    return lpegmatch(stripzeros,format("%.5fpt",n)) -- plural as we need to keep the pt
 end
 
 local function basepoints(n)
     if n == 0 then
-        return "0pt"
+        return "0bp"
     end
     n = tonumber(n)
     if not n or n == 0 then
-        return "0pt"
+        return "0bp"
     end
     n = n * bpf
     if n % 1 == 0 then
         return format("%ibp",n)
+    else
+        return lpegmatch(stripzeros,format("%.5fbp",n)) -- plural as we need to keep the pt
+    end
+end
+
+local function nubasepoints(n)
+    if n == 0 then
+        return "0"
+    end
+    n = tonumber(n)
+    if not n or n == 0 then
+        return "0"
+    end
+    n = n * bpf
+    if n % 1 == 0 then
+        return format("%i",n)
+    else
+        return format("%.5f",n) -- no strip
     end
-    return lpegmatch(stripzeros,format("%.5fbp",n)) -- plural as we need to keep the pt
 end
 
-number.points     = points
-number.basepoints = basepoints
+number.points       = points
+number.nupoints     = nupoints
+number.basepoints   = basepoints
+number.nubasepoints = nubasepoints
 
 -- str = " \n \ntest  \n test\ntest "
 -- print("["..string.gsub(string.collapsecrlf(str),"\n","+").."]")
@@ -357,7 +393,9 @@ end
 -- U+hexadecimal      %...u   character number
 -- U+HEXADECIMAL      %...U   character number
 -- points             %p      number (scaled points)
+-- nupoints           %P      number (scaled points) / without unit / always 5 decimals
 -- basepoints         %b      number (scaled points)
+-- nubasepoints       %B      number (scaled points) / without unit / always 5 decimals
 -- table concat       %...t   table
 -- table concat       %{.}t   table
 -- serialize          %...T   sequenced (no nested tables)
@@ -616,7 +654,9 @@ local environment = {
     concat          = table.concat,
     signed          = number.signed,
     points          = number.points,
+    nupoints        = number.nupoints,
     basepoints      = number.basepoints,
+    nubasepoints    = number.nubasepoints,
     utfchar         = utf.char,
     utfbyte         = utf.byte,
     lpegmatch       = lpeg.match,
@@ -879,11 +919,21 @@ local format_p = function()
     return format("points(a%s)",n)
 end
 
+local format_P = function()
+    n = n + 1
+    return format("nupoints(a%s)",n)
+end
+
 local format_b = function()
     n = n + 1
     return format("basepoints(a%s)",n)
 end
 
+local format_B = function()
+    n = n + 1
+    return format("nubasepoints(a%s)",n)
+end
+
 local format_t = function(f)
     n = n + 1
     if f and f ~= "" then
@@ -1125,7 +1175,7 @@ local builder = Cs { "start",
               --
               + V("r")
               + V("h") + V("H") + V("u") + V("U")
-              + V("p") + V("b")
+              + V("p") + V("P") + V("b") + V("B")
               + V("t") + V("T")
               + V("l") + V("L")
               + V("I")
@@ -1174,8 +1224,10 @@ local builder = Cs { "start",
     ["H"] = (prefix_any * P("H")) / format_H, -- %H => 0x0A1B2 (when - no 0x) was V
     ["u"] = (prefix_any * P("u")) / format_u, -- %u => u+0a1b2 (when - no u+)
     ["U"] = (prefix_any * P("U")) / format_U, -- %U => U+0A1B2 (when - no U+)
-    ["p"] = (prefix_any * P("p")) / format_p, -- %p => 12.345pt / maybe: P (and more units)
-    ["b"] = (prefix_any * P("b")) / format_b, -- %b => 12.342bp / maybe: B (and more units)
+    ["p"] = (prefix_any * P("p")) / format_p, -- %p => 12.345pt
+    ["P"] = (prefix_any * P("P")) / format_P, -- %p => 12.345
+    ["b"] = (prefix_any * P("b")) / format_b, -- %b => 12.342bp
+    ["B"] = (prefix_any * P("B")) / format_B, -- %b => 12.342
     ["t"] = (prefix_tab * P("t")) / format_t, -- %t => concat
     ["T"] = (prefix_tab * P("T")) / format_T, -- %t => sequenced
     ["l"] = (prefix_any * P("l")) / format_l, -- %l => boolean
diff --git a/lualibs.dtx b/lualibs.dtx
index 7246e85..68297b6 100644
--- a/lualibs.dtx
+++ b/lualibs.dtx
@@ -37,7 +37,7 @@
 \input docstrip.tex
 \Msg{************************************************************************}
 \Msg{* Installation}
-\Msg{* Package: lualibs 2020-12-30 v2.73 Lua additional functions.}
+\Msg{* Package: lualibs 2021-05-20 v2.74 Lua additional functions.}
 \Msg{************************************************************************}
 
 \keepsilent
@@ -107,7 +107,7 @@ and lualibs-extended.lua.
 %<*driver>
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesFile{lualibs.drv}
-  [2020/12/30 v2.73 Lua Libraries.]
+  [2021/05/20 v2.74 Lua Libraries.]
 \documentclass{ltxdoc}
 \usepackage{fancyvrb,xspace}
 \usepackage[x11names]{xcolor}
@@ -208,7 +208,7 @@ and lualibs-extended.lua.
 % \GetFileInfo{lualibs.drv}
 %
 % \title{The \identifier{lualibs} package}
-% \date{2020/12/30 v2.73}
+% \date{2021/05/20 v2.74}
 % \author{Élie Roux      · \email{elie.roux at telecom-bretagne.eu}\\
 %         Philipp Gesang · \email{phg at phi-gamma.net}\\
 %         The \LaTeX3 Project · \email{https://github.com/latex3/lualibs/}\\
@@ -429,8 +429,8 @@ lualibs = lualibs or { }
 
 lualibs.module_info = {
   name          = "lualibs",
-  version       = "2.73",       --TAGVERSION
-    date        = "2020-12-30", --TAGDATE
+  version       = "2.74",       --TAGVERSION
+    date        = "2021-05-20", --TAGDATE
   description   = "ConTeXt Lua standard libraries.",
   author        = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang",
   copyright     = "PRAGMA ADE / ConTeXt Development Team",
@@ -583,8 +583,8 @@ local loadmodule        = lualibs.loadmodule
 
 local lualibs_basic_module = {
   name          = "lualibs-basic",
-  version       = "2.73",       --TAGVERSION
-  date          = "2020-12-30", --TAGDATE
+  version       = "2.74",       --TAGVERSION
+  date          = "2021-05-20", --TAGDATE
   description   = "ConTeXt Lua libraries -- basic collection.",
   author        = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang",
   copyright     = "PRAGMA ADE / ConTeXt Development Team",
@@ -665,8 +665,8 @@ lualibs = lualibs or { }
 
 local lualibs_extended_module = {
   name          = "lualibs-extended",
-  version       = "2.73",       --TAGVERSION
-  date          = "2020-12-30", --TAGDATE
+  version       = "2.74",       --TAGVERSION
+  date          = "2021-05-20", --TAGDATE
   description   = "ConTeXt Lua libraries -- extended collection.",
   author        = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang",
   copyright     = "PRAGMA ADE / ConTeXt Development Team",





More information about the latex3-commits mailing list.