core: ported regex.gsub to faster native version (#1233)

* added regex.gmatch iterator and other fixes
* fixed issues reported by Guldoman
* push strings with fixed len just in case for binary safety
* added limit to regex.gsub and use pushinteger
* added description to regex.gsub limits param
* replaced substitutions regex description for correctness
* ignore negative limits on regex.gsub
This commit is contained in:
Jefferson González
2022-12-20 17:46:37 -04:00
committed by GitHub
parent 5b5b5fd3e3
commit 3c64c32379
4 changed files with 301 additions and 66 deletions
+1 -1
View File
@@ -216,7 +216,7 @@ command.add("core.docview!", {
return text:gsub(old:gsub("%W", "%%%1"), new:gsub("%%", "%%%%"), nil)
end
local result, matches = regex.gsub(regex.compile(old, "m"), text, new)
return result, #matches
return result, matches
end)
end,