From 54d357dce0e13408b819a1fe98b6417fad2cdd4c Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 4 Sep 2023 22:42:47 +0200 Subject: [PATCH] build: bump lpeg to 1.1.0 (#25016) Release notes indicates it has better UTF8 handling which is relevant for us. --- cmake.deps/deps.txt | 4 ++-- runtime/lua/vim/re.lua | 34 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cmake.deps/deps.txt b/cmake.deps/deps.txt index 7cb1e2c881..4ea8887e2d 100644 --- a/cmake.deps/deps.txt +++ b/cmake.deps/deps.txt @@ -22,8 +22,8 @@ LIBVTERM_SHA256 09156f43dd2128bd347cbeebe50d9a571d32c64e0cf18d211197946aff7226e0 LUV_URL https://github.com/luvit/luv/archive/dcd1a1cad5b05634a7691402d6ca2f214fb4ae76.tar.gz LUV_SHA256 b68c73ed233918da7e0b34b57c6bac0490e6c6f1b12c1051266b6ad9efa780d0 -LPEG_URL https://github.com/neovim/deps/raw/aa004f1b2b6470a92363cba8e1cc1874141dacc4/opt/lpeg-1.0.2.tar.gz -LPEG_SHA256 48d66576051b6c78388faad09b70493093264588fcd0f258ddaab1cdd4a15ffe +LPEG_URL https://github.com/neovim/deps/raw/d495ee6f79e7962a53ad79670cb92488abe0b9b4/opt/lpeg-1.1.0.tar.gz +LPEG_SHA256 4b155d67d2246c1ffa7ad7bc466c1ea899bbc40fef0257cc9c03cecbaed4352a LUA_COMPAT53_URL https://github.com/keplerproject/lua-compat-5.3/archive/v0.9.tar.gz LUA_COMPAT53_SHA256 ad05540d2d96a48725bb79a1def35cf6652a4e2ec26376e2617c8ce2baa6f416 diff --git a/runtime/lua/vim/re.lua b/runtime/lua/vim/re.lua index dffe37186a..007eb27ed8 100644 --- a/runtime/lua/vim/re.lua +++ b/runtime/lua/vim/re.lua @@ -1,6 +1,8 @@ --- $Id: re.lua $ --- vendored from lpeg-1.0.2 --- Copyright © 2007-2019 Lua.org, PUC-Rio. +-- +-- Copyright 2007-2023, Lua.org & PUC-Rio (see 'lpeg.html' for license) +-- written by Roberto Ierusalimschy +-- +--- vendored from lpeg-1.1.0 -- imported functions and modules local tonumber, type, print, error = tonumber, type, print, error @@ -12,14 +14,14 @@ local m = require"lpeg" -- on 'mm' local mm = m --- pattern's metatable +-- patterns' metatable local mt = getmetatable(mm.P(0)) +local version = _VERSION -- No more global accesses after this point -local version = _VERSION -if version == "Lua 5.2" then _ENV = nil end +_ENV = nil -- does no harm in Lua 5.1 local any = m.P(1) @@ -144,7 +146,7 @@ local item = (defined + Range + m.C(any)) / m.P local Class = "[" * (m.C(m.P"^"^-1)) -- optional complement symbol - * m.Cf(item * (item - "]")^0, mt.__add) / + * (item * ((item % mt.__add) - "]")^0) / function (c, p) return c == "^" and any - p or p end * "]" @@ -170,13 +172,13 @@ end local exp = m.P{ "Exp", Exp = S * ( m.V"Grammar" - + m.Cf(m.V"Seq" * ("/" * S * m.V"Seq")^0, mt.__add) ); - Seq = m.Cf(m.Cc(m.P"") * m.V"Prefix"^0 , mt.__mul) + + m.V"Seq" * ("/" * S * m.V"Seq" % mt.__add)^0 ); + Seq = (m.Cc(m.P"") * (m.V"Prefix" % mt.__mul)^0) * (#seq_follow + patt_error); Prefix = "&" * S * m.V"Prefix" / mt.__len + "!" * S * m.V"Prefix" / mt.__unm + m.V"Suffix"; - Suffix = m.Cf(m.V"Primary" * S * + Suffix = m.V"Primary" * S * ( ( m.P"+" * m.Cc(1, mt.__pow) + m.P"*" * m.Cc(0, mt.__pow) + m.P"?" * m.Cc(-1, mt.__pow) @@ -187,10 +189,11 @@ local exp = m.P{ "Exp", + m.P"{}" * m.Cc(nil, m.Ct) + defwithfunc(mt.__div) ) - + "=>" * S * defwithfunc(m.Cmt) - + "~>" * S * defwithfunc(m.Cf) - ) * S - )^0, function (a,b,f) return f(a,b) end ); + + "=>" * S * defwithfunc(mm.Cmt) + + ">>" * S * defwithfunc(mt.__mod) + + "~>" * S * defwithfunc(mm.Cf) + ) % function (a,b,f) return f(a,b) end * S + )^0; Primary = "(" * m.V"Exp" * ")" + String / mm.P + Class @@ -206,8 +209,7 @@ local exp = m.P{ "Exp", + (name * -arrow + "<" * name * ">") * m.Cb("G") / NT; Definition = name * arrow * m.V"Exp"; Grammar = m.Cg(m.Cc(true), "G") * - m.Cf(m.V"Definition" / firstdef * m.Cg(m.V"Definition")^0, - adddef) / mm.P + ((m.V"Definition" / firstdef) * (m.V"Definition" % adddef)^0) / mm.P } local pattern = S * m.Cg(m.Cc(false), "G") * exp / mm.P * (-any + patt_error)