summaryrefslogtreecommitdiff
path: root/source/luametatex/tools/mp.patch.lua
blob: 116f4f0a75b4e213b1fd5218011b6212bd8d4470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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 <zlib%.h>)",function(s)
     --     okay(1,"zlib header file commented")
     --     return "/* " .. s .. "*/"
     -- end,1)
     --
     -- data = gsub(data,"(#include <png%.h>)",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

}