Fixes:
1. Allocate space for the NUL byte.
2. Do not exclude last line from range.
3. Remove code for sandbox: it is handled earlier.
4. Fix index in new_line_transformed when converting NULs to NLs.
5. Always allocate new_line_transformed, but save allocated value.
1. Use `char *` for strings.
2. Add `const` qualifiers.
3. Add attributes and documentation.
4. Handle skipping *inside*.
5. Handle non-heredoc argument also inside: deferring this to the caller is
pointless because all callers need the same thing. Though new ex_lua caller
may live without allocations in this case, allocating nevertheless produces
cleaner code.
6. Note that all callers call script_get with `eap` and `eap->arg`. Thus second
argument is useless in practice: it is one and the same always and can be
reached through the first argument.
Fixes problem introduced by “api: Allow kObjectTypeNil to be zero without
breaking compatibility”: apparently there are clients which use metadata and
there are which aren’t. For the first that commit would not be needed, for the
second that commit misses this critical piece.
Now it checks functions also after every semicolon and closing figure brace,
possibly preceded by whitespaces (tabs and spaces). This should make messing
with declarations in macros not needed.
Reasoning: luajit is not being compiled with sanitizers, lua is. Given that
linking with sanitized libraries requires sanitizers enabled, it is needed to
either compile libnvim-test with sanitizers or link it with lua compiled without
sanitizers. Most easy way to do the latter is just use luajit which is compiled
without sanitizers (as they do not work well with luajit).
Function declarations generator is able to handle properly only the *first*
function definition that is in macros, and only if it is the first entity in the
macros. So msgpack_rpc_from_* was already really a static function, additionally
its attributes were useless. This commit switches to explicit declarations and
makes generated functions static.
Reasoning; currently INTERNAL_CALL is mostly used to determine whether it is
needed to deal with NL-used-as-NUL problem. This code is useful for nvim_… API
calls done from VimL, but not for API calls done from lua, yet lua needs to
supply something as channel_id.
During testing found the following bugs:
1. msgpack-gen.lua script is completely unprepared for Float values either in
return type or in arguments. Specifically:
1. At the time of writing relevant code FLOAT_OBJ did not exist as well as
FLOATING_OBJ, but it would be used by msgpack-gen.lua should return type
be Float. I added FLOATING_OBJ macros later because did not know that
msgpack-gen.lua uses these _OBJ macros, otherwise it would be FLOAT_OBJ.
2. msgpack-gen.lua should use .data.floating in place of .data.float. But it
did not expect that .data subattribute may have name different from
lowercased type name.
2. vim_replace_termcodes returned its argument as-is if it receives an empty
string (as well as _vim_id*() functions did). But if something in returned
argument lives in an allocated memory such action will cause double free:
once when freeing arguments, then when freeing return value. It did not cause
problems yet because msgpack bindings return empty string as {NULL, 0} and
nothing was actually allocated.
3. New code in msgpack-gen.lua popped arguments in reversed order, making lua
bindings’ signatures be different from API ones.
No tests yet, no documentation update, no :lua* stuff, no vim module.
converter.c should also work with typval_T, not Object.
Known problem: luaeval("1", {}) results in
PANIC: unprotected error in call to Lua API (attempt to index a nil value)
Ref #3823
The comment is incorrect, s:error does need to be called. I thought the
call was unnecessary because it didn't show any message for me but I had
shortmess+=F which was hiding the message.