diff options
-rw-r--r-- | .ci/api-python.sh | 19 | ||||
-rw-r--r-- | .ci/clang-asan.sh | 39 | ||||
-rwxr-xr-x | .ci/clint.sh (renamed from scripts/clint.sh) | 0 | ||||
-rw-r--r-- | .ci/common.sh | 87 | ||||
-rw-r--r-- | .ci/coverity.sh | 16 | ||||
-rw-r--r-- | .ci/gcc-ia32.sh | 23 | ||||
-rw-r--r-- | .ci/gcc-unittest.sh | 11 | ||||
-rw-r--r-- | .travis.yml | 16 | ||||
-rwxr-xr-x | scripts/travis.sh | 183 | ||||
-rw-r--r-- | src/nvim/api/private/helpers.c | 14 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 79 | ||||
-rw-r--r-- | src/nvim/eval.c | 30 | ||||
-rw-r--r-- | src/nvim/testdir/test69.in | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test69.ok | 4 | ||||
-rw-r--r-- | src/nvim/version.c | 2 | ||||
-rw-r--r-- | third-party/CMakeLists.txt | 4 |
16 files changed, 278 insertions, 256 deletions
diff --git a/.ci/api-python.sh b/.ci/api-python.sh new file mode 100644 index 0000000000..093f6b7166 --- /dev/null +++ b/.ci/api-python.sh @@ -0,0 +1,19 @@ +. "$CI_SCRIPTS/common.sh" + +set_environment /opt/neovim-deps + +sudo apt-get install expect valgrind + +$MAKE_CMD + +git clone --depth=1 -b master git://github.com/neovim/python-client +cd python-client +sudo pip install . +sudo pip install nose +test_cmd="nosetests --verbosity=2" +nvim_cmd="valgrind -q --track-origins=yes --leak-check=yes --suppressions=$suppressions --log-file=$tmpdir/valgrind-%p.log ../build/bin/nvim -u NONE" +if ! ../scripts/run-api-tests.exp "$test_cmd" "$nvim_cmd"; then + valgrind_check "$tmpdir" + exit 1 +fi +valgrind_check "$tmpdir" diff --git a/.ci/clang-asan.sh b/.ci/clang-asan.sh new file mode 100644 index 0000000000..2c67a3c1c6 --- /dev/null +++ b/.ci/clang-asan.sh @@ -0,0 +1,39 @@ +. "$CI_SCRIPTS/common.sh" + +set_environment /opt/neovim-deps + +sudo pip install cpp-coveralls + +clang_version=3.4 +if [ ! -d /usr/local/clang-$clang_version ]; then + echo "Downloading clang $clang_version..." + sudo mkdir /usr/local/clang-$clang_version + wget -q -O - http://llvm.org/releases/$clang_version/clang+llvm-$clang_version-x86_64-unknown-ubuntu12.04.xz \ + | sudo tar xJf - --strip-components=1 -C /usr/local/clang-$clang_version + export CC=/usr/local/clang-$clang_version/bin/clang +else + export CC=clang +fi +symbolizer=/usr/local/clang-$clang_version/bin/llvm-symbolizer + +export SANITIZE=1 +export ASAN_SYMBOLIZER_PATH=$symbolizer +export ASAN_OPTIONS="detect_leaks=1:log_path=$tmpdir/asan" +export TSAN_OPTIONS="external_symbolizer_path=$symbolizer:log_path=$tmpdir/tsan" + +export SKIP_UNITTEST=1 +export UBSAN_OPTIONS="log_path=$tmpdir/ubsan" # not sure if this works + +install_dir="$(pwd)/dist" +$MAKE_CMD cmake CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DCMAKE_INSTALL_PREFIX=$install_dir -DUSE_GCOV=ON" +$MAKE_CMD +if ! $MAKE_CMD test; then + reset + asan_check "$tmpdir" + exit 1 +fi + +asan_check "$tmpdir" +coveralls --encoding iso-8859-1 || echo 'coveralls upload failed.' + +$MAKE_CMD install diff --git a/scripts/clint.sh b/.ci/clint.sh index 55eb5c9394..55eb5c9394 100755 --- a/scripts/clint.sh +++ b/.ci/clint.sh diff --git a/.ci/common.sh b/.ci/common.sh new file mode 100644 index 0000000000..fdd448b4ce --- /dev/null +++ b/.ci/common.sh @@ -0,0 +1,87 @@ +valgrind_check() { + ( + cd $1 + set -- valgrind-[*] valgrind-* + case $1$2 in + 'valgrind-[*]valgrind-*') + ;; + *) + shift + local err='' + for valgrind_log in "$@"; do + # Remove useless warning + sed -i "$valgrind_log" \ + -e '/Warning: noted but unhandled ioctl/d' \ + -e '/could cause spurious value errors to appear/d' \ + -e '/See README_MISSING_SYSCALL_OR_IOCTL for guidance/d' + if [ "$(stat -c %s $valgrind_log)" != "0" ]; then + # if after removing the warning, the log still has errors, show its + # contents and set the flag so we exit with non-zero status + cat "$valgrind_log" + err=1 + fi + done + if [ -n "$err" ]; then + echo "Runtime errors detected" + exit 1 + fi + ;; + esac + ) +} + +asan_check() { + ( + cd $1 + set -- [*]san.[*] *san.* + case $1$2 in + '[*]san.[*]*san.*') + ;; + *) + shift + cat "$@" + echo "Runtime errors detected" + exit 1 + ;; + esac + ) +} + +set_environment() { + local prefix="$1" + eval $($prefix/bin/luarocks path) + export PATH="$prefix/bin:$PATH" + export PKG_CONFIG_PATH="$prefix/lib/pkgconfig" + export USE_BUNDLED_DEPS=OFF +} + + +install_prebuilt_deps() { + # install prebuilt dependencies + if [ ! -d /opt/neovim-deps ]; then + cd /opt + sudo git clone --depth=1 git://github.com/neovim/deps neovim-deps + cd - + fi +} + +tmpdir="$(pwd)/tmp" +rm -rf "$tmpdir" +mkdir -p "$tmpdir" +suppressions="$(pwd)/.valgrind.supp" + +# Travis reports back that it has 32-cores via /proc/cpuinfo, but it's not +# what we really have available. According to their documentation, it only has +# 1.5 virtual cores. +# See: +# http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM +# for more information. +MAKE_CMD="make -j2" + +install_prebuilt_deps + +# Pins the version of the java package installed on the Travis VMs +# and avoids a lengthy upgrade process for them. +sudo apt-mark hold oracle-java7-installer oracle-java8-installer + +sudo apt-get update diff --git a/.ci/coverity.sh b/.ci/coverity.sh new file mode 100644 index 0000000000..0edaf2e088 --- /dev/null +++ b/.ci/coverity.sh @@ -0,0 +1,16 @@ +. "$CI_SCRIPTS/common.sh" + +# temporarily disable error checking, the coverity script exits with +# status code 1 whenever it (1) fails OR (2) is not on the correct +# branch. +set +e +curl -s https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh | +COVERITY_SCAN_PROJECT_NAME="neovim/neovim" \ + COVERITY_SCAN_NOTIFICATION_EMAIL="coverity@aktau.be" \ + COVERITY_SCAN_BRANCH_PATTERN="coverity-scan" \ + COVERITY_SCAN_BUILD_COMMAND_PREPEND="$MAKE_CMD deps" \ + COVERITY_SCAN_BUILD_COMMAND="$MAKE_CMD nvim" \ + bash +set -e + +exit 0 diff --git a/.ci/gcc-ia32.sh b/.ci/gcc-ia32.sh new file mode 100644 index 0000000000..b4fc1745ed --- /dev/null +++ b/.ci/gcc-ia32.sh @@ -0,0 +1,23 @@ +. "$CI_SCRIPTS/common.sh" +set_environment /opt/neovim-deps/32 + +# Need this to keep apt-get from removing gcc when installing libncurses +# below. +sudo apt-get install libc6-dev libc6-dev:i386 + +# Do this separately so that things get configured correctly, otherwise +# libncurses fails to install. +sudo apt-get install gcc-multilib g++-multilib + +# Install the dev version to get the pkg-config and symlinks installed +# correctly. +sudo apt-get install libncurses5-dev:i386 + +CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DBUSTED_OUTPUT_TYPE=color_terminal \ + -DCMAKE_SYSTEM_PROCESSOR=i386 \ + -DCMAKE_SYSTEM_LIBRARY_PATH=/lib32:/usr/lib32:/usr/local/lib32 \ + -DFIND_LIBRARY_USE_LIB64_PATHS=OFF \ + -DCMAKE_IGNORE_PATH=/lib:/usr/lib:/usr/local/lib \ + -DCMAKE_TOOLCHAIN_FILE=cmake/i386-linux-gnu.toolchain.cmake" +$MAKE_CMD CMAKE_EXTRA_FLAGS="${CMAKE_EXTRA_FLAGS}" unittest +$MAKE_CMD test diff --git a/.ci/gcc-unittest.sh b/.ci/gcc-unittest.sh new file mode 100644 index 0000000000..a4e4a6f35f --- /dev/null +++ b/.ci/gcc-unittest.sh @@ -0,0 +1,11 @@ +. "$CI_SCRIPTS/common.sh" + +set_environment /opt/neovim-deps + +sudo pip install cpp-coveralls + +export CC=gcc +export SKIP_EXEC=1 +$MAKE_CMD CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DBUSTED_OUTPUT_TYPE=color_terminal -DUSE_GCOV=ON" unittest + +coveralls --encoding iso-8859-1 || echo 'coveralls upload failed.' diff --git a/.travis.yml b/.travis.yml index 703419200d..4af91446ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,17 @@ language: c env: global: + - PROJECT_ROOT="$(pwd)" + - CI_SCRIPTS="$PROJECT_ROOT/.ci" # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created # via the "travis encrypt" command using the project repo's public key - secure: "QEz92NyItkzQu52kCFD928jEwUYnA2OIgSyeNrp+Y3gm5rOmSZerY8hGiXyNZxocap9+qIPCapRRYU3ZYKWZPeucWMLN3aIjxAFdhugKbnmNYE1jFugb6b8N3SxiX/3206NHXlYaz0OZhh6OBAFmPUXamJC8OrWVgPNPo7wv4UQ=" matrix: - - TRAVIS_BUILD_TYPE=clang/asan - - TRAVIS_BUILD_TYPE=gcc/ia32 - - TRAVIS_BUILD_TYPE=gcc/unittest - - TRAVIS_BUILD_TYPE=clint - - TRAVIS_BUILD_TYPE=api/python - - TRAVIS_BUILD_TYPE=coverity + - CI_TARGET=clang-asan + - CI_TARGET=gcc-ia32 + - CI_TARGET=gcc-unittest + - CI_TARGET=clint + - CI_TARGET=api-python + - CI_TARGET=coverity script: - - ./scripts/travis.sh + - sh -e "${CI_SCRIPTS}/${CI_TARGET}.sh" diff --git a/scripts/travis.sh b/scripts/travis.sh deleted file mode 100755 index ceb244a9f4..0000000000 --- a/scripts/travis.sh +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/sh -e - -tmpdir="$(pwd)/tmp" -rm -rf "$tmpdir" -mkdir -p "$tmpdir" -suppressions="$(pwd)/.valgrind.supp" - -valgrind_check() { - ( - cd $1 - set -- valgrind-[*] valgrind-* - case $1$2 in - 'valgrind-[*]valgrind-*') - ;; - *) - shift - local err='' - for valgrind_log in "$@"; do - # Remove useless warning - sed -i "$valgrind_log" \ - -e '/Warning: noted but unhandled ioctl/d' \ - -e '/could cause spurious value errors to appear/d' \ - -e '/See README_MISSING_SYSCALL_OR_IOCTL for guidance/d' - if [ "$(stat -c %s $valgrind_log)" != "0" ]; then - # if after removing the warning, the log still has errors, show its - # contents and set the flag so we exit with non-zero status - cat "$valgrind_log" - err=1 - fi - done - if [ -n "$err" ]; then - echo "Runtime errors detected" - exit 1 - fi - ;; - esac - ) -} - -asan_check() { - ( - cd $1 - set -- [*]san.[*] *san.* - case $1$2 in - '[*]san.[*]*san.*') - ;; - *) - shift - cat "$@" - echo "Runtime errors detected" - exit 1 - ;; - esac - ) -} - -set_environment() { - local prefix="$1" - eval $($prefix/bin/luarocks path) - export PATH="$prefix/bin:$PATH" - export PKG_CONFIG_PATH="$prefix/lib/pkgconfig" - export USE_BUNDLED_DEPS=OFF -} - -# install prebuilt dependencies -if [ ! -d /opt/neovim-deps ]; then - cd /opt - sudo git clone --depth=1 git://github.com/neovim/deps neovim-deps - cd - -fi - -# Travis reports back that it has 32-cores via /proc/cpuinfo, but it's not -# what we really have available. According to their documentation, it only has -# 1.5 virtual cores. -# See: -# http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM -# for more information. -MAKE_CMD="make -j2" - -if [ "$TRAVIS_BUILD_TYPE" = "coverity" ]; then - # temporarily disable error checking, the coverity script exits with - # status code 1 whenever it (1) fails OR (2) is not on the correct - # branch. - set +e - curl -s https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh | - COVERITY_SCAN_PROJECT_NAME="neovim/neovim" \ - COVERITY_SCAN_NOTIFICATION_EMAIL="coverity@aktau.be" \ - COVERITY_SCAN_BRANCH_PATTERN="coverity-scan" \ - COVERITY_SCAN_BUILD_COMMAND_PREPEND="$MAKE_CMD deps" \ - COVERITY_SCAN_BUILD_COMMAND="$MAKE_CMD nvim" \ - bash - set -e - exit 0 -elif [ "$TRAVIS_BUILD_TYPE" = "clang/asan" ]; then - clang_version=3.4 - if [ ! -d /usr/local/clang-$clang_version ]; then - echo "Downloading clang $clang_version..." - sudo mkdir /usr/local/clang-$clang_version - wget -q -O - http://llvm.org/releases/$clang_version/clang+llvm-$clang_version-x86_64-unknown-ubuntu12.04.xz \ - | sudo tar xJf - --strip-components=1 -C /usr/local/clang-$clang_version - export CC=/usr/local/clang-$clang_version/bin/clang - else - export CC=clang - fi - symbolizer=/usr/local/clang-$clang_version/bin/llvm-symbolizer - - sudo pip install cpp-coveralls - set_environment /opt/neovim-deps - - export SANITIZE=1 - export ASAN_SYMBOLIZER_PATH=$symbolizer - export ASAN_OPTIONS="detect_leaks=1:log_path=$tmpdir/asan" - export TSAN_OPTIONS="external_symbolizer_path=$symbolizer:log_path=$tmpdir/tsan" - - export SKIP_UNITTEST=1 - export UBSAN_OPTIONS="log_path=$tmpdir/ubsan" # not sure if this works - - install_dir="$(pwd)/dist" - $MAKE_CMD cmake CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DCMAKE_INSTALL_PREFIX=$install_dir -DUSE_GCOV=ON" - $MAKE_CMD - if ! $MAKE_CMD test; then - reset - asan_check "$tmpdir" - exit 1 - fi - asan_check "$tmpdir" - coveralls --encoding iso-8859-1 || echo 'coveralls upload failed.' - $MAKE_CMD install -elif [ "$TRAVIS_BUILD_TYPE" = "gcc/unittest" ]; then - sudo pip install cpp-coveralls - export CC=gcc - set_environment /opt/neovim-deps - export SKIP_EXEC=1 - $MAKE_CMD CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DBUSTED_OUTPUT_TYPE=color_terminal -DUSE_GCOV=ON" unittest - coveralls --encoding iso-8859-1 || echo 'coveralls upload failed.' -elif [ "$TRAVIS_BUILD_TYPE" = "gcc/ia32" ]; then - set_environment /opt/neovim-deps/32 - - # Pins the version of the java package installed on the Travis VMs - # and avoids a lengthy upgrade process for them. - sudo apt-mark hold oracle-java7-installer oracle-java8-installer - - sudo apt-get update - - # Need this to keep apt-get from removing gcc when installing libncurses - # below. - sudo apt-get install libc6-dev libc6-dev:i386 - - # Do this separately so that things get configured correctly, otherwise - # libncurses fails to install. - sudo apt-get install gcc-multilib g++-multilib - - # Install the dev version to get the pkg-config and symlinks installed - # correctly. - sudo apt-get install libncurses5-dev:i386 - - CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DBUSTED_OUTPUT_TYPE=color_terminal \ - -DCMAKE_SYSTEM_PROCESSOR=i386 \ - -DCMAKE_SYSTEM_LIBRARY_PATH=/lib32:/usr/lib32:/usr/local/lib32 \ - -DFIND_LIBRARY_USE_LIB64_PATHS=OFF \ - -DCMAKE_IGNORE_PATH=/lib:/usr/lib:/usr/local/lib \ - -DCMAKE_TOOLCHAIN_FILE=cmake/i386-linux-gnu.toolchain.cmake" - $MAKE_CMD CMAKE_EXTRA_FLAGS="${CMAKE_EXTRA_FLAGS}" unittest - $MAKE_CMD test -elif [ "$TRAVIS_BUILD_TYPE" = "clint" ]; then - ./scripts/clint.sh -elif [ "$TRAVIS_BUILD_TYPE" = "api/python" ]; then - set_environment /opt/neovim-deps - sudo apt-get update - sudo apt-get install expect valgrind - $MAKE_CMD - git clone --depth=1 -b master git://github.com/neovim/python-client - cd python-client - sudo pip install . - sudo pip install nose - test_cmd="nosetests --verbosity=2" - nvim_cmd="valgrind -q --track-origins=yes --leak-check=yes --suppressions=$suppressions --log-file=$tmpdir/valgrind-%p.log ../build/bin/nvim -u NONE" - if ! ../scripts/run-api-tests.exp "$test_cmd" "$nvim_cmd"; then - valgrind_check "$tmpdir" - exit 1 - fi - valgrind_check "$tmpdir" -fi diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 354a74d19a..f6fb46e1d1 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -343,6 +343,20 @@ String cstr_to_string(const char *str) }; } +/// Creates a String using the given C string. Unlike +/// cstr_to_string this function DOES NOT copy the C string. +/// +/// @param str the C string to use +/// @return The resulting String, or an empty String if +/// str was NULL +String cstr_as_string(char *str) FUNC_ATTR_PURE +{ + if (str == NULL) { + return (String) STRING_INIT; + } + return (String) {.data = str, .size = strlen(str)}; +} + bool object_to_vim(Object obj, typval_T *tv, Error *err) { tv->v_type = VAR_UNKNOWN; diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 6c793cbc54..a2c50b4c81 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -54,55 +54,52 @@ void vim_command(String str, Error *err) /// Pass input keys to Neovim /// /// @param keys to be typed -/// @param replace_tcodes If true replace special keys such as <CR> or <Leader> -/// for compatibility with Vim --remote-send expressions -/// @param remap If True remap keys -/// @param typed Handle keys as if typed; otherwise they are handled as -/// if coming from a mapping. This matters for undo, -/// opening folds, etc. -void vim_feedkeys(String keys, Boolean replace_tcodes, Boolean remap, - Boolean typed, Error *err) +/// @param mode specifies the mapping options +/// @see feedkeys() +void vim_feedkeys(String keys, String mode) { - char *ptr = NULL; - char *cpo_save = (char *)p_cpo; - - if (replace_tcodes) { - // Set 'cpoptions' the way we want it. - // B set - backslashes are *not* treated specially - // k set - keycodes are *not* reverse-engineered - // < unset - <Key> sequences *are* interpreted - // The last but one parameter of replace_termcodes() is TRUE so that the - // <lt> sequence is recognised - needed for a real backslash. - p_cpo = (char_u *)"Bk"; - replace_termcodes((char_u *)keys.data, (char_u **)&ptr, false, true, true); - p_cpo = (char_u *)cpo_save; - } else { - ptr = keys.data; + bool remap = true; + bool typed = false; + + if (keys.size == 0) { + return; } - if (ptr == NULL) { - set_api_error("Failed to eval expression", err); - } else { - // Add the string to the input stream. - // Can't use add_to_input_buf() here, we now have K_SPECIAL bytes. - // - // First clear typed characters from the typeahead buffer, there could - // be half a mapping there. Then append to the existing string, so - // that multiple commands from a client are concatenated. - if (typebuf.tb_maplen < typebuf.tb_len) { - del_typebuf(typebuf.tb_len - typebuf.tb_maplen, typebuf.tb_maplen); + for (size_t i = 0; i < mode.size; ++i) { + switch (mode.data[i]) { + case 'n': remap = false; break; + case 'm': remap = true; break; + case 't': typed = true; break; } - (void)ins_typebuf((char_u *)ptr, (remap ? REMAP_YES : REMAP_NONE), - typebuf.tb_len, !typed, false); + } + + /* Need to escape K_SPECIAL and CSI before putting the string in the + * typeahead buffer. */ + char *keys_esc = (char *)vim_strsave_escape_csi((char_u *)keys.data); + ins_typebuf((char_u *)keys_esc, (remap ? REMAP_YES : REMAP_NONE), + typebuf.tb_len, !typed, false); + free(keys_esc); - // Let input_available() know we inserted text in the typeahead - // buffer. */ + if (vgetc_busy) typebuf_was_filled = true; +} - if (replace_tcodes) { - free(ptr); - } +/// Replace any terminal codes with the internal representation +/// +/// @see replace_termcodes +/// @see cpoptions +String vim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, + Boolean special) +{ + if (str.size == 0) { + // Empty string + return str; } + + char *ptr = NULL; + replace_termcodes((char_u *)str.data, (char_u **)&ptr, + from_part, do_lt, special); + return cstr_as_string(ptr); } /// Evaluates the expression str using the vim internal expression diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f7b65d1476..80f7a65d45 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -83,7 +83,7 @@ #include "nvim/os/time.h" #include "nvim/os/channel.h" #include "nvim/api/private/helpers.h" -#include "nvim/api/private/defs.h" +#include "nvim/api/vim.h" #include "nvim/os/msgpack_rpc_helpers.h" #include "nvim/os/dl.h" #include "nvim/os/provider.h" @@ -8280,11 +8280,8 @@ static void f_extend(typval_T *argvars, typval_T *rettv) */ static void f_feedkeys(typval_T *argvars, typval_T *rettv) { - int remap = TRUE; - char_u *keys, *flags; + char_u *keys, *flags = NULL; char_u nbuf[NUMBUFLEN]; - int typed = FALSE; - char_u *keys_esc; /* This is not allowed in the sandbox. If the commands would still be * executed in the sandbox it would be OK, but it probably happens later, @@ -8296,23 +8293,10 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv) if (*keys != NUL) { if (argvars[1].v_type != VAR_UNKNOWN) { flags = get_tv_string_buf(&argvars[1], nbuf); - for (; *flags != NUL; ++flags) { - switch (*flags) { - case 'n': remap = FALSE; break; - case 'm': remap = TRUE; break; - case 't': typed = TRUE; break; - } - } } - /* Need to escape K_SPECIAL and CSI before putting the string in the - * typeahead buffer. */ - keys_esc = vim_strsave_escape_csi(keys); - ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE), - typebuf.tb_len, !typed, FALSE); - free(keys_esc); - if (vgetc_busy) - typebuf_was_filled = TRUE; + vim_feedkeys(cstr_as_string((char *)keys), + cstr_as_string((char *)flags)); } } @@ -19012,8 +18996,10 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags) if (regmatch.startp[0] == regmatch.endp[0]) { if (zero_width == regmatch.startp[0]) { /* avoid getting stuck on a match with an empty string */ - *((char_u *)ga.ga_data + ga.ga_len) = *tail++; - ++ga.ga_len; + int i = MB_PTR2LEN(tail); + memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i); + ga.ga_len += i; + tail += i; continue; } zero_width = regmatch.startp[0]; diff --git a/src/nvim/testdir/test69.in b/src/nvim/testdir/test69.in index 75317b4954..674dc32812 100644 --- a/src/nvim/testdir/test69.in +++ b/src/nvim/testdir/test69.in @@ -180,6 +180,13 @@ byteidx byteidxcomp STARTTEST +/^substitute +:let y = substitute('123', '\zs', 'a', 'g') | put =y +ENDTEST + +substitute + +STARTTEST :g/^STARTTEST/.,/^ENDTEST/d :1;/^Results/,$wq! test.out ENDTEST diff --git a/src/nvim/testdir/test69.ok b/src/nvim/testdir/test69.ok index 41cd9d02c3..af8befb0c7 100644 --- a/src/nvim/testdir/test69.ok +++ b/src/nvim/testdir/test69.ok @@ -160,3 +160,7 @@ byteidxcomp [0, 1, 3, 4, -1] [0, 1, 2, 4, 5, -1] + +substitute +a1a2a3a + diff --git a/src/nvim/version.c b/src/nvim/version.c index dd39070558..3311b78f49 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -226,7 +226,7 @@ static int included_patches[] = { //326, //325, //324, - //323, + 323, //322, //321, //320, diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index c41b80c9b8..56956fdc70 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -46,8 +46,8 @@ endif() include(ExternalProject) -set(LIBUV_URL https://github.com/joyent/libuv/archive/v0.11.26.tar.gz) -set(LIBUV_MD5 05fabe884173f422649fbe1047ca62b1) +set(LIBUV_URL https://github.com/joyent/libuv/archive/v0.11.28.tar.gz) +set(LIBUV_MD5 1a849ba4fc571d531482ed74bc7aabc4) set(MSGPACK_URL https://github.com/msgpack/msgpack-c/releases/download/cpp-0.5.8/msgpack-0.5.8.tar.gz) set(MSGPACK_MD5 ea0bee0939d2980c0df91f0e4843ccc4) |