From ec48a9c58989babcad23d73483955f35b6e41492 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 3 Feb 2018 20:11:40 +0100 Subject: [PATCH 01/11] patch 8.0.1463: test fails without 'autochdir' option Problem: Test fails without 'autochdir' option. Solution: Skip test if 'autochdir' is not supported. --- src/testdir/test_autocmd.vim | 3 +++ src/version.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index c504f704fc..065ac4e29d 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -1232,6 +1232,9 @@ function Test_dirchanged_local() endfunc function Test_dirchanged_auto() + if !exists('+autochdir') + return + endif call s:Before_test_dirchanged() call test_autochdir() autocmd test_dirchanged DirChanged auto call add(s:li, "auto:") diff --git a/src/version.c b/src/version.c index 5b4c2d2099..af192797f7 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1463, /**/ 1462, /**/ From 8a37b032895b40dd6953280c33585bcba0c7ef8b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 3 Feb 2018 20:43:08 +0100 Subject: [PATCH 02/11] patch 8.0.1464: completing directory after :find does not add slash Problem: Completing directory after :find does not add slash. Solution: Adjust the flags for globpath(). (Genki Sky) --- src/misc1.c | 7 ++++++- src/testdir/test_find_complete.vim | 6 ++++++ src/version.c | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/misc1.c b/src/misc1.c index 2d635d677f..726500a4c8 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -10761,6 +10761,7 @@ expand_in_path( char_u *curdir; garray_T path_ga; char_u *paths = NULL; + int glob_flags = 0; if ((curdir = alloc((unsigned)MAXPATHL)) == NULL) return 0; @@ -10777,7 +10778,11 @@ expand_in_path( if (paths == NULL) return 0; - globpath(paths, pattern, gap, (flags & EW_ICASE) ? WILD_ICASE : 0); + if (flags & EW_ICASE) + glob_flags |= WILD_ICASE; + if (flags & EW_ADDSLASH) + glob_flags |= WILD_ADD_SLASH; + globpath(paths, pattern, gap, glob_flags); vim_free(paths); return gap->ga_len; diff --git a/src/testdir/test_find_complete.vim b/src/testdir/test_find_complete.vim index 4732109ed0..a7bc135d47 100644 --- a/src/testdir/test_find_complete.vim +++ b/src/testdir/test_find_complete.vim @@ -86,6 +86,12 @@ func Test_find_complete() call feedkeys(":find f\t\n", "xt") call assert_equal('Holy Grail', getline(1)) + " Test that find completion on directory appends a slash + call feedkeys(":find in/pa\tfile.txt\n", "xt") + call assert_equal('E.T.', getline(1)) + call feedkeys(":find ./i\tstuff.txt\n", "xt") + call assert_equal('Another Holy Grail', getline(1)) + " Test shortening of " " foo/x/bar/voyager.txt diff --git a/src/version.c b/src/version.c index af192797f7..811d521054 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1464, /**/ 1463, /**/ From 4bc0bed53695ac67db8d601f2a15e48e7a196688 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 3 Feb 2018 22:35:40 +0100 Subject: [PATCH 03/11] patch 8.0.1465: python2 and python3 detection not tested Problem: Python2 and python3 detection not tested. (Matej Cepl) Solution: Add test for detecting python2 and python3. Also detect a script using "js" as javascript. --- runtime/scripts.vim | 2 +- src/testdir/test_filetype.vim | 5 ++++- src/version.c | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/runtime/scripts.vim b/runtime/scripts.vim index fe05d265b3..e271db89dc 100644 --- a/runtime/scripts.vim +++ b/runtime/scripts.vim @@ -137,7 +137,7 @@ if s:line1 =~# "^#!" set ft=ruby " JavaScript - elseif s:name =~# 'node\(js\)\=\>' || s:name =~# 'rhino\>' + elseif s:name =~# 'node\(js\)\=\>\|js\>' || s:name =~# 'rhino\>' set ft=javascript " BC calculator diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index ccf8016839..62dbc7473f 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -561,10 +561,13 @@ let s:script_checks = { \ 'perl6': [['#!/path/perl6']], \ 'perl': [['#!/path/perl']], \ 'php': [['#!/path/php']], - \ 'python': [['#!/path/python']], + \ 'python': [['#!/path/python'], + \ ['#!/path/python2'], + \ ['#!/path/python3']], \ 'groovy': [['#!/path/groovy']], \ 'ruby': [['#!/path/ruby']], \ 'javascript': [['#!/path/node'], + \ ['#!/path/js'], \ ['#!/path/nodejs'], \ ['#!/path/rhino']], \ 'bc': [['#!/path/bc']], diff --git a/src/version.c b/src/version.c index 811d521054..352d491bfa 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1465, /**/ 1464, /**/ From 06b77ef69f252e1ba8a2136dcbed6622bc2371bb Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 4 Feb 2018 14:32:57 +0100 Subject: [PATCH 04/11] patch 8.0.1466: older GTK versions don't have gtk_entry_get_text_length() Problem: Older GTK versions don't have gtk_entry_get_text_length(). Solution: Add a function with #ifdefs to take care of GTK version differences. (Kazunobu Kuriyama, closes #2605) --- src/gui_gtk.c | 34 ++++++++++++++++++++++++++++++++-- src/version.c | 2 ++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/gui_gtk.c b/src/gui_gtk.c index c1b0479749..7ae9cbfdb1 100644 --- a/src/gui_gtk.c +++ b/src/gui_gtk.c @@ -2144,6 +2144,37 @@ convert_localized_message(char_u **buffer, const char *message) return (const char *)*buffer; } +/* + * Returns the number of characters in GtkEntry. + */ + static unsigned long +entry_get_text_length(GtkEntry *entry) +{ + g_return_val_if_fail(entry != NULL, 0); + g_return_val_if_fail(GTK_IS_ENTRY(entry) == TRUE, 0); + +#if GTK_CHECK_VERSION(2,18,0) + /* 2.18 introduced a new object GtkEntryBuffer to handle text data for + * GtkEntry instead of letting each instance of the latter have its own + * storage for that. The code below is almost identical to the + * implementation of gtk_entry_get_text_length() for the versions >= 2.18. + */ + return gtk_entry_buffer_get_length(gtk_entry_get_buffer(entry)); +#elif GTK_CHECK_VERSION(2,14,0) + /* 2.14 introduced a new function to avoid memory management bugs which can + * happen when gtk_entry_get_text() is used without due care and attention. + */ + return gtk_entry_get_text_length(entry); +#else + /* gtk_entry_get_text() returns the pointer to the storage allocated + * internally by the widget. Accordingly, use the one with great care: + * Don't free it nor modify the contents it points to; call the function + * every time you need the pointer since its value may have been changed + * by the widget. */ + return g_utf8_strlen(gtk_entry_get_text(entry), -1); +#endif +} + static void find_replace_dialog_create(char_u *arg, int do_replace) { @@ -2198,10 +2229,9 @@ find_replace_dialog_create(char_u *arg, int do_replace) * For :promptrepl dialog, give it to 'with' entry if 'what' has an * non-empty entry; otherwise, to 'what' entry. */ gtk_widget_grab_focus(frdp->what); - if (do_replace && gtk_entry_get_text_length(GTK_ENTRY(frdp->what))) + if (do_replace && entry_get_text_length(GTK_ENTRY(frdp->what)) > 0) gtk_widget_grab_focus(frdp->with); - vim_free(entry_text); return; } diff --git a/src/version.c b/src/version.c index 352d491bfa..bac652b616 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1466, /**/ 1465, /**/ From fef4ddd5eb8816a6607a624aa401bcfa71a63def Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 4 Feb 2018 14:49:57 +0100 Subject: [PATCH 05/11] patch 8.0.1467: libvterm doesn't handle illegal byte sequence correctly Problem: Libvterm doesn't handle illegal byte sequence correctly. Solution: After the invalid code check if there is space to store another character. Allocate one more character. (zhykzhykzhyk, closes #2614, closes #2613) --- src/libvterm/src/encoding.c | 8 +++++--- src/libvterm/src/state.c | 5 +++-- src/version.c | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libvterm/src/encoding.c b/src/libvterm/src/encoding.c index b37a08c3f1..43216e24a6 100644 --- a/src/libvterm/src/encoding.c +++ b/src/libvterm/src/encoding.c @@ -46,14 +46,16 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_, return; else if(c >= 0x20 && c < 0x7f) { - if(data->bytes_remaining) + if(data->bytes_remaining) { + data->bytes_remaining = 0; cp[(*cpi)++] = UNICODE_INVALID; - + if (*cpi >= cplen) + break; + } cp[(*cpi)++] = c; #ifdef DEBUG_PRINT_UTF8 printf(" UTF-8 char: U+%04x\n", c); #endif - data->bytes_remaining = 0; } else if(c == 0x7f) /* DEL */ diff --git a/src/libvterm/src/state.c b/src/libvterm/src/state.c index 5a6feacb1b..32dabeb348 100644 --- a/src/libvterm/src/state.c +++ b/src/libvterm/src/state.c @@ -248,8 +248,9 @@ static int on_text(const char bytes[], size_t len, void *user) VTermPos oldpos = state->pos; - /* We'll have at most len codepoints */ - codepoints = vterm_allocator_malloc(state->vt, len * sizeof(uint32_t)); + /* We'll have at most len codepoints, plus one from a previous incomplete + * sequence. */ + codepoints = vterm_allocator_malloc(state->vt, (len + 1) * sizeof(uint32_t)); encoding = state->gsingle_set ? &state->encoding[state->gsingle_set] : diff --git a/src/version.c b/src/version.c index bac652b616..767a348235 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1467, /**/ 1466, /**/ From 191f18bad0b5c48afa05c3e8a00f3ced993f6a38 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 4 Feb 2018 16:38:47 +0100 Subject: [PATCH 06/11] patch 8.0.1468: illegal memory access in del_bytes() Problem: Illegal memory access in del_bytes(). Solution: Check for negative byte count. (Christian Brabandt, closes #2466) --- src/message.c | 6 +++--- src/misc1.c | 17 +++++++++++++---- src/version.c | 2 ++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/message.c b/src/message.c index 211403384a..17a6633523 100644 --- a/src/message.c +++ b/src/message.c @@ -761,7 +761,7 @@ emsgn(char_u *s, long n) void iemsg(char_u *s) { - msg(s); + emsg(s); #ifdef ABORT_ON_INTERNAL_ERROR abort(); #endif @@ -4993,7 +4993,7 @@ vim_vsnprintf_typval( zero_padding = 0; } else - { + { /* Regular float number */ format[0] = '%'; l = 1; @@ -5016,7 +5016,7 @@ vim_vsnprintf_typval( format[l + 1] = NUL; str_arg_l = sprintf(tmp, format, f); - } + } if (remove_trailing_zeroes) { diff --git a/src/misc1.c b/src/misc1.c index 726500a4c8..593dce1c3d 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -2457,7 +2457,7 @@ del_chars(long count, int fixpos) * If "fixpos" is TRUE, don't leave the cursor on the NUL after the line. * Caller must have prepared for undo. * - * return FAIL for failure, OK otherwise + * Return FAIL for failure, OK otherwise. */ int del_bytes( @@ -2476,12 +2476,21 @@ del_bytes( oldp = ml_get(lnum); oldlen = (int)STRLEN(oldp); - /* - * Can't do anything when the cursor is on the NUL after the line. - */ + /* Can't do anything when the cursor is on the NUL after the line. */ if (col >= oldlen) return FAIL; + /* If "count" is zero there is nothing to do. */ + if (count == 0) + return OK; + + /* If "count" is negative the caller must be doing something wrong. */ + if (count < 1) + { + IEMSGN("E950: Invalid count for del_bytes(): %ld", count); + return FAIL; + } + #ifdef FEAT_MBYTE /* If 'delcombine' is set and deleting (less than) one character, only * delete the last combining character. */ diff --git a/src/version.c b/src/version.c index 767a348235..e4a4b51f8d 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1468, /**/ 1467, /**/ From 2374faae111057ee28e8d487f9a52a95855e2206 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 4 Feb 2018 17:47:42 +0100 Subject: [PATCH 07/11] patch 8.0.1469: when package path is a symlink 'runtimepath' is wrong Problem: When package path is a symlink adding it to 'runtimepath' happens at the end. Solution: Do not resolve symlinks before locating the position in 'runtimepath'. (Ozaki Kiichi, closes #2604) --- src/ex_cmds2.c | 245 +++++++++++++++++++---------------- src/testdir/test_packadd.vim | 51 +++++++- src/version.c | 2 + 3 files changed, 182 insertions(+), 116 deletions(-) diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 1475ef25db..73fe0194be 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -3567,13 +3567,11 @@ source_all_matches(char_u *pat) } } -/* used for "cookie" of add_pack_plugin() */ -static int APP_ADD_DIR; -static int APP_LOAD; -static int APP_BOTH; - - static void -add_pack_plugin(char_u *fname, void *cookie) +/* + * Add the package directory to 'runtimepath'. + */ + static int +add_pack_dir_to_rtp(char_u *fname) { char_u *p4, *p3, *p2, *p1, *p; char_u *insp; @@ -3582,125 +3580,154 @@ add_pack_plugin(char_u *fname, void *cookie) int keep; size_t oldlen; size_t addlen; - char_u *afterdir; + char_u *afterdir = NULL; size_t afterlen = 0; - char_u *ffname = fix_fname(fname); + char_u *ffname = NULL; size_t fname_len; char_u *buf = NULL; char_u *rtp_ffname; int match; + int retval = FAIL; + p4 = p3 = p2 = p1 = get_past_head(fname); + for (p = p1; *p; MB_PTR_ADV(p)) + if (vim_ispathsep_nocolon(*p)) + { + p4 = p3; p3 = p2; p2 = p1; p1 = p; + } + + /* now we have: + * rtp/pack/name/start/name + * p4 p3 p2 p1 + * + * find the part up to "pack" in 'runtimepath' */ + c = *++p4; /* append pathsep in order to expand symlink */ + *p4 = NUL; + ffname = fix_fname(fname); + *p4 = c; if (ffname == NULL) - return; - if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)ffname) == NULL) + return FAIL; + + /* Find "ffname" in "p_rtp", ignoring '/' vs '\' differences. */ + fname_len = STRLEN(ffname); + insp = p_rtp; + buf = alloc(MAXPATHL); + if (buf == NULL) + goto theend; + while (*insp != NUL) { - /* directory is not yet in 'runtimepath', add it */ - p4 = p3 = p2 = p1 = get_past_head(ffname); - for (p = p1; *p; MB_PTR_ADV(p)) - if (vim_ispathsep_nocolon(*p)) - { - p4 = p3; p3 = p2; p2 = p1; p1 = p; - } - - /* now we have: - * rtp/pack/name/start/name - * p4 p3 p2 p1 - * - * find the part up to "pack" in 'runtimepath' */ - c = *p4; - *p4 = NUL; - - /* Find "ffname" in "p_rtp", ignoring '/' vs '\' differences. */ - fname_len = STRLEN(ffname); - insp = p_rtp; - buf = alloc(MAXPATHL); - if (buf == NULL) + copy_option_part(&insp, buf, MAXPATHL, ","); + add_pathsep(buf); + rtp_ffname = fix_fname(buf); + if (rtp_ffname == NULL) goto theend; - while (*insp != NUL) - { - copy_option_part(&insp, buf, MAXPATHL, ","); - add_pathsep(buf); - rtp_ffname = fix_fname(buf); - if (rtp_ffname == NULL) - goto theend; - match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0; - vim_free(rtp_ffname); - if (match) - break; - } - - if (*insp == NUL) - /* not found, append at the end */ - insp = p_rtp + STRLEN(p_rtp); - else - /* append after the matching directory. */ - --insp; - *p4 = c; - - /* check if rtp/pack/name/start/name/after exists */ - afterdir = concat_fnames(ffname, (char_u *)"after", TRUE); - if (afterdir != NULL && mch_isdir(afterdir)) - afterlen = STRLEN(afterdir) + 1; /* add one for comma */ - - oldlen = STRLEN(p_rtp); - addlen = STRLEN(ffname) + 1; /* add one for comma */ - new_rtp = alloc((int)(oldlen + addlen + afterlen + 1)); - /* add one for NUL */ - if (new_rtp == NULL) - goto theend; - keep = (int)(insp - p_rtp); - mch_memmove(new_rtp, p_rtp, keep); - new_rtp[keep] = ','; - mch_memmove(new_rtp + keep + 1, ffname, addlen); - if (p_rtp[keep] != NUL) - mch_memmove(new_rtp + keep + addlen, p_rtp + keep, - oldlen - keep + 1); - if (afterlen > 0) - { - STRCAT(new_rtp, ","); - STRCAT(new_rtp, afterdir); - } - set_option_value((char_u *)"rtp", 0L, new_rtp, 0); - vim_free(new_rtp); - vim_free(afterdir); + match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0; + vim_free(rtp_ffname); + if (match) + break; } - if (cookie != &APP_ADD_DIR) + if (*insp == NUL) + /* not found, append at the end */ + insp = p_rtp + STRLEN(p_rtp); + else + /* append after the matching directory. */ + --insp; + + /* check if rtp/pack/name/start/name/after exists */ + afterdir = concat_fnames(fname, (char_u *)"after", TRUE); + if (afterdir != NULL && mch_isdir(afterdir)) + afterlen = STRLEN(afterdir) + 1; /* add one for comma */ + + oldlen = STRLEN(p_rtp); + addlen = STRLEN(fname) + 1; /* add one for comma */ + new_rtp = alloc((int)(oldlen + addlen + afterlen + 1)); + /* add one for NUL */ + if (new_rtp == NULL) + goto theend; + keep = (int)(insp - p_rtp); + mch_memmove(new_rtp, p_rtp, keep); + new_rtp[keep] = ','; + mch_memmove(new_rtp + keep + 1, fname, addlen); + if (p_rtp[keep] != NUL) + mch_memmove(new_rtp + keep + addlen, p_rtp + keep, oldlen - keep + 1); + if (afterlen > 0) { - static char *plugpat = "%s/plugin/**/*.vim"; - static char *ftpat = "%s/ftdetect/*.vim"; - int len; - char_u *pat; - - len = (int)STRLEN(ffname) + (int)STRLEN(ftpat); - pat = alloc(len); - if (pat == NULL) - goto theend; - vim_snprintf((char *)pat, len, plugpat, ffname); - source_all_matches(pat); - -#ifdef FEAT_AUTOCMD - { - char_u *cmd = vim_strsave((char_u *)"g:did_load_filetypes"); - - /* If runtime/filetype.vim wasn't loaded yet, the scripts will be - * found when it loads. */ - if (cmd != NULL && eval_to_number(cmd) > 0) - { - do_cmdline_cmd((char_u *)"augroup filetypedetect"); - vim_snprintf((char *)pat, len, ftpat, ffname); - source_all_matches(pat); - do_cmdline_cmd((char_u *)"augroup END"); - } - vim_free(cmd); - } -#endif - vim_free(pat); + STRCAT(new_rtp, ","); + STRCAT(new_rtp, afterdir); } + set_option_value((char_u *)"rtp", 0L, new_rtp, 0); + vim_free(new_rtp); + retval = OK; theend: vim_free(buf); vim_free(ffname); + vim_free(afterdir); + return retval; +} + +/* + * Load scripts in "plugin" and "ftdetect" directories of the package. + */ + static int +load_pack_plugin(char_u *fname) +{ + static char *plugpat = "%s/plugin/**/*.vim"; + static char *ftpat = "%s/ftdetect/*.vim"; + int len; + char_u *ffname = fix_fname(fname); + char_u *pat = NULL; + int retval = FAIL; + + if (ffname == NULL) + return FAIL; + len = (int)STRLEN(ffname) + (int)STRLEN(ftpat); + pat = alloc(len); + if (pat == NULL) + goto theend; + vim_snprintf((char *)pat, len, plugpat, ffname); + source_all_matches(pat); + +#ifdef FEAT_AUTOCMD + { + char_u *cmd = vim_strsave((char_u *)"g:did_load_filetypes"); + + /* If runtime/filetype.vim wasn't loaded yet, the scripts will be + * found when it loads. */ + if (cmd != NULL && eval_to_number(cmd) > 0) + { + do_cmdline_cmd((char_u *)"augroup filetypedetect"); + vim_snprintf((char *)pat, len, ftpat, ffname); + source_all_matches(pat); + do_cmdline_cmd((char_u *)"augroup END"); + } + vim_free(cmd); + } +#endif + vim_free(pat); + retval = OK; + +theend: + vim_free(ffname); + return retval; +} + +/* used for "cookie" of add_pack_plugin() */ +static int APP_ADD_DIR; +static int APP_LOAD; +static int APP_BOTH; + + static void +add_pack_plugin(char_u *fname, void *cookie) +{ + if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)fname) == NULL) + /* directory is not yet in 'runtimepath', add it */ + if (add_pack_dir_to_rtp(fname) == FAIL) + return; + + if (cookie != &APP_ADD_DIR) + load_pack_plugin(fname); } /* diff --git a/src/testdir/test_packadd.vim b/src/testdir/test_packadd.vim index 09b9b82f55..889d77f414 100644 --- a/src/testdir/test_packadd.vim +++ b/src/testdir/test_packadd.vim @@ -37,8 +37,8 @@ func Test_packadd() call assert_equal(77, g:plugin_also_works) call assert_equal(17, g:ftdetect_works) call assert_true(len(&rtp) > len(rtp)) - call assert_true(&rtp =~ '/testdir/Xdir/pack/mine/opt/mytest\($\|,\)') - call assert_true(&rtp =~ '/testdir/Xdir/pack/mine/opt/mytest/after$') + call assert_match('/testdir/Xdir/pack/mine/opt/mytest\($\|,\)', &rtp) + call assert_match('/testdir/Xdir/pack/mine/opt/mytest/after$', &rtp) " Check exception call assert_fails("packadd directorynotfound", 'E919:') @@ -60,7 +60,7 @@ func Test_packadd_start() call assert_equal(24, g:plugin_works) call assert_true(len(&rtp) > len(rtp)) - call assert_true(&rtp =~ '/testdir/Xdir/pack/mine/start/other\($\|,\)') + call assert_match('/testdir/Xdir/pack/mine/start/other\($\|,\)', &rtp) endfunc func Test_packadd_noload() @@ -77,7 +77,7 @@ func Test_packadd_noload() packadd! mytest call assert_true(len(&rtp) > len(rtp)) - call assert_true(&rtp =~ 'testdir/Xdir/pack/mine/opt/mytest\($\|,\)') + call assert_match('testdir/Xdir/pack/mine/opt/mytest\($\|,\)', &rtp) call assert_equal(0, g:plugin_works) " check the path is not added twice @@ -108,7 +108,7 @@ func Test_packadd_symlink_dir() packadd mytest " Must have been inserted in the middle, not at the end - call assert_true(&rtp =~ '/pack/mine/opt/mytest,') + call assert_match('/pack/mine/opt/mytest,', &rtp) call assert_equal(44, g:plugin_works) " No change when doing it again. @@ -121,6 +121,43 @@ func Test_packadd_symlink_dir() exec "silent !rm" top2_dir endfunc +func Test_packadd_symlink_dir2() + if !has('unix') + return + endif + let top2_dir = s:topdir . '/Xdir2' + let real_dir = s:topdir . '/Xsym/pack' + call mkdir(top2_dir, 'p') + call mkdir(real_dir, 'p') + let &rtp = top2_dir . ',' . top2_dir . '/after' + let &packpath = &rtp + + exec "silent !ln -s ../Xsym/pack" top2_dir . '/pack' + let s:plugdir = top2_dir . '/pack/mine/opt/mytest' + call mkdir(s:plugdir . '/plugin', 'p') + + exe 'split ' . s:plugdir . '/plugin/test.vim' + call setline(1, 'let g:plugin_works = 48') + wq + let g:plugin_works = 0 + + packadd mytest + + " Must have been inserted in the middle, not at the end + call assert_match('/Xdir2/pack/mine/opt/mytest,', &rtp) + call assert_equal(48, g:plugin_works) + + " No change when doing it again. + let rtp_before = &rtp + packadd mytest + call assert_equal(rtp_before, &rtp) + + set rtp& + let rtp = &rtp + exec "silent !rm" top2_dir . '/pack' + exec "silent !rmdir" top2_dir +endfunc + " Check command-line completion for 'packadd' func Test_packadd_completion() let optdir1 = &packpath . '/pack/mine/opt' @@ -196,9 +233,9 @@ func Test_helptags() helptags ALL let tags1 = readfile(docdir1 . '/tags') - call assert_true(tags1[0] =~ 'look-here') + call assert_match('look-here', tags1[0]) let tags2 = readfile(docdir2 . '/tags') - call assert_true(tags2[0] =~ 'look-away') + call assert_match('look-away', tags2[0]) endfunc func Test_colorscheme() diff --git a/src/version.c b/src/version.c index e4a4b51f8d..5786860a5b 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1469, /**/ 1468, /**/ From 2c7b906afb86b986476cfc959732e433b1b4a3b1 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 4 Feb 2018 18:22:46 +0100 Subject: [PATCH 08/11] patch 8.0.1470: integer overflow when using regexp pattern Problem: Integer overflow when using regexp pattern. (geeknik) Solution: Use a long instead of int. (Christian Brabandt, closes #2251) --- src/regexp_nfa.c | 27 +++++++++++++++++---------- src/version.c | 2 ++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index afd42383cf..43fe5dc4d4 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -1600,7 +1600,7 @@ nfa_regatom(void) default: { - int n = 0; + long n = 0; int cmp = c; if (c == '<' || c == '>') @@ -1628,7 +1628,14 @@ nfa_regatom(void) /* \%{n}v \%{n}v */ EMIT(cmp == '<' ? NFA_VCOL_LT : cmp == '>' ? NFA_VCOL_GT : NFA_VCOL); - EMIT(n); +#if VIM_SIZEOF_INT < VIM_SIZEOF_LONG + if (n > INT_MAX) + { + EMSG(_("E951: \\% value too large")); + return FAIL; + } +#endif + EMIT((int)n); break; } else if (c == '\'' && n == 0) @@ -3970,7 +3977,7 @@ static int nfa_match; #ifdef FEAT_RELTIME static proftime_T *nfa_time_limit; static int *nfa_timed_out; -static int nfa_time_count; +static int nfa_time_count; #endif static void copy_pim(nfa_pim_T *to, nfa_pim_T *from); @@ -4068,10 +4075,10 @@ copy_ze_off(regsub_T *to, regsub_T *from) if (REG_MULTI) { if (from->list.multi[0].end_lnum >= 0) - { + { to->list.multi[0].end_lnum = from->list.multi[0].end_lnum; to->list.multi[0].end_col = from->list.multi[0].end_col; - } + } } else { @@ -5124,9 +5131,9 @@ recursive_regmatch( } if (state->c == NFA_START_INVISIBLE_BEFORE - || state->c == NFA_START_INVISIBLE_BEFORE_FIRST - || state->c == NFA_START_INVISIBLE_BEFORE_NEG - || state->c == NFA_START_INVISIBLE_BEFORE_NEG_FIRST) + || state->c == NFA_START_INVISIBLE_BEFORE_FIRST + || state->c == NFA_START_INVISIBLE_BEFORE_NEG + || state->c == NFA_START_INVISIBLE_BEFORE_NEG_FIRST) { /* The recursive match must end at the current position. When "pim" is * not NULL it specifies the current position. */ @@ -6302,7 +6309,7 @@ nfa_regmatch( } } else if (state->c < 0 ? check_char_class(state->c, curc) - : (curc == state->c + : (curc == state->c || (rex.reg_ic && MB_TOLOWER(curc) == MB_TOLOWER(state->c)))) { @@ -6863,7 +6870,7 @@ nfa_regmatch( && (REG_MULTI ? (reglnum < nfa_endp->se_u.pos.lnum || (reglnum == nfa_endp->se_u.pos.lnum - && (int)(reginput - regline) + && (int)(reginput - regline) < nfa_endp->se_u.pos.col)) : reginput < nfa_endp->se_u.ptr)))) { diff --git a/src/version.c b/src/version.c index 5786860a5b..5d417029be 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1470, /**/ 1469, /**/ From 28944fecff3c40b44325921d45aaf67451b0937f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 4 Feb 2018 19:01:31 +0100 Subject: [PATCH 09/11] patch 8.0.1471: on MS-Windows CursorIM highlighting no longer works Problem: On MS-Windows CursorIM highlighting no longer works. Solution: Adjust #if statements. (Ken Takata) --- src/gui.c | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui.c b/src/gui.c index c9d00a6b70..691153a7a8 100644 --- a/src/gui.c +++ b/src/gui.c @@ -1137,13 +1137,13 @@ gui_update_cursor( if (id > 0) { cattr = syn_id2colors(id, &cfg, &cbg); -#if defined(FEAT_XIM) || defined(FEAT_HANGULIN) +#if defined(FEAT_MBYTE) || defined(FEAT_HANGULIN) { static int iid; guicolor_T fg, bg; if ( -# if defined(FEAT_GUI_GTK) && !defined(FEAT_HANGULIN) +# if defined(FEAT_GUI_GTK) && defined(FEAT_XIM) && !defined(FEAT_HANGULIN) preedit_get_status() # else im_get_status() diff --git a/src/version.c b/src/version.c index 5d417029be..df15d1117d 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1471, /**/ 1470, /**/ From 5d4247402b7195c6872485ddf1600a1cea723027 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 4 Feb 2018 19:11:30 +0100 Subject: [PATCH 10/11] patch 8.0.1472: MS-Windows: nsis installer is a bit slow Problem: MS-Windows: nsis installer is a bit slow. Solution: Use ReserveFile for vimrc.ini. (closes #2522) --- nsis/gvim.nsi | 15 +++++++++------ src/version.c | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/nsis/gvim.nsi b/nsis/gvim.nsi index 871ce673a9..a1820f449f 100644 --- a/nsis/gvim.nsi +++ b/nsis/gvim.nsi @@ -89,6 +89,11 @@ Page instfiles UninstPage uninstConfirm UninstPage instfiles +# Reserve files +# Needed for showing the _vimrc setting page faster. +ReserveFile /plugin InstallOptions.dll +ReserveFile vimrc.ini + ########################################################## # Functions @@ -475,14 +480,12 @@ Function SetCustom # Display the InstallOptions dialog # Check if a _vimrc should be created - SectionGetFlags ${sec_vimrc_id} $0 - IntOp $0 $0 & 1 - StrCmp $0 "1" +2 0 + SectionGetFlags ${sec_vimrc_id} $3 + IntOp $3 $3 & 1 + StrCmp $3 "1" +2 0 Abort - Push $3 - InstallOptions::dialog "$PLUGINSDIR\vimrc.ini" - Pop $3 + InstallOptions::dialog "$PLUGINSDIR\vimrc.ini" Pop $3 FunctionEnd diff --git a/src/version.c b/src/version.c index df15d1117d..5c4e17ba9c 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1472, /**/ 1471, /**/ From 511ffdd65d48b0597ed10614d161b5e811342058 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 4 Feb 2018 19:37:40 +0100 Subject: [PATCH 11/11] patch 8.0.1473: MS-Windows: D&D fails between 32 and 64 bit apps Problem: MS-Windows: D&D fails between 32 and 64 bit apps. Solution: Add the /HIGHENTROPYVA:NO linker option. (Ken Takata, closes #2504) --- src/Make_mvc.mak | 7 +++++++ src/version.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak index b496e5a5c2..c2e808c954 100644 --- a/src/Make_mvc.mak +++ b/src/Make_mvc.mak @@ -1179,6 +1179,13 @@ LINKARGS1 = $(LINKARGS1) /LTCG:STATUS !endif !endif +!if $(MSVC_MAJOR) >= 11 && "$(CPU)" == "AMD64" && "$(GUI)" == "yes" +# This option is required for VC2012 or later so that 64-bit gvim can +# accept D&D from 32-bit applications. NOTE: This disables 64-bit ASLR, +# therefore the security level becomes as same as VC2010. +LINKARGS1 = $(LINKARGS1) /HIGHENTROPYVA:NO +!endif + all: $(VIM).exe \ vimrun.exe \ install.exe \ diff --git a/src/version.c b/src/version.c index 5c4e17ba9c..8f34303999 100644 --- a/src/version.c +++ b/src/version.c @@ -771,6 +771,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1473, /**/ 1472, /**/