mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 16:58:17 +00:00
ex_getln: Refactor script_get()
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.
This commit is contained in:
@@ -277,9 +277,14 @@ void executor_eval_lua(const String str, typval_T *const arg,
|
||||
void ex_lua(exarg_T *const eap)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char *const code = (char *)script_get(eap, eap->arg);
|
||||
size_t len;
|
||||
char *const code = script_get(eap, &len);
|
||||
if (eap->skip) {
|
||||
xfree(code);
|
||||
return;
|
||||
}
|
||||
typval_T tv = { .v_type = VAR_UNKNOWN };
|
||||
executor_exec_lua(cstr_as_string(code), &tv);
|
||||
executor_exec_lua((String) { .data = code, .size = len }, &tv);
|
||||
clear_tv(&tv);
|
||||
xfree(code);
|
||||
}
|
||||
|
Reference in New Issue
Block a user