From c161b7d6fe142231346cc1844e6e27c0ab7718c1 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Fri, 16 Sep 2022 15:53:42 +0200 Subject: 2022-09-16 14:41:00 --- source/luametatex/tools/mp.patch.lua | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 source/luametatex/tools/mp.patch.lua (limited to 'source/luametatex/tools/mp.patch.lua') diff --git a/source/luametatex/tools/mp.patch.lua b/source/luametatex/tools/mp.patch.lua new file mode 100644 index 000000000..116f4f0a7 --- /dev/null +++ b/source/luametatex/tools/mp.patch.lua @@ -0,0 +1,66 @@ +local gsub = string.gsub + +return { + + action = function(data,report) + + if true then + -- we have no patches + return data + end + + if not report then + report = print -- let it look bad + end + + local n, m = 0, 0 + + statistics.starttiming() + + local function okay(i,str) + n = n + 1 + report("patch %02i ok : %s",i,str) + end + + -- not used + + -- data = gsub(data,"(#include )",function(s) + -- okay(1,"zlib header file commented") + -- return "/* " .. s .. "*/" + -- end,1) + -- + -- data = gsub(data,"(#include )",function(s) + -- okay(2,"png header file commented") + -- return "/* " .. s .. "*/" + -- end,1) + + -- patched + + -- data = gsub(data,"calloc%((%w+),%s*(%w+)%)",function(n,m) + -- okay(3,"calloc replaced by malloc") + -- return "malloc(" .. n .. "*" .. m .. ")" + -- end,1) + + -- not used + + -- data = gsub(data,"(mp_show_library_versions%s*%(%s*%w+%s*%)%s*)%b{}",function(s) + -- okay(4,"reporting library versions removed") + -- return s .. "\n{\n}" + -- end,1) + + -- data = gsub(data,"#if INTEGER_MAX == LONG_MAX",function(s) + -- okay(5,"fix INTEGER_TYPE") + -- return "#if INTEGER_TYPE == long" + -- end,1) + + -- done + + statistics.stoptiming() + + report("patching time: %s", statistics.elapsedtime()) + report("patches left : %i", m - n) + + return data + end + +} -- cgit v1.2.3