mp.patch.lua /size: 1555 b    last modification: 2024-01-16 10:22
1local gsub = string.gsub
2
3return {
4
5    action = function(data,report)
6
7        if true then
8            -- we have no patches
9            return data
10        end
11
12        if not report then
13            report = print -- let it look bad
14        end
15
16        local n, m = 0, 0
17
18        statistics.starttiming()
19
20        local function okay(i,str)
21            n = n + 1
22            report("patch %02i ok  : %s",i,str)
23        end
24
25        -- not used
26
27     -- data = gsub(data,"(#include <zlib%.h>)",function(s)
28     --     okay(1,"zlib header file commented")
29     --     return "/* " .. s .. "*/"
30     -- end,1)
31     --
32     -- data = gsub(data,"(#include <png%.h>)",function(s)
33     --     okay(2,"png header file commented")
34     --     return "/* " .. s .. "*/"
35     -- end,1)
36
37        -- patched
38
39     -- data = gsub(data,"calloc%((%w+),%s*(%w+)%)",function(n,m)
40     --     okay(3,"calloc replaced by malloc")
41     --     return "malloc(" .. n .. "*" .. m .. ")"
42     -- end,1)
43
44        -- not used
45
46     -- data = gsub(data,"(mp_show_library_versions%s*%(%s*%w+%s*%)%s*)%b{}",function(s)
47     --     okay(4,"reporting library versions removed")
48     --     return s .. "\n{\n}"
49     -- end,1)
50
51     -- data = gsub(data,"#if INTEGER_MAX == LONG_MAX",function(s)
52     --     okay(5,"fix INTEGER_TYPE")
53     --     return "#if INTEGER_TYPE == long"
54     -- end,1)
55
56        -- done
57
58        statistics.stoptiming()
59
60        report("patching time: %s", statistics.elapsedtime())
61        report("patches left : %i", m - n)
62
63        return data
64    end
65
66}
67