diff options
author | ZyX <kp-pav@yandex.ru> | 2017-01-29 23:22:50 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-03-27 00:13:16 +0300 |
commit | 9fd2bf67aa1db66e3465753d5aaaec342f4ce193 (patch) | |
tree | c07db015f38c00b6ab3bf8c4b76a86910f46ad09 /src/nvim/viml/executor/executor.c | |
parent | ebad04622056b0cb88e2b25211746b57fb4ef3c2 (diff) | |
download | rneovim-9fd2bf67aa1db66e3465753d5aaaec342f4ce193.tar.gz rneovim-9fd2bf67aa1db66e3465753d5aaaec342f4ce193.tar.bz2 rneovim-9fd2bf67aa1db66e3465753d5aaaec342f4ce193.zip |
executor,functests: Add print() tests, some fixes
Diffstat (limited to 'src/nvim/viml/executor/executor.c')
-rw-r--r-- | src/nvim/viml/executor/executor.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/nvim/viml/executor/executor.c b/src/nvim/viml/executor/executor.c index 48149c4420..4eb63f38ad 100644 --- a/src/nvim/viml/executor/executor.c +++ b/src/nvim/viml/executor/executor.c @@ -384,9 +384,6 @@ static int nlua_print(lua_State *const lstate) lua_pushvalue(lstate, curargidx); // arg if (lua_pcall(lstate, 1, 1, 0)) { errmsg = lua_tolstring(lstate, -1, &errmsg_len); - if (!errmsg) { - PRINT_ERROR("<Unknown error: lua_tolstring returned NULL for error>"); - } goto nlua_print_error; } size_t len; @@ -408,19 +405,32 @@ static int nlua_print(lua_State *const lstate) const size_t len = (size_t)msg_ga.ga_len - 1; char *const str = (char *)msg_ga.ga_data; - for (size_t i = 0; i < len - 1;) { + for (size_t i = 0; i < len;) { const size_t start = i; - while (str[i] != NL && i < len - 1) { - if (str[i] == NUL) { - str[i] = NL; + while (i < len) { + switch (str[i]) { + case NUL: { + str[i] = NL; + i++; + continue; + } + case NL: { + str[i] = NUL; + i++; + break; + } + default: { + i++; + continue; + } } - i++; - } - if (str[i] == NL) { - str[i] = NUL; + break; } msg((char_u *)str + start); } + if (str[len - 1] == NUL) { // Last was newline + msg((char_u *)""); + } } ga_clear(&msg_ga); return 0; |