aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt58
-rw-r--r--src/eval.c2
-rw-r--r--src/ex_cmds.c4
3 files changed, 51 insertions, 13 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 359a9f5180..fecfea8cdf 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,8 +12,25 @@ list(APPEND NEOVIM_SOURCES "${PROJECT_BINARY_DIR}/config/auto/pathdef.c")
file( GLOB OS_SOURCES os/*.c )
-add_executable (nvim ${NEOVIM_SOURCES} ${OS_SOURCES})
-add_library (nvim-test MODULE ${NEOVIM_SOURCES} ${OS_SOURCES})
+if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ if(DEFINED ENV{SANITIZE})
+ message(STATUS "Enabling the sanitizers")
+ add_definitions(-DEXITFREE) # is this necessary for LeakSanitizer?
+ add_definitions(-fno-sanitize-recover -fno-omit-frame-pointer
+ -fno-optimize-sibling-calls -fsanitize=address -fsanitize=undefined)
+ set(CMAKE_EXE_LINKER_FLAGS
+ "-fsanitize=address -fsanitize=undefined ${CMAKE_EXE_LINKER_FLAGS}")
+ set(CMAKE_SHARED_LINKER_FLAGS
+ "-fsanitize=address -fsanitize=undefined ${CMAKE_SHARED_LINKER_FLAGS}")
+ endif()
+endif()
+
+if(NOT DEFINED ENV{SKIP_EXEC})
+ add_executable (nvim ${NEOVIM_SOURCES} ${OS_SOURCES})
+endif()
+if(NOT DEFINED ENV{SKIP_UNITTEST})
+ add_library (nvim-test MODULE ${NEOVIM_SOURCES} ${OS_SOURCES})
+endif()
# The libraries we link against for nvim
set(NVIM_LINK_LIBRARIES m ${LibUV_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
@@ -28,27 +45,46 @@ if (LibIntl_FOUND)
list(APPEND NVIM_LINK_LIBRARIES ${LibIntl_LIBRARY})
endif()
-target_link_libraries (nvim ${NVIM_LINK_LIBRARIES})
-target_link_libraries (nvim-test ${NVIM_LINK_LIBRARIES})
+if(NOT DEFINED ENV{SKIP_EXEC})
+ target_link_libraries (nvim ${NVIM_LINK_LIBRARIES})
+endif()
+if(NOT DEFINED ENV{SKIP_UNITTEST})
+ target_link_libraries (nvim-test ${NVIM_LINK_LIBRARIES})
+endif()
include(CheckLibraryExists)
check_library_exists(termcap tgetent "" HAVE_LIBTERMCAP)
if (HAVE_LIBTERMCAP)
- target_link_libraries(nvim termcap)
- target_link_libraries(nvim-test termcap)
+
+ if(NOT DEFINED ENV{SKIP_EXEC})
+ target_link_libraries(nvim termcap)
+ endif()
+ if(NOT DEFINED ENV{SKIP_UNITTEST})
+ target_link_libraries(nvim-test termcap)
+ endif()
else()
check_library_exists(curses tgetent "" HAVE_LIBCURSES)
if (HAVE_LIBCURSES)
- target_link_libraries(nvim curses)
- target_link_libraries(nvim-test curses)
+ if(NOT DEFINED ENV{SKIP_EXEC})
+ target_link_libraries(nvim curses)
+ endif()
+ if(NOT DEFINED ENV{SKIP_UNITTEST})
+ target_link_libraries(nvim-test curses)
+ endif()
else()
find_package(Curses REQUIRED)
- target_link_libraries(nvim ${CURSES_LIBRARIES})
- target_link_libraries(nvim-test ${CURSES_LIBRARIES})
+ if(NOT DEFINED ENV{SKIP_EXEC})
+ target_link_libraries(nvim ${CURSES_LIBRARIES})
+ endif()
+ if(DEFINED ENV{SKIP_UNITTEST})
+ target_link_libraries(nvim-test ${CURSES_LIBRARIES})
+ endif()
endif()
endif()
include_directories ("${PROJECT_SOURCE_DIR}/src/proto")
-install(TARGETS nvim RUNTIME DESTINATION bin)
+if(NOT DEFINED ENV{SKIP_EXEC})
+ install(TARGETS nvim RUNTIME DESTINATION bin)
+endif()
diff --git a/src/eval.c b/src/eval.c
index b164912c1c..d5ed1b1e04 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -4275,7 +4275,7 @@ eval6 (
else if (op == '/') {
/* We rely on the floating point library to handle divide
* by zero to result in "inf" and not a crash. */
- f1 = f1 / f2;
+ f1 = f2 != 0 ? f1 / f2 : INFINITY;
} else {
EMSG(_("E804: Cannot use '%' with Float"));
return FAIL;
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 68b5727786..c4da8d65e7 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2834,8 +2834,10 @@ do_ecmd (
* <VN> We could instead free the synblock
* and re-attach to buffer, perhaps.
*/
- if (curwin->w_s == &(curwin->w_buffer->b_s))
+ if (curwin->w_buffer != NULL &&
+ curwin->w_s == &(curwin->w_buffer->b_s))
curwin->w_s = &(buf->b_s);
+
curwin->w_buffer = buf;
curbuf = buf;
++curbuf->b_nwindows;