diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2015-05-04 23:06:20 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2015-05-04 23:06:20 +0200 |
commit | fe729cc9736391f61a75ccbee5c0fc162a2c99bd (patch) | |
tree | d3a413d68ccfeff9f47c723f2f9415f7cf354d65 /src/fontloader/misc/fontloader-util-str.lua | |
parent | 136826a4dc6e9505ed1ff1cfa6c862451a4a280a (diff) | |
download | luaotfload-fe729cc9736391f61a75ccbee5c0fc162a2c99bd.tar.gz |
[fontloader] sync with Context as of 2015-05-04
Diffstat (limited to 'src/fontloader/misc/fontloader-util-str.lua')
-rw-r--r-- | src/fontloader/misc/fontloader-util-str.lua | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/fontloader/misc/fontloader-util-str.lua b/src/fontloader/misc/fontloader-util-str.lua index a677a82..de4a87e 100644 --- a/src/fontloader/misc/fontloader-util-str.lua +++ b/src/fontloader/misc/fontloader-util-str.lua @@ -44,7 +44,12 @@ end if not number then number = { } end -- temp hack for luatex-fonts -local stripper = patterns.stripzeros +local stripper = patterns.stripzeros +local newline = patterns.newline +local endofstring = patterns.endofstring +local whitespace = patterns.whitespace +local spacer = patterns.spacer +local spaceortab = patterns.spaceortab local function points(n) n = tonumber(n) @@ -62,12 +67,12 @@ number.basepoints = basepoints -- str = " \n \ntest \n test\ntest " -- print("["..string.gsub(string.collapsecrlf(str),"\n","+").."]") -local rubish = patterns.spaceortab^0 * patterns.newline -local anyrubish = patterns.spaceortab + patterns.newline +local rubish = spaceortab^0 * newline +local anyrubish = spaceortab + newline local anything = patterns.anything -local stripped = (patterns.spaceortab^1 / "") * patterns.newline +local stripped = (spaceortab^1 / "") * newline local leading = rubish^0 / "" -local trailing = (anyrubish^1 * patterns.endofstring) / "" +local trailing = (anyrubish^1 * endofstring) / "" local redundant = rubish^3 / "\n" local pattern = Cs(leading * (trailing + redundant + stripped + anything)^0) @@ -129,7 +134,7 @@ local pattern = return "" end end - + patterns.newline * Cp() / function(position) + + newline * Cp() / function(position) extra, start = 0, position end + patterns.anything @@ -162,11 +167,6 @@ end -- return str -- end -local newline = patterns.newline -local endofstring = patterns.endofstring -local whitespace = patterns.whitespace -local spacer = patterns.spacer - local space = spacer^0 local nospace = space/"" local endofline = nospace * newline @@ -1117,3 +1117,9 @@ local pattern = function string.optionalquoted(str) return lpegmatch(pattern,str) or str end + +local pattern = Cs((newline / os.newline + 1)^0) + +function string.replacenewlines(str) + return lpegmatch(pattern,str) +end |