diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2015-06-13 00:40:45 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2015-06-13 00:40:45 +0200 |
commit | 90f398e1c9d2896b2d30d0b66f9c8a88255511a8 (patch) | |
tree | 88459ad0c6986a6648c969726081248cd5c8d74e /src/fontloader/misc/fontloader-util-str.lua | |
parent | c4c4901173b0f4284534db1b6a3cfe865b05e15c (diff) | |
parent | b271e253b40cd0af97f6d50f0461f87ad1ed5314 (diff) | |
download | luaotfload-90f398e1c9d2896b2d30d0b66f9c8a88255511a8.tar.gz |
Merge pull request #274 from phi-gamma/master
pull in current state of affairs
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..c2139b1 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 or "\r") + 1)^0) + +function string.replacenewlines(str) + return lpegmatch(pattern,str) +end |