diff options
author | Karl Berry <karl@freefriends.org> | 2018-09-26 20:49:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-09-26 20:49:48 +0000 |
commit | 3a0140d05a7e481750ec23a30ed5cf3cdef61eb7 (patch) | |
tree | 8fac1dc16795d22db3b45205fa55db220a9beed4 /Master/texmf-dist/tex/luatex/lualibs/lualibs-string.lua | |
parent | b573c63f79c24b5c8dff312e023c2745b49f6089 (diff) |
lualibs (26sep18)
git-svn-id: svn://tug.org/texlive/trunk@48770 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/lualibs/lualibs-string.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/lualibs/lualibs-string.lua | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-string.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-string.lua index be8f397aee3..8ae8d8d1d76 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-string.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/lualibs-string.lua @@ -18,7 +18,7 @@ local P, S, C, Ct, Cc, Cs = lpeg.P, lpeg.S, lpeg.C, lpeg.Ct, lpeg.Cc, lpeg.Cs -- -- function string.split(str,pattern) -- local t = { } --- if #str > 0 then +-- if str ~= "" then -- local n = 1 -- for s in gmatch(str..pattern,"(.-)"..pattern) do -- t[n] = s @@ -72,6 +72,7 @@ end local stripper = patterns.stripper local fullstripper = patterns.fullstripper local collapser = patterns.collapser +local nospacer = patterns.nospacer local longtostring = patterns.longtostring function string.strip(str) @@ -86,6 +87,10 @@ function string.collapsespaces(str) return str and lpegmatch(collapser,str) or "" end +function string.nospaces(str) + return str and lpegmatch(nospacer,str) or "" +end + function string.longtostring(str) return str and lpegmatch(longtostring,str) or "" end @@ -212,3 +217,24 @@ end string.quote = string.quoted string.unquote = string.unquoted + +-- new + +if not string.bytetable then -- used in font-cff.lua + + local limit = 5000 -- we can go to 8000 in luajit and much higher in lua if needed + + function string.bytetable(str) -- from a string + local n = #str + if n > limit then + local t = { byte(str,1,limit) } + for i=limit+1,n do + t[i] = byte(str,i) + end + return t + else + return { byte(str,1,n) } + end + end + +end |