diff options
author | ZyX <kp-pav@yandex.ru> | 2017-01-29 03:36:47 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-03-27 00:12:42 +0300 |
commit | 3d48c35d6bfa83ba3ae621fa9ec3f512da199f59 (patch) | |
tree | df801c433c2be1eb94aafefce914e24113b888fa /src/nvim/viml/executor/executor.c | |
parent | 3531d8c8eaa6783637f510dbc5dbd58c9d435b61 (diff) | |
download | rneovim-3d48c35d6bfa83ba3ae621fa9ec3f512da199f59.tar.gz rneovim-3d48c35d6bfa83ba3ae621fa9ec3f512da199f59.tar.bz2 rneovim-3d48c35d6bfa83ba3ae621fa9ec3f512da199f59.zip |
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.
Diffstat (limited to 'src/nvim/viml/executor/executor.c')
-rw-r--r-- | src/nvim/viml/executor/executor.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nvim/viml/executor/executor.c b/src/nvim/viml/executor/executor.c index 38e3cf1c6d..fb39716f5c 100644 --- a/src/nvim/viml/executor/executor.c +++ b/src/nvim/viml/executor/executor.c @@ -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); } |