Differences From
Artifact [f6f8bc0dcc]:
1 1 -- vim: ft=terra
2 2 local m={}
3 3 local pstr = lib.mem.ptr(int8)
4 4
5 -terra m.sanitize(txt: pstr, quo: bool)
5 +terra m.sanitize(pool: &lib.mem.pool, txt: pstr, quo: bool)
6 6 if txt.ptr == nil then return pstr.null() end
7 7 if txt.ct == 0 then txt.ct = lib.str.sz(txt.ptr) end
8 - var a: lib.str.acc a:init(txt.ct*1.3)
8 + var a: lib.str.acc a:pool(pool,txt.ct*1.3)
9 9 for i=0,txt.ct do
10 10 if txt(i) == @'<' then a:lpush('<')
11 11 elseif txt(i) == @'>' then a:lpush('>')
12 12 elseif txt(i) == @'&' then a:lpush('&')
13 13 elseif quo and txt(i) == @'"' then a:lpush('"')
14 14 else a:push(&txt(i),1) end
15 15 end
................................................................................
24 24
25 25 terra m.hexbyte(i: uint8): int8[2]
26 26 return arrayof(int8,
27 27 m.hexdgt(i / 0x10),
28 28 m.hexdgt(i % 0x10))
29 29 end
30 30
31 -terra m.urlenc(txt: pstr, qparam: bool)
31 +terra m.urlenc(pool: &lib.mem.pool, txt: pstr, qparam: bool)
32 32 if txt.ptr == nil then return pstr.null() end
33 33 if txt.ct == 0 then txt.ct = lib.str.sz(txt.ptr) end
34 - var a: lib.str.acc a:init(txt.ct*1.3)
34 + var a: lib.str.acc a:pool(pool,txt.ct*1.3)
35 35 for i=0,txt.ct do
36 36 if txt(i) == @' ' then a:lpush('+')
37 37 elseif txt(i) == @'&' and not qparam then a:lpush('&')
38 38 elseif (txt(i) < 0x2c or
39 39 (txt(i) > @';' and txt(i) < @'@') or
40 40 (txt(i) > @'Z' and txt(i) < @'a') or
41 41 (txt(i) >= 0x7b and txt(i) <= 0x7f)) and