From 3d48c35d6bfa83ba3ae621fa9ec3f512da199f59 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 29 Jan 2017 03:36:47 +0300 Subject: 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. --- src/nvim/ex_docmd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index aa43b71a0d..74bb6177c6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3734,10 +3734,12 @@ void ex_ni(exarg_T *eap) /// Skips over ":perl <skip) + if (!eap->skip) { ex_ni(eap); - else - xfree(script_get(eap, eap->arg)); + } else { + size_t len; + xfree(script_get(eap, &len)); + } } /* -- cgit