aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/FindLuaJit.cmake3
-rw-r--r--runtime/doc/eval.txt5
-rwxr-xr-xscripts/gendeclarations.lua16
-rw-r--r--src/nvim/CMakeLists.txt15
-rw-r--r--src/nvim/eval.c17
-rw-r--r--src/nvim/ex_cmds.c9
-rw-r--r--test/functional/shell/viml_system_spec.lua22
-rw-r--r--third-party/CMakeLists.txt6
8 files changed, 64 insertions, 29 deletions
diff --git a/cmake/FindLuaJit.cmake b/cmake/FindLuaJit.cmake
index a72fb175b4..e5fdc764f1 100644
--- a/cmake/FindLuaJit.cmake
+++ b/cmake/FindLuaJit.cmake
@@ -25,7 +25,8 @@ find_path(LUAJIT_INCLUDE_DIR luajit.h
PATH_SUFFIXES luajit-2.0
${LIMIT_SEARCH})
-# If we're asked to use static linkage, add libuv.a as a preferred library name.
+# If we're asked to use static linkage, add libluajit-5.1.a as a preferred
+# library name.
if(LUAJIT_USE_STATIC)
list(APPEND LUAJIT_NAMES
"${CMAKE_STATIC_LIBRARY_PREFIX}luajit-5.1${CMAKE_STATIC_LIBRARY_SUFFIX}")
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 91a9f1292f..0778cf6122 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -6188,11 +6188,12 @@ system({expr} [, {input}]) *system()* *E677*
Use |:checktime| to force a check.
-systemlist({expr} [, {input}]) *systemlist()*
+systemlist({expr} [, {input} [, {keepempty}]]) *systemlist()*
Same as |system()|, but returns a |List| with lines (parts of
output separated by NL) with NULs transformed into NLs. Output
is the same as |readfile()| will output with {binary} argument
- set to "b".
+ set to "b", except that a final newline is not preserved,
+ unless {keepempty} is present and it's non-zero.
Returns an empty string on error, so be careful not to run
into |E706|.
diff --git a/scripts/gendeclarations.lua b/scripts/gendeclarations.lua
index bc55b48a0a..9398bbb31c 100755
--- a/scripts/gendeclarations.lua
+++ b/scripts/gendeclarations.lua
@@ -3,9 +3,8 @@
local fname = arg[1]
local static_fname = arg[2]
local non_static_fname = arg[3]
-local cpp = arg[4]
+local preproc_fname = arg[4]
-cpp = cpp:gsub(' %-DINCLUDE_GENERATED_DECLARATIONS ', ' ')
local lpeg = require('lpeg')
@@ -156,15 +155,14 @@ local pattern = concat(
if fname == '--help' then
print'Usage:'
print()
- print' gendeclarations.lua definitions.c static.h non-static.h "cc -E …"'
+ print' gendeclarations.lua definitions.c static.h non-static.h preprocessor.i'
os.exit()
end
-local pipe = io.popen(cpp .. ' -DDO_NOT_DEFINE_EMPTY_ATTRIBUTES ' .. fname, 'r')
-local text = pipe:read('*a')
-if not pipe:close() then
- os.exit(2)
-end
+local preproc_f = io.open(preproc_fname)
+local text = preproc_f:read("*all")
+preproc_f:close()
+
local header = [[
#ifndef DEFINE_FUNC_ATTRIBUTES
@@ -181,7 +179,7 @@ local footer = [[
local non_static = header
local static = header
-local filepattern = '^# %d+ "[^"]-/?([^"/]+)"'
+local filepattern = '^#%a* %d+ "[^"]-/?([^"/]+)"'
local curfile
init = 0
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index f84594f969..27d9f1b9c3 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -100,13 +100,15 @@ set_source_files_properties(
${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-conversion")
get_directory_property(gen_cdefs COMPILE_DEFINITIONS)
-foreach(gen_cdef ${gen_cdefs})
- set(gen_cflags "${gen_cflags} -D${gen_cdef}")
+foreach(gen_cdef ${gen_cdefs} DO_NOT_DEFINE_EMPTY_ATTRIBUTES)
+ if(NOT "${gen_cdef}" MATCHES "INCLUDE_GENERATED_DECLARATIONS")
+ list(APPEND gen_cflags "-D${gen_cdef}")
+ endif()
endforeach()
get_directory_property(gen_includes INCLUDE_DIRECTORIES)
foreach(gen_include ${gen_includes})
- set(gen_cflags "${gen_cflags} -I${gen_include}")
+ list(APPEND gen_cflags "-I${gen_include}")
endforeach()
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
set(gen_cflags "${gen_cflags} ${CMAKE_C_FLAGS_${build_type}} ${CMAKE_C_FLAGS}")
@@ -127,11 +129,12 @@ foreach(sfile ${NEOVIM_SOURCES}
endif()
set(gf1 "${GENERATED_DIR}/${r}.c.generated.h")
set(gf2 "${GENERATED_INCLUDES_DIR}/${r}.h.generated.h")
+ set(gf3 "${GENERATED_DIR}/${r}.i")
+ separate_arguments(C_FLAGS_ARRAY UNIX_COMMAND ${CMAKE_C_FLAGS})
add_custom_command(
OUTPUT "${gf1}" "${gf2}"
- COMMAND "${LUA_PRG}" "${HEADER_GENERATOR}"
- "${sfile}" "${gf1}" "${gf2}"
- "${CMAKE_C_COMPILER} ${gen_cflags} -E"
+ COMMAND ${CMAKE_C_COMPILER} ${sfile} -o ${gf3} ${gen_cflags} -E ${C_FLAGS_ARRAY}
+ COMMAND "${LUA_PRG}" "${HEADER_GENERATOR}" "${sfile}" "${gf1}" "${gf2}" "${gf3}"
DEPENDS "${HEADER_GENERATOR}" "${sfile}"
)
list(APPEND NEOVIM_GENERATED_SOURCES "${gf1}")
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 8be25bc34e..be69bdbe61 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -6593,7 +6593,7 @@ static struct fst {
{"synconcealed", 2, 2, f_synconcealed},
{"synstack", 2, 2, f_synstack},
{"system", 1, 2, f_system},
- {"systemlist", 1, 2, f_systemlist},
+ {"systemlist", 1, 3, f_systemlist},
{"tabpagebuflist", 0, 1, f_tabpagebuflist},
{"tabpagenr", 0, 1, f_tabpagenr},
{"tabpagewinnr", 1, 2, f_tabpagewinnr},
@@ -14523,7 +14523,7 @@ static void f_synstack(typval_T *argvars, typval_T *rettv)
}
}
-static list_T* string_to_list(char_u *str, size_t len)
+static list_T* string_to_list(char_u *str, size_t len, bool keepempty)
{
list_T *list = list_alloc();
@@ -14543,6 +14543,11 @@ static list_T* string_to_list(char_u *str, size_t len)
list_append(list, li);
}
+ // Optionally retain final newline, if present
+ if (keepempty && str[len-1] == NL) {
+ list_append_string(list, (char_u*)"", 0);
+ }
+
return list;
}
@@ -14585,7 +14590,11 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
}
if (retlist) {
- rettv->vval.v_list = string_to_list((char_u *) res, nread);
+ int keepempty = 0;
+ if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) {
+ keepempty = get_tv_number(&argvars[2]);
+ }
+ rettv->vval.v_list = string_to_list((char_u *) res, nread, keepempty != 0);
rettv->vval.v_list->lv_refcount++;
rettv->v_type = VAR_LIST;
@@ -19723,7 +19732,7 @@ static void apply_job_autocmds(int id, char *name, char *type,
str_slot->li_tv.v_type = VAR_LIST;
str_slot->li_tv.v_lock = 0;
str_slot->li_tv.vval.v_list =
- string_to_list((char_u *) received, received_len);
+ string_to_list((char_u *) received, received_len, false);
str_slot->li_tv.vval.v_list->lv_refcount++;
list_append(list, str_slot);
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 7c6e046133..44caa67847 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3606,12 +3606,13 @@ void do_sub(exarg_T *eap)
linenr_T joined_lines_count = eap->line2 < curbuf->b_ml.ml_line_count
? eap->line2 - eap->line1 + 2
: eap->line2 - eap->line1 + 1;
- if (joined_lines_count >= 2) {
+ if (joined_lines_count > 1) {
do_join(joined_lines_count, FALSE, TRUE, FALSE, true);
+ sub_nsubs = joined_lines_count - 1;
+ sub_nlines = 1;
+ do_sub_msg(false);
+ ex_may_print(eap);
}
- sub_nlines = sub_nsubs = joined_lines_count - 1;
- do_sub_msg(false);
- ex_may_print(eap);
return;
}
diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/shell/viml_system_spec.lua
index 8d212c1375..48dc518d7b 100644
--- a/test/functional/shell/viml_system_spec.lua
+++ b/test/functional/shell/viml_system_spec.lua
@@ -188,6 +188,28 @@ describe('systemlist()', function()
end)
end)
+ describe('handles empty lines', function()
+ it('in the middle', function()
+ eq({'line one','','line two'}, eval("systemlist('cat',['line one','','line two'])"))
+ end)
+
+ it('in the beginning', function()
+ eq({'','line one','line two'}, eval("systemlist('cat',['','line one','line two'])"))
+ end)
+ end)
+
+ describe('when keepempty option is', function()
+ it('0, ignores trailing newline', function()
+ eq({'aa','bb'}, eval("systemlist('cat',['aa','bb'],0)"))
+ eq({'aa','bb'}, eval("systemlist('cat',['aa','bb',''],0)"))
+ end)
+
+ it('1, preserves trailing newline', function()
+ eq({'aa','bb'}, eval("systemlist('cat',['aa','bb'],1)"))
+ eq({'aa','bb',''}, eval("systemlist('cat',['aa','bb',''],2)"))
+ end)
+ end)
+
if xclip then
describe("with a program that doesn't close stdout", function()
it('will exit properly after passing input', function()
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index 03fc720843..7d86382d34 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -54,9 +54,9 @@ endif()
include(ExternalProject)
-set(LIBUV_URL https://github.com/libuv/libuv/archive/v0.11.28.tar.gz)
-set(LIBUV_SHA1 3b70b65467ee693228b8b8385665a52690d74092)
-set(LIBUV_MD5 1a849ba4fc571d531482ed74bc7aabc4)
+set(LIBUV_URL https://github.com/libuv/libuv/archive/v1.0.1.tar.gz)
+set(LIBUV_SHA1 be4edcca18a518153b5e249a17621f2674d7654d)
+set(LIBUV_MD5 c5e4bbf954b8438c57d9414ee54b4d90)
set(MSGPACK_URL https://github.com/msgpack/msgpack-c/archive/ecf4b09acd29746829b6a02939db91dfdec635b4.tar.gz)
set(MSGPACK_SHA1 c160ff99f20d9d0a25bea0a57f4452f1c9bde370)