diff options
-rw-r--r-- | CMakeLists.txt | 67 | ||||
-rw-r--r-- | cmake/FindIconv.cmake | 18 | ||||
-rw-r--r-- | cmake/GetCompileFlags.cmake | 58 | ||||
-rw-r--r-- | cmake/InstallHelpers.cmake | 18 | ||||
-rw-r--r-- | config/CMakeLists.txt | 7 | ||||
-rw-r--r-- | config/config.h.in | 3 | ||||
-rw-r--r-- | neovim.rb | 45 | ||||
-rw-r--r-- | src/nvim/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/nvim/cursor_shape.c | 2 | ||||
-rw-r--r-- | src/nvim/edit.c | 22 | ||||
-rw-r--r-- | src/nvim/ops.c | 17 | ||||
-rw-r--r-- | src/nvim/regexp.c | 30 | ||||
-rw-r--r-- | src/nvim/screen.c | 34 | ||||
-rw-r--r-- | src/nvim/version.c | 8 | ||||
-rw-r--r-- | src/nvim/version_defs.h | 12 |
15 files changed, 227 insertions, 122 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d67aebee64..223c28f348 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,37 @@ set(DEPS_BIN_DIR "${DEPS_INSTALL_DIR}/bin") list(APPEND CMAKE_PREFIX_PATH ${DEPS_INSTALL_DIR}) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + # CMake tries to treat /sw and /opt/local as extension of the system path, but + # that doesn't really work out very well. Once you have a dependency that + # resides there and have to add it as an include directory, then any other + # dependency that could be satisfied from there must be--otherwise you can end + # up with conflicting versions. So, let's make them more of a priority having + # them be included as one of the first places to look for dependencies. + list(APPEND CMAKE_PREFIX_PATH /sw /opt/local) + + # Work around some old, broken detection by CMake for knowing when to use the + # isystem flag. Apple's compilers have supported this for quite some time + # now. + if(CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ") + endif() + if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") + endif() +endif() + +# Set available build types for CMake GUIs. +# A different build type can still be set by -DCMAKE_BUILD_TYPE=... +set_property(CACHE CMAKE_BUILD_TYPE PROPERTY + STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + +# Set default build type. +if(NOT CMAKE_BUILD_TYPE) + message(STATUS "CMAKE_BUILD_TYPE not given; setting to 'RelWithDebInfo'.") + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE) +endif() + # Version tokens include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT) @@ -28,20 +59,11 @@ git_timestamp(GIT_TIMESTAMP) if(GIT_TIMESTAMP) set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}") endif() +set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}") +# NVIM_VERSION_CFLAGS set further below. set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# Work around some old, broken detection by CMake for knowing when to use the -# isystem flag. Apple's compilers have supported this for quite some time now. -if(APPLE) - if(CMAKE_COMPILER_IS_GNUCC) - set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ") - endif() - if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") - endif() -endif() - # Default to -O2 on release builds. string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") @@ -67,9 +89,16 @@ if(TRAVIS_CI_BUILD) add_definitions(-Werror) endif() +if(CMAKE_COMPILER_IS_GNUCC) + include(CheckCCompilerFlag) + check_c_compiler_flag(-Og HAS_OG_FLAG) +else() + set(HAS_OG_FLAG 0) +endif() + # Set custom build flags for RelWithDebInfo. # -DNDEBUG purposely omitted because we want assertions. -if(CMAKE_COMPILER_IS_GNUCC) +if(HAS_OG_FLAG) set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og -g" CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE) else() @@ -128,7 +157,12 @@ include_directories(SYSTEM ${LUAJIT_INCLUDE_DIRS}) find_package(LibIntl) if(LibIntl_FOUND) - include_directories(SYSTEM ${LibIntl_INCLUDE_DIR}) + include_directories(SYSTEM ${LibIntl_INCLUDE_DIRS}) +endif() + +find_package(Iconv) +if(Iconv_FOUND) + include_directories(SYSTEM ${Iconv_INCLUDE_DIRS}) endif() # Determine platform's threading library. Set CMAKE_THREAD_PREFER_PTHREAD @@ -228,9 +262,14 @@ install(SCRIPT ${CMAKE_MODULE_PATH}/GenerateHelptags.cmake) # Go down the tree. -add_subdirectory(config) add_subdirectory(src/nvim) +# Read compilation flags from src/nvim, +# used in config subdirectory below. +include(GetCompileFlags) +get_compile_flags(NVIM_VERSION_CFLAGS) + add_subdirectory(test/includes) +add_subdirectory(config) # Setup some test-related bits. We do this after going down the tree because we # need some of the targets. diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake new file mode 100644 index 0000000000..f3a54e9d6f --- /dev/null +++ b/cmake/FindIconv.cmake @@ -0,0 +1,18 @@ +# - Try to find iconv +# Once done, this will define +# +# Iconv_FOUND - system has iconv +# Iconv_INCLUDE_DIRS - the iconv include directories +# Iconv_LIBRARIES - link these to use iconv + +include(LibFindMacros) + +find_path(ICONV_INCLUDE_DIR NAMES iconv.h) +find_library(ICONV_LIBRARY NAMES iconv) + +set(Iconv_PROCESS_INCLUDES ICONV_INCLUDE_DIR) +if(ICONV_LIBRARY) + set(Iconv_PROCESS_LIBS ICONV_LIBRARY) +endif() + +libfind_process(Iconv) diff --git a/cmake/GetCompileFlags.cmake b/cmake/GetCompileFlags.cmake new file mode 100644 index 0000000000..e0994b67bc --- /dev/null +++ b/cmake/GetCompileFlags.cmake @@ -0,0 +1,58 @@ +function(get_compile_flags _compile_flags) + # Create template akin to CMAKE_C_COMPILE_OBJECT. + set(compile_flags "<CMAKE_C_COMPILER> <CFLAGS> <BUILD_TYPE_CFLAGS> <DEFINITIONS> <INCLUDES>") + + # Get C compiler. + string(REPLACE + "<CMAKE_C_COMPILER>" + "${CMAKE_C_COMPILER}" + compile_flags + "${compile_flags}") + + # Get flags set by add_definition(). + get_directory_property(definitions + DIRECTORY "src/nvim" + DEFINITIONS) + string(REPLACE + "<DEFINITIONS>" + "${definitions}" + compile_flags + "${compile_flags}") + + # Get general C flags. + string(REPLACE + "<CFLAGS>" + "${CMAKE_C_FLAGS}" + compile_flags + "${compile_flags}") + + # Get C flags specific to build type. + string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) + string(REPLACE + "<BUILD_TYPE_CFLAGS>" + "${CMAKE_C_FLAGS_${build_type}}" + compile_flags + "${compile_flags}") + + # Get include directories. + get_directory_property(include_directories_list + DIRECTORY "src/nvim" + INCLUDE_DIRECTORIES) + foreach(include_directory ${include_directories_list}) + set(include_directories "${include_directories} -I${include_directory}") + endforeach() + string(REPLACE + "<INCLUDES>" + "${include_directories}" + compile_flags + "${compile_flags}") + + # Clean duplicate whitespace. + string(REPLACE + " " + " " + compile_flags + "${compile_flags}") + + set(${_compile_flags} "${compile_flags}" PARENT_SCOPE) +endfunction() diff --git a/cmake/InstallHelpers.cmake b/cmake/InstallHelpers.cmake index a23bf63ab3..763b2a092c 100644 --- a/cmake/InstallHelpers.cmake +++ b/cmake/InstallHelpers.cmake @@ -22,19 +22,21 @@ function(create_install_dir_with_perms) install(CODE " - if(ENV{DESTDIR}) - # TODO(fwalch): Is this branch ever taken (#1381, #1387)? - set(PREFIX \$ENV{DESTDIR}/\${CMAKE_INSTALL_PREFIX}) - else() - set(PREFIX \${CMAKE_INSTALL_PREFIX}) + if(DEFINED ENV{DESTDIR} AND NOT IS_ABSOLUTE \${CMAKE_INSTALL_PREFIX}) + message(FATAL_ERROR \"Install prefix must be absolute when using DESTDIR\") endif() - set(_current_dir \"\${PREFIX}/${_install_dir_DESTINATION}\") + set(_current_dir \"\${CMAKE_INSTALL_PREFIX}/${_install_dir_DESTINATION}\") set(_dir_permissions \"${_install_dir_DIRECTORY_PERMISSIONS}\") set(_parent_dirs) - while(NOT EXISTS \${_current_dir}) + set(_prev_dir) + + # Explicitly prepend DESTDIR when using EXISTS. + # file(INSTALL ...) implicitly respects DESTDIR, but EXISTS does not. + while(NOT EXISTS \$ENV{DESTDIR}\${_current_dir} AND NOT \${_prev_dir} STREQUAL \${_current_dir}) list(APPEND _parent_dirs \${_current_dir}) + set(_prev_dir \${_current_dir}) get_filename_component(_current_dir \${_current_dir} PATH) endwhile() @@ -47,6 +49,8 @@ function(create_install_dir_with_perms) # 3.0.2. foreach(_current_dir \${_parent_dirs}) if(NOT IS_DIRECTORY \${_current_dir}) + # file(INSTALL ...) implicitly respects DESTDIR, so there's no need to + # prepend it here. file(INSTALL DESTINATION \${_current_dir} TYPE DIRECTORY DIR_PERMISSIONS \${_dir_permissions} diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index c48887548d..0f5dd7d984 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -44,12 +44,9 @@ check_function_exists(getpwent HAVE_GETPWENT) check_function_exists(getpwnam HAVE_GETPWNAM) check_function_exists(getpwuid HAVE_GETPWUID) -check_include_files(iconv.h HAVE_ICONV_H) -check_library_exists(iconv iconv "" HAVE_ICONV_LIB) -if(HAVE_ICONV_LIB) - set(CMAKE_REQUIRED_LIBRARIES iconv) +if(Iconv_FOUND) + set(HAVE_ICONV 1) endif() -check_function_exists(iconv HAVE_ICONV) check_function_exists(lstat HAVE_LSTAT) if(NOT HAVE_LSTAT) diff --git a/config/config.h.in b/config/config.h.in index 7a04837c92..79dabc61e4 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -4,6 +4,8 @@ #define NVIM_VERSION_PRERELEASE "@NVIM_VERSION_PRERELEASE@" #define NVIM_VERSION_BUILD "@NVIM_VERSION_BUILD@" #define NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@" +#define NVIM_VERSION_CFLAGS "@NVIM_VERSION_CFLAGS@" +#define NVIM_VERSION_BUILD_TYPE "@NVIM_VERSION_BUILD_TYPE@" #cmakedefine DEBUG @@ -29,7 +31,6 @@ #cmakedefine HAVE_GETPWNAM #cmakedefine HAVE_GETPWUID #cmakedefine HAVE_ICONV -#cmakedefine USE_ICONV #cmakedefine HAVE_ICONV_H #cmakedefine HAVE_LANGINFO_H #cmakedefine HAVE_LIBGEN_H @@ -1,42 +1,9 @@ -require "formula" +odie <<-EOS.undent -class Neovim < Formula - homepage "http://neovim.org" - head "https://github.com/neovim/neovim.git" + Whoops, the neovim Homebrew Formula has moved! Please instead run: - depends_on "cmake" => :build - depends_on "libtool" => :build - depends_on "automake" => :build - depends_on "autoconf" => :build + brew tap neovim/homebrew-neovim + brew install --HEAD neovim - resource "libuv" do - url "https://github.com/joyent/libuv/archive/v0.11.28.tar.gz" - sha1 "3b70b65467ee693228b8b8385665a52690d74092" - end - - resource "msgpack" do - url "https://github.com/msgpack/msgpack-c/archive/ecf4b09acd29746829b6a02939db91dfdec635b4.tar.gz" - sha1 "c160ff99f20d9d0a25bea0a57f4452f1c9bde370" - end - - resource "luajit" do - url "http://luajit.org/download/LuaJIT-2.0.3.tar.gz" - sha1 "2db39e7d1264918c2266b0436c313fbd12da4ceb" - end - - resource "luarocks" do - url "https://github.com/keplerproject/luarocks/archive/0587afbb5fe8ceb2f2eea16f486bd6183bf02f29.tar.gz" - sha1 "61a894fd5d61987bf7e7f9c3e0c5de16ba4b68c4" - end - - def install - ENV["GIT_DIR"] = cached_download/".git" if build.head? - ENV.deparallelize - - resources.each do |r| - r.stage(target=buildpath/".deps/build/src/#{r.name}") - end - - system "make", "CMAKE_BUILD_TYPE=RelWithDebInfo", "CMAKE_EXTRA_FLAGS=\"-DCMAKE_INSTALL_PREFIX:PATH=#{prefix}\"", "install" - end -end + Thanks! +EOS diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 5b97cf5f40..b06b4fa547 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -89,8 +89,8 @@ get_directory_property(gen_includes INCLUDE_DIRECTORIES) foreach(gen_include ${gen_includes}) set(gen_cflags "${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}") +string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) +set(gen_cflags "${gen_cflags} ${CMAKE_C_FLAGS_${build_type}} ${CMAKE_C_FLAGS}") foreach(sfile ${NEOVIM_SOURCES} "${PROJECT_SOURCE_DIR}/src/nvim/regexp_nfa.c") @@ -158,8 +158,8 @@ else() endif() endif() -if(HAVE_ICONV_LIB) - list(APPEND NVIM_LINK_LIBRARIES iconv) +if(Iconv_LIBRARIES) + list(APPEND NVIM_LINK_LIBRARIES ${Iconv_LIBRARIES}) endif() # Put these last on the link line, since multiple things may depend on them. diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 9992fbdfcf..328b751693 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -1,3 +1,4 @@ +#include <assert.h> #include "nvim/vim.h" #include "nvim/ascii.h" #include "nvim/cursor_shape.h" @@ -76,6 +77,7 @@ char_u *parse_shape_opt(int what) * For the 'a' mode, we loop to handle all the modes. */ all_idx = -1; + assert(modep < colonp); while (modep < colonp || all_idx >= 0) { if (all_idx < 0) { /* Find the mode. */ diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 1d5e1a51cf..384ca9abd8 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3231,6 +3231,7 @@ static buf_T *ins_compl_next_buf(buf_T *buf, int flag) if (flag == 'w') { /* just windows */ if (buf == curbuf) /* first call for this flag/expansion */ wp = curwin; + assert(wp); while ((wp = (wp->w_next != NULL ? wp->w_next : firstwin)) != curwin && wp->w_buffer->b_scanned) ; @@ -3612,6 +3613,7 @@ static int ins_compl_get_exp(pos_T *ini) * If 'infercase' is set, don't use 'smartcase' here */ save_p_scs = p_scs; + assert(ins_buf); if (ins_buf->b_p_inf) p_scs = FALSE; @@ -3760,8 +3762,10 @@ static int ins_compl_get_exp(pos_T *ini) compl_started = TRUE; } else { /* Mark a buffer scanned when it has been scanned completely */ - if (type == 0 || type == CTRL_X_PATH_PATTERNS) + if (type == 0 || type == CTRL_X_PATH_PATTERNS) { + assert(ins_buf); ins_buf->b_scanned = TRUE; + } compl_started = FALSE; } @@ -6286,6 +6290,7 @@ static void mb_replace_pop_ins(int cc) break; } else { buf[0] = c; + assert(n > 1); for (i = 1; i < n; ++i) buf[i] = replace_pop(); if (utf_iscomposing(utf_ptr2char(buf))) @@ -6331,10 +6336,11 @@ static void replace_do_bs(int limit_col) char_u *p; int i; int vcol; + const int l_State = State; cc = replace_pop(); if (cc > 0) { - if (State & VREPLACE_FLAG) { + if (l_State & VREPLACE_FLAG) { /* Get the number of screen cells used by the character we are * going to delete. */ getvcol(curwin, &curwin->w_cursor, NULL, &start_vcol, NULL); @@ -6342,17 +6348,17 @@ static void replace_do_bs(int limit_col) } if (has_mbyte) { (void)del_char_after_col(limit_col); - if (State & VREPLACE_FLAG) + if (l_State & VREPLACE_FLAG) orig_len = (int)STRLEN(get_cursor_pos_ptr()); replace_push(cc); } else { pchar_cursor(cc); - if (State & VREPLACE_FLAG) + if (l_State & VREPLACE_FLAG) orig_len = (int)STRLEN(get_cursor_pos_ptr()) - 1; } replace_pop_ins(); - if (State & VREPLACE_FLAG) { + if (l_State & VREPLACE_FLAG) { /* Get the number of screen cells used by the inserted characters */ p = get_cursor_pos_ptr(); ins_len = (int)STRLEN(p) - orig_len; @@ -7449,7 +7455,9 @@ static int ins_bs(int c, int mode, int *inserted_space_p) if (State & REPLACE_FLAG) replace_do_bs(-1); else { - if (enc_utf8 && p_deco) + const bool l_enc_utf8 = enc_utf8; + const int l_p_deco = p_deco; + if (l_enc_utf8 && l_p_deco) (void)utfc_ptr2char(get_cursor_pos_ptr(), cpc); (void)del_char(FALSE); /* @@ -7457,7 +7465,7 @@ static int ins_bs(int c, int mode, int *inserted_space_p) * move the cursor back. Don't back up before the base * character. */ - if (enc_utf8 && p_deco && cpc[0] != NUL) + if (l_enc_utf8 && l_p_deco && cpc[0] != NUL) inc_cursor(); if (revins_chars) { revins_chars--; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index e74fcef8d9..e7079e02d0 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -11,6 +11,7 @@ * op_change, op_yank, do_put, do_join */ +#include <assert.h> #include <inttypes.h> #include <stdbool.h> #include <string.h> @@ -3436,7 +3437,7 @@ int do_join(long count, && has_format_option(FO_REMOVE_COMS); int prev_was_comment; - + assert(count > 1); if (save_undo && u_save((linenr_T)(curwin->w_cursor.lnum - 1), (linenr_T)(curwin->w_cursor.lnum + count)) == FAIL) return FAIL; @@ -5027,6 +5028,8 @@ void cursor_pos_info(void) pos_T min_pos, max_pos; oparg_T oparg; struct block_def bd; + const int l_VIsual_active = VIsual_active; + const int l_VIsual_mode = VIsual_mode; /* * Compute the length of the file in characters. @@ -5039,7 +5042,7 @@ void cursor_pos_info(void) else eol_size = 1; - if (VIsual_active) { + if (l_VIsual_active) { if (lt(VIsual, curwin->w_cursor)) { min_pos = VIsual; max_pos = curwin->w_cursor; @@ -5050,7 +5053,7 @@ void cursor_pos_info(void) if (*p_sel == 'e' && max_pos.col > 0) --max_pos.col; - if (VIsual_mode == Ctrl_V) { + if (l_VIsual_mode == Ctrl_V) { char_u * saved_sbr = p_sbr; /* Make 'sbr' empty for a moment to get the correct size. */ @@ -5083,12 +5086,12 @@ void cursor_pos_info(void) } /* Do extra processing for VIsual mode. */ - if (VIsual_active + if (l_VIsual_active && lnum >= min_pos.lnum && lnum <= max_pos.lnum) { char_u *s = NULL; long len = 0L; - switch (VIsual_mode) { + switch (l_VIsual_mode) { case Ctrl_V: virtual_op = virtual_active(); block_prep(&oparg, &bd, lnum, 0); @@ -5141,8 +5144,8 @@ void cursor_pos_info(void) if (!curbuf->b_p_eol && curbuf->b_p_bin) byte_count -= eol_size; - if (VIsual_active) { - if (VIsual_mode == Ctrl_V && curwin->w_curswant < MAXCOL) { + if (l_VIsual_active) { + if (l_VIsual_mode == Ctrl_V && curwin->w_curswant < MAXCOL) { getvcols(curwin, &min_pos, &max_pos, &min_pos.col, &max_pos.col); vim_snprintf((char *)buf1, sizeof(buf1), _("%" PRId64 " Cols; "), diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 90da02bb1b..cef2e6d9bf 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -43,6 +43,7 @@ /* #undef REGEXP_DEBUG */ /* #define REGEXP_DEBUG */ +#include <assert.h> #include <inttypes.h> #include <stdbool.h> #include <string.h> @@ -1199,10 +1200,7 @@ char_u *skip_regexp(char_u *startp, int dirc, int magic, char_u **newp) *newp = vim_strsave(startp); p = *newp + (p - startp); } - if (*newp != NULL) - STRMOVE(p, p + 1); - else - ++p; + STRMOVE(p, p + 1); } else ++p; /* skip next character */ if (*p == 'v') @@ -1300,16 +1298,18 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags) r->regstart = (*mb_ptr2char)(OPERAND(scan)); else r->regstart = *OPERAND(scan); - } else if ((OP(scan) == BOW - || OP(scan) == EOW - || OP(scan) == NOTHING - || OP(scan) == MOPEN + 0 || OP(scan) == NOPEN - || OP(scan) == MCLOSE + 0 || OP(scan) == NCLOSE) - && OP(regnext(scan)) == EXACTLY) { - if (has_mbyte) - r->regstart = (*mb_ptr2char)(OPERAND(regnext(scan))); - else - r->regstart = *OPERAND(regnext(scan)); + } else if (OP(scan) == BOW + || OP(scan) == EOW + || OP(scan) == NOTHING + || OP(scan) == MOPEN + 0 || OP(scan) == NOPEN + || OP(scan) == MCLOSE + 0 || OP(scan) == NCLOSE) { + char_u *regnext_scan = regnext(scan); + if (OP(regnext_scan) == EXACTLY) { + if (has_mbyte) + r->regstart = (*mb_ptr2char)(OPERAND(regnext_scan)); + else + r->regstart = *OPERAND(regnext_scan); + } } /* @@ -5626,6 +5626,8 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e /* Get the line to compare with. */ p = reg_getline(clnum); + assert(p); + if (clnum == end_lnum) len = end_col - ccol; else diff --git a/src/nvim/screen.c b/src/nvim/screen.c index ac726f7988..e217945ac3 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -244,6 +244,9 @@ int redraw_asap(int type) u8char_T *screenlineUC = NULL; /* copy from ScreenLinesUC[] */ u8char_T *screenlineC[MAX_MCO]; /* copy from ScreenLinesC[][] */ schar_T *screenline2 = NULL; /* copy from ScreenLines2[] */ + const bool l_enc_utf8 = enc_utf8; + const int l_enc_dbcs = enc_dbcs; + const long l_p_mco = p_mco; redraw_later(type); if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY)) @@ -254,14 +257,14 @@ int redraw_asap(int type) screenline = xmalloc((size_t)(rows * Columns * sizeof(schar_T))); screenattr = xmalloc((size_t)(rows * Columns * sizeof(sattr_T))); - if (enc_utf8) { + if (l_enc_utf8) { screenlineUC = xmalloc((size_t)(rows * Columns * sizeof(u8char_T))); - for (i = 0; i < p_mco; ++i) { + for (i = 0; i < l_p_mco; ++i) { screenlineC[i] = xmalloc((size_t)(rows * Columns * sizeof(u8char_T))); } } - if (enc_dbcs == DBCS_JPNU) { + if (l_enc_dbcs == DBCS_JPNU) { screenline2 = xmalloc((size_t)(rows * Columns * sizeof(schar_T))); } @@ -273,16 +276,16 @@ int redraw_asap(int type) memmove(screenattr + r * Columns, ScreenAttrs + LineOffset[cmdline_row + r], (size_t)Columns * sizeof(sattr_T)); - if (enc_utf8) { + if (l_enc_utf8) { memmove(screenlineUC + r * Columns, ScreenLinesUC + LineOffset[cmdline_row + r], (size_t)Columns * sizeof(u8char_T)); - for (i = 0; i < p_mco; ++i) + for (i = 0; i < l_p_mco; ++i) memmove(screenlineC[i] + r * Columns, ScreenLinesC[r] + LineOffset[cmdline_row + r], (size_t)Columns * sizeof(u8char_T)); } - if (enc_dbcs == DBCS_JPNU) + if (l_enc_dbcs == DBCS_JPNU) memmove(screenline2 + r * Columns, ScreenLines2 + LineOffset[cmdline_row + r], (size_t)Columns * sizeof(schar_T)); @@ -302,16 +305,16 @@ int redraw_asap(int type) memmove(ScreenAttrs + off, screenattr + r * Columns, (size_t)Columns * sizeof(sattr_T)); - if (enc_utf8) { + if (l_enc_utf8) { memmove(ScreenLinesUC + off, screenlineUC + r * Columns, (size_t)Columns * sizeof(u8char_T)); - for (i = 0; i < p_mco; ++i) + for (i = 0; i < l_p_mco; ++i) memmove(ScreenLinesC[i] + off, screenlineC[i] + r * Columns, (size_t)Columns * sizeof(u8char_T)); } - if (enc_dbcs == DBCS_JPNU) + if (l_enc_dbcs == DBCS_JPNU) memmove(ScreenLines2 + off, screenline2 + r * Columns, (size_t)Columns * sizeof(schar_T)); @@ -322,12 +325,12 @@ int redraw_asap(int type) free(screenline); free(screenattr); - if (enc_utf8) { + if (l_enc_utf8) { free(screenlineUC); - for (i = 0; i < p_mco; ++i) + for (i = 0; i < l_p_mco; ++i) free(screenlineC[i]); } - if (enc_dbcs == DBCS_JPNU) + if (l_enc_dbcs == DBCS_JPNU) free(screenline2); /* Show the intro message when appropriate. */ @@ -3474,7 +3477,6 @@ win_line ( n_extra = tab_len; } else { char_u *p; - int len = n_extra; int i; int saved_nextra = n_extra; @@ -3485,7 +3487,7 @@ win_line ( /* if n_extra > 0, it gives the number of chars to use for * a tab, else we need to calculate the width for a tab */ - len = (tab_len * mb_char2len(lcs_tab2)); + int len = (tab_len * mb_char2len(lcs_tab2)); if (n_extra > 0) { len += n_extra - tab_len; } @@ -3865,7 +3867,7 @@ win_line ( /* Get rid of the boguscols now, we want to draw until the right * edge for 'cursorcolumn'. */ col -= boguscols; - boguscols = 0; + // boguscols = 0; // Disabled because value never read after this if (draw_color_col) draw_color_col = advance_color_col(VCOL_HLC, &color_cols); @@ -7532,7 +7534,6 @@ int showmode(void) msg_puts_attr(edit_submode_extra, sub_attr); } } - length = 0; } else { if (State & VREPLACE_FLAG) MSG_PUTS_ATTR(_(" VREPLACE"), attr); @@ -7708,7 +7709,6 @@ static void draw_tabline(void) attr = attr_nosel; tabcount = 0; - scol = 0; FOR_ALL_TABS(tp) { if (col >= Columns - 4) { diff --git a/src/nvim/version.c b/src/nvim/version.c index 4d81cc86bf..137f85bb2b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -21,6 +21,8 @@ char *Version = VIM_VERSION_SHORT; char *longVersion = NVIM_VERSION_LONG " (compiled " __DATE__ " " __TIME__ ")"; char *version_commit = "Commit: " NVIM_VERSION_COMMIT; +char *version_buildtype = "Build type: " NVIM_VERSION_BUILD_TYPE; +char *version_cflags = "Compilation: " NVIM_VERSION_CFLAGS; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "version.c.generated.h" @@ -778,6 +780,8 @@ void list_version(void) // internal variables in eval.c! MSG(longVersion); MSG(version_commit); + MSG(version_buildtype); + MSG(version_cflags); // Print the list of extra patch descriptions if there is at least one. char *s = ""; @@ -857,10 +861,6 @@ void list_version(void) version_msg("\"\n"); } #endif // ifdef HAVE_PATHDEF -#ifdef DEBUG - version_msg("\n"); - version_msg(_(" DEBUG BUILD")); -#endif // ifdef DEBUG } /// Output a string for the version message. If it's going to wrap, output a diff --git a/src/nvim/version_defs.h b/src/nvim/version_defs.h index d8e1b4ea82..0ba6143632 100644 --- a/src/nvim/version_defs.h +++ b/src/nvim/version_defs.h @@ -22,13 +22,19 @@ #define NVIM_VERSION_PATCH 0 #endif #ifndef NVIM_VERSION_PRERELEASE -#define NVIM_VERSION_PRERELEASE +#define NVIM_VERSION_PRERELEASE "?" #endif #ifndef NVIM_VERSION_BUILD -#define NVIM_VERSION_BUILD +#define NVIM_VERSION_BUILD "?" #endif #ifndef NVIM_VERSION_COMMIT -#define NVIM_VERSION_COMMIT +#define NVIM_VERSION_COMMIT "?" +#endif +#ifndef NVIM_VERSION_CFLAGS +#define NVIM_VERSION_CFLAGS "?" +#endif +#ifndef NVIM_VERSION_BUILD_TYPE +#define NVIM_VERSION_BUILD_TYPE "?" #endif // for the startup-screen #define NVIM_VERSION_MEDIUM STR(NVIM_VERSION_MAJOR) "." STR(NVIM_VERSION_MINOR) |