aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds2.c
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-01-29 03:36:47 +0300
committerZyX <kp-pav@yandex.ru>2017-03-27 00:12:42 +0300
commit3d48c35d6bfa83ba3ae621fa9ec3f512da199f59 (patch)
treedf801c433c2be1eb94aafefce914e24113b888fa /src/nvim/ex_cmds2.c
parent3531d8c8eaa6783637f510dbc5dbd58c9d435b61 (diff)
downloadrneovim-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/ex_cmds2.c')
-rw-r--r--src/nvim/ex_cmds2.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 9fc4ef2a02..092bb38dd0 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -3695,19 +3695,18 @@ char_u *get_locales(expand_T *xp, int idx)
static void script_host_execute(char *name, exarg_T *eap)
{
- uint8_t *script = script_get(eap, eap->arg);
+ size_t len;
+ char *const script = script_get(eap, &len);
- if (!eap->skip) {
- list_T *args = list_alloc();
+ if (script != NULL) {
+ list_T *const args = list_alloc();
// script
- list_append_string(args, script ? script : eap->arg, -1);
+ list_append_allocated_string(args, script);
// current range
list_append_number(args, (int)eap->line1);
list_append_number(args, (int)eap->line2);
(void)eval_call_provider(name, "execute", args);
}
-
- xfree(script);
}
static void script_host_execute_file(char *name, exarg_T *eap)