59
60
61
62
63
64
65
66
67
68
69
70
71
72
...
559
560
561
562
563
564
565
566
567
|
var sz = lib.math.biggest(self.ct, other.ct)
for i = 0, sz do
if self.ptr[i] == 0 and other.ptr[i] == 0 then return true end
if self.ptr[i] ~= other.ptr[i] then return false end
end
return true
end
terra ty:ffw()
var newp = m.ffw(self.ptr,self.ct)
var newct = self.ct - (newp - self.ptr)
return ty { ptr = newp, ct = newct }
end
terra ty:blob()
................................................................................
var cur = str while cur.ct > 0 do
var add, cont = disemvowel_codepoint(cur)
if add:ref() then acc:ppush(add) end
cur = cont
end
return acc:finalize()
end
return m
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
...
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
|
var sz = lib.math.biggest(self.ct, other.ct)
for i = 0, sz do
if self.ptr[i] == 0 and other.ptr[i] == 0 then return true end
if self.ptr[i] ~= other.ptr[i] then return false end
end
return true
end
terra ty:startswith(other: ty)
for i=0, other.ct do
if other(i) == 0 then return true end
if other(i) ~= self(i) then return false end
end
return true
end
terra ty:ffw()
var newp = m.ffw(self.ptr,self.ct)
var newct = self.ct - (newp - self.ptr)
return ty { ptr = newp, ct = newct }
end
terra ty:blob()
................................................................................
var cur = str while cur.ct > 0 do
var add, cont = disemvowel_codepoint(cur)
if add:ref() then acc:ppush(add) end
cur = cont
end
return acc:finalize()
end
terra m.qesc(pool: &lib.mem.pool, str: m.t): m.t
-- escape double-quotes
var a: m.acc a:pool(pool, str.ct + str.ct/2)
a:lpush '"'
for i=0, str.ct do
if str(i) == @'"' then a:lpush '\\"'
elseif str(i) == @'\\' then a:lpush '\\\\'
elseif str(i) < 0x20 then -- for json
var hex = lib.math.hexbyte(str(i))
a:lpush('\\u00'):push(&hex[0], 2)
else a:push(str.ptr + i,1) end
end
a:lpush '"'
return a:finalize()
end
return m
|