mirror of
https://github.com/bol-van/zapret2.git
synced 2026-03-14 06:13:09 +00:00
zapret-lib: remove bitable, use barray
This commit is contained in:
@@ -2256,12 +2256,10 @@ function blob_or_def(desync, name, def)
|
||||
```
|
||||
function barray(a, packer)
|
||||
function btable(a, packer)
|
||||
function bitable(a, packer)
|
||||
```
|
||||
|
||||
- `barray` uses only numeric indices starting from 1. The order is preserved.
|
||||
- `btable` uses all indices but does not guarantee order.
|
||||
- `bitable` uses onlt numeric indices and guarantees order.
|
||||
|
||||
Packs elements of array `a` in ascending order of index from 1 to the last.
|
||||
`packer` is a function that takes an element of `a` and returns a raw string.
|
||||
|
||||
@@ -2421,12 +2421,10 @@ function blob_or_def(desync, name, def)
|
||||
```
|
||||
function barray(a, packer)
|
||||
function btable(a, packer)
|
||||
function bitable(a, packer)
|
||||
```
|
||||
|
||||
- barray использует только числовые индексы, начиная с 1. порядок соблюдается
|
||||
- btable использует все индексы, но не гарантирует порядок
|
||||
- bitable использует только числовые индексы от 1 и гарантирует порядок
|
||||
|
||||
Упаковка элементов массива a в порядке возрастания индекса от 1 до последнего.
|
||||
`packer` - функция, берущая элемент a и возвращающая raw string.
|
||||
|
||||
@@ -330,16 +330,6 @@ function btable(a, packer)
|
||||
return s
|
||||
end
|
||||
end
|
||||
-- convert table a to packed string using 'packer' function. numeric indexes only, ordered
|
||||
function bitable(a, packer)
|
||||
if a then
|
||||
local s=""
|
||||
for k,v in ipairs(a) do
|
||||
s = s .. packer(v)
|
||||
end
|
||||
return s
|
||||
end
|
||||
end
|
||||
|
||||
-- sequence comparision functions. they work only within 2G interval
|
||||
-- seq1>=seq2
|
||||
@@ -1626,7 +1616,7 @@ function http_dissect_reply(http)
|
||||
end
|
||||
function http_reconstruct_headers(headers, unixeol)
|
||||
local eol = unixeol and "\n" or "\r\n"
|
||||
return headers and bitable(headers, function(a) return a.header..": "..a.value..eol end) or ""
|
||||
return headers and barray(headers, function(a) return a.header..": "..a.value..eol end) or ""
|
||||
end
|
||||
function http_reconstruct_req(hdis, unixeol)
|
||||
local eol = unixeol and "\n" or "\r\n"
|
||||
|
||||
@@ -913,6 +913,7 @@ static uint8_t desync(
|
||||
lua_pushf_str(params.L, "func", func->func);
|
||||
lua_pushf_int(params.L, "func_n", ctx->func_n);
|
||||
lua_pushf_str(params.L, "func_instance", instance);
|
||||
|
||||
// prevent use of desync ctx object outside of function call
|
||||
ctx->valid = true;
|
||||
status = lua_pcall(params.L, 2, LUA_MULTRET, 0);
|
||||
|
||||
Reference in New Issue
Block a user