Skip to content

Commit 07dd3d0

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 94ffaff + 511ffdd commit 07dd3d0

16 files changed

Lines changed: 309 additions & 147 deletions

nsis/gvim.nsi

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ Page instfiles
8989
UninstPage uninstConfirm
9090
UninstPage instfiles
9191

92+
# Reserve files
93+
# Needed for showing the _vimrc setting page faster.
94+
ReserveFile /plugin InstallOptions.dll
95+
ReserveFile vimrc.ini
96+
9297
##########################################################
9398
# Functions
9499

@@ -475,14 +480,12 @@ Function SetCustom
475480
# Display the InstallOptions dialog
476481

477482
# Check if a _vimrc should be created
478-
SectionGetFlags ${sec_vimrc_id} $0
479-
IntOp $0 $0 & 1
480-
StrCmp $0 "1" +2 0
483+
SectionGetFlags ${sec_vimrc_id} $3
484+
IntOp $3 $3 & 1
485+
StrCmp $3 "1" +2 0
481486
Abort
482487

483-
Push $3
484-
InstallOptions::dialog "$PLUGINSDIR\vimrc.ini"
485-
Pop $3
488+
InstallOptions::dialog "$PLUGINSDIR\vimrc.ini"
486489
Pop $3
487490
FunctionEnd
488491

runtime/scripts.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ if s:line1 =~# "^#!"
137137
set ft=ruby
138138

139139
" JavaScript
140-
elseif s:name =~# 'node\(js\)\=\>' || s:name =~# 'rhino\>'
140+
elseif s:name =~# 'node\(js\)\=\>\|js\>' || s:name =~# 'rhino\>'
141141
set ft=javascript
142142

143143
" BC calculator

src/Make_mvc.mak

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,13 @@ LINKARGS1 = $(LINKARGS1) /LTCG:STATUS
11791179
!endif
11801180
!endif
11811181

1182+
!if $(MSVC_MAJOR) >= 11 && "$(CPU)" == "AMD64" && "$(GUI)" == "yes"
1183+
# This option is required for VC2012 or later so that 64-bit gvim can
1184+
# accept D&D from 32-bit applications. NOTE: This disables 64-bit ASLR,
1185+
# therefore the security level becomes as same as VC2010.
1186+
LINKARGS1 = $(LINKARGS1) /HIGHENTROPYVA:NO
1187+
!endif
1188+
11821189
all: $(VIM).exe \
11831190
vimrun.exe \
11841191
install.exe \

src/ex_cmds2.c

Lines changed: 132 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,13 +3640,11 @@ source_all_matches(char_u *pat)
36403640
}
36413641
}
36423642

3643-
/* used for "cookie" of add_pack_plugin() */
3644-
static int APP_ADD_DIR;
3645-
static int APP_LOAD;
3646-
static int APP_BOTH;
3647-
3648-
static void
3649-
add_pack_plugin(char_u *fname, void *cookie)
3643+
/*
3644+
* Add the package directory to 'runtimepath'.
3645+
*/
3646+
static int
3647+
add_pack_dir_to_rtp(char_u *fname)
36503648
{
36513649
char_u *p4, *p3, *p2, *p1, *p;
36523650
char_u *insp;
@@ -3655,125 +3653,154 @@ add_pack_plugin(char_u *fname, void *cookie)
36553653
int keep;
36563654
size_t oldlen;
36573655
size_t addlen;
3658-
char_u *afterdir;
3656+
char_u *afterdir = NULL;
36593657
size_t afterlen = 0;
3660-
char_u *ffname = fix_fname(fname);
3658+
char_u *ffname = NULL;
36613659
size_t fname_len;
36623660
char_u *buf = NULL;
36633661
char_u *rtp_ffname;
36643662
int match;
3663+
int retval = FAIL;
36653664

3666-
if (ffname == NULL)
3667-
return;
3668-
if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)ffname) == NULL)
3669-
{
3670-
/* directory is not yet in 'runtimepath', add it */
3671-
p4 = p3 = p2 = p1 = get_past_head(ffname);
3672-
for (p = p1; *p; MB_PTR_ADV(p))
3673-
if (vim_ispathsep_nocolon(*p))
3674-
{
3675-
p4 = p3; p3 = p2; p2 = p1; p1 = p;
3676-
}
3677-
3678-
/* now we have:
3679-
* rtp/pack/name/start/name
3680-
* p4 p3 p2 p1
3681-
*
3682-
* find the part up to "pack" in 'runtimepath' */
3683-
c = *p4;
3684-
*p4 = NUL;
3685-
3686-
/* Find "ffname" in "p_rtp", ignoring '/' vs '\' differences. */
3687-
fname_len = STRLEN(ffname);
3688-
insp = p_rtp;
3689-
buf = alloc(MAXPATHL);
3690-
if (buf == NULL)
3691-
goto theend;
3692-
while (*insp != NUL)
3665+
p4 = p3 = p2 = p1 = get_past_head(fname);
3666+
for (p = p1; *p; MB_PTR_ADV(p))
3667+
if (vim_ispathsep_nocolon(*p))
36933668
{
3694-
copy_option_part(&insp, buf, MAXPATHL, ",");
3695-
add_pathsep(buf);
3696-
rtp_ffname = fix_fname(buf);
3697-
if (rtp_ffname == NULL)
3698-
goto theend;
3699-
match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
3700-
vim_free(rtp_ffname);
3701-
if (match)
3702-
break;
3669+
p4 = p3; p3 = p2; p2 = p1; p1 = p;
37033670
}
37043671

3705-
if (*insp == NUL)
3706-
/* not found, append at the end */
3707-
insp = p_rtp + STRLEN(p_rtp);
3708-
else
3709-
/* append after the matching directory. */
3710-
--insp;
3711-
*p4 = c;
3712-
3713-
/* check if rtp/pack/name/start/name/after exists */
3714-
afterdir = concat_fnames(ffname, (char_u *)"after", TRUE);
3715-
if (afterdir != NULL && mch_isdir(afterdir))
3716-
afterlen = STRLEN(afterdir) + 1; /* add one for comma */
3717-
3718-
oldlen = STRLEN(p_rtp);
3719-
addlen = STRLEN(ffname) + 1; /* add one for comma */
3720-
new_rtp = alloc((int)(oldlen + addlen + afterlen + 1));
3721-
/* add one for NUL */
3722-
if (new_rtp == NULL)
3672+
/* now we have:
3673+
* rtp/pack/name/start/name
3674+
* p4 p3 p2 p1
3675+
*
3676+
* find the part up to "pack" in 'runtimepath' */
3677+
c = *++p4; /* append pathsep in order to expand symlink */
3678+
*p4 = NUL;
3679+
ffname = fix_fname(fname);
3680+
*p4 = c;
3681+
if (ffname == NULL)
3682+
return FAIL;
3683+
3684+
/* Find "ffname" in "p_rtp", ignoring '/' vs '\' differences. */
3685+
fname_len = STRLEN(ffname);
3686+
insp = p_rtp;
3687+
buf = alloc(MAXPATHL);
3688+
if (buf == NULL)
3689+
goto theend;
3690+
while (*insp != NUL)
3691+
{
3692+
copy_option_part(&insp, buf, MAXPATHL, ",");
3693+
add_pathsep(buf);
3694+
rtp_ffname = fix_fname(buf);
3695+
if (rtp_ffname == NULL)
37233696
goto theend;
3724-
keep = (int)(insp - p_rtp);
3725-
mch_memmove(new_rtp, p_rtp, keep);
3726-
new_rtp[keep] = ',';
3727-
mch_memmove(new_rtp + keep + 1, ffname, addlen);
3728-
if (p_rtp[keep] != NUL)
3729-
mch_memmove(new_rtp + keep + addlen, p_rtp + keep,
3730-
oldlen - keep + 1);
3731-
if (afterlen > 0)
3732-
{
3733-
STRCAT(new_rtp, ",");
3734-
STRCAT(new_rtp, afterdir);
3735-
}
3736-
set_option_value((char_u *)"rtp", 0L, new_rtp, 0);
3737-
vim_free(new_rtp);
3738-
vim_free(afterdir);
3697+
match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
3698+
vim_free(rtp_ffname);
3699+
if (match)
3700+
break;
37393701
}
37403702

3741-
if (cookie != &APP_ADD_DIR)
3742-
{
3743-
static char *plugpat = "%s/plugin/**/*.vim";
3744-
static char *ftpat = "%s/ftdetect/*.vim";
3745-
int len;
3746-
char_u *pat;
3703+
if (*insp == NUL)
3704+
/* not found, append at the end */
3705+
insp = p_rtp + STRLEN(p_rtp);
3706+
else
3707+
/* append after the matching directory. */
3708+
--insp;
3709+
3710+
/* check if rtp/pack/name/start/name/after exists */
3711+
afterdir = concat_fnames(fname, (char_u *)"after", TRUE);
3712+
if (afterdir != NULL && mch_isdir(afterdir))
3713+
afterlen = STRLEN(afterdir) + 1; /* add one for comma */
3714+
3715+
oldlen = STRLEN(p_rtp);
3716+
addlen = STRLEN(fname) + 1; /* add one for comma */
3717+
new_rtp = alloc((int)(oldlen + addlen + afterlen + 1));
3718+
/* add one for NUL */
3719+
if (new_rtp == NULL)
3720+
goto theend;
3721+
keep = (int)(insp - p_rtp);
3722+
mch_memmove(new_rtp, p_rtp, keep);
3723+
new_rtp[keep] = ',';
3724+
mch_memmove(new_rtp + keep + 1, fname, addlen);
3725+
if (p_rtp[keep] != NUL)
3726+
mch_memmove(new_rtp + keep + addlen, p_rtp + keep, oldlen - keep + 1);
3727+
if (afterlen > 0)
3728+
{
3729+
STRCAT(new_rtp, ",");
3730+
STRCAT(new_rtp, afterdir);
3731+
}
3732+
set_option_value((char_u *)"rtp", 0L, new_rtp, 0);
3733+
vim_free(new_rtp);
3734+
retval = OK;
37473735

3748-
len = (int)STRLEN(ffname) + (int)STRLEN(ftpat);
3749-
pat = alloc(len);
3750-
if (pat == NULL)
3751-
goto theend;
3752-
vim_snprintf((char *)pat, len, plugpat, ffname);
3753-
source_all_matches(pat);
3736+
theend:
3737+
vim_free(buf);
3738+
vim_free(ffname);
3739+
vim_free(afterdir);
3740+
return retval;
3741+
}
3742+
3743+
/*
3744+
* Load scripts in "plugin" and "ftdetect" directories of the package.
3745+
*/
3746+
static int
3747+
load_pack_plugin(char_u *fname)
3748+
{
3749+
static char *plugpat = "%s/plugin/**/*.vim";
3750+
static char *ftpat = "%s/ftdetect/*.vim";
3751+
int len;
3752+
char_u *ffname = fix_fname(fname);
3753+
char_u *pat = NULL;
3754+
int retval = FAIL;
3755+
3756+
if (ffname == NULL)
3757+
return FAIL;
3758+
len = (int)STRLEN(ffname) + (int)STRLEN(ftpat);
3759+
pat = alloc(len);
3760+
if (pat == NULL)
3761+
goto theend;
3762+
vim_snprintf((char *)pat, len, plugpat, ffname);
3763+
source_all_matches(pat);
37543764

37553765
#ifdef FEAT_AUTOCMD
3756-
{
3757-
char_u *cmd = vim_strsave((char_u *)"g:did_load_filetypes");
3766+
{
3767+
char_u *cmd = vim_strsave((char_u *)"g:did_load_filetypes");
37583768

3759-
/* If runtime/filetype.vim wasn't loaded yet, the scripts will be
3760-
* found when it loads. */
3761-
if (cmd != NULL && eval_to_number(cmd) > 0)
3762-
{
3763-
do_cmdline_cmd((char_u *)"augroup filetypedetect");
3764-
vim_snprintf((char *)pat, len, ftpat, ffname);
3765-
source_all_matches(pat);
3766-
do_cmdline_cmd((char_u *)"augroup END");
3767-
}
3768-
vim_free(cmd);
3769+
/* If runtime/filetype.vim wasn't loaded yet, the scripts will be
3770+
* found when it loads. */
3771+
if (cmd != NULL && eval_to_number(cmd) > 0)
3772+
{
3773+
do_cmdline_cmd((char_u *)"augroup filetypedetect");
3774+
vim_snprintf((char *)pat, len, ftpat, ffname);
3775+
source_all_matches(pat);
3776+
do_cmdline_cmd((char_u *)"augroup END");
37693777
}
3770-
#endif
3771-
vim_free(pat);
3778+
vim_free(cmd);
37723779
}
3780+
#endif
3781+
vim_free(pat);
3782+
retval = OK;
37733783

37743784
theend:
3775-
vim_free(buf);
37763785
vim_free(ffname);
3786+
return retval;
3787+
}
3788+
3789+
/* used for "cookie" of add_pack_plugin() */
3790+
static int APP_ADD_DIR;
3791+
static int APP_LOAD;
3792+
static int APP_BOTH;
3793+
3794+
static void
3795+
add_pack_plugin(char_u *fname, void *cookie)
3796+
{
3797+
if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)fname) == NULL)
3798+
/* directory is not yet in 'runtimepath', add it */
3799+
if (add_pack_dir_to_rtp(fname) == FAIL)
3800+
return;
3801+
3802+
if (cookie != &APP_ADD_DIR)
3803+
load_pack_plugin(fname);
37773804
}
37783805

37793806
/*

src/gui.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,13 +1152,13 @@ gui_update_cursor(
11521152
if (id > 0)
11531153
{
11541154
cattr = syn_id2colors(id, &cfg, &cbg);
1155-
#if defined(FEAT_XIM) || defined(FEAT_HANGULIN)
1155+
#if defined(FEAT_MBYTE) || defined(FEAT_HANGULIN)
11561156
{
11571157
static int iid;
11581158
guicolor_T fg, bg;
11591159

11601160
if (
1161-
# if defined(FEAT_GUI_GTK) && !defined(FEAT_HANGULIN)
1161+
# if defined(FEAT_GUI_GTK) && defined(FEAT_XIM) && !defined(FEAT_HANGULIN)
11621162
preedit_get_status()
11631163
# else
11641164
im_get_status()

src/gui_gtk.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,6 +2144,37 @@ convert_localized_message(char_u **buffer, const char *message)
21442144
return (const char *)*buffer;
21452145
}
21462146

2147+
/*
2148+
* Returns the number of characters in GtkEntry.
2149+
*/
2150+
static unsigned long
2151+
entry_get_text_length(GtkEntry *entry)
2152+
{
2153+
g_return_val_if_fail(entry != NULL, 0);
2154+
g_return_val_if_fail(GTK_IS_ENTRY(entry) == TRUE, 0);
2155+
2156+
#if GTK_CHECK_VERSION(2,18,0)
2157+
/* 2.18 introduced a new object GtkEntryBuffer to handle text data for
2158+
* GtkEntry instead of letting each instance of the latter have its own
2159+
* storage for that. The code below is almost identical to the
2160+
* implementation of gtk_entry_get_text_length() for the versions >= 2.18.
2161+
*/
2162+
return gtk_entry_buffer_get_length(gtk_entry_get_buffer(entry));
2163+
#elif GTK_CHECK_VERSION(2,14,0)
2164+
/* 2.14 introduced a new function to avoid memory management bugs which can
2165+
* happen when gtk_entry_get_text() is used without due care and attention.
2166+
*/
2167+
return gtk_entry_get_text_length(entry);
2168+
#else
2169+
/* gtk_entry_get_text() returns the pointer to the storage allocated
2170+
* internally by the widget. Accordingly, use the one with great care:
2171+
* Don't free it nor modify the contents it points to; call the function
2172+
* every time you need the pointer since its value may have been changed
2173+
* by the widget. */
2174+
return g_utf8_strlen(gtk_entry_get_text(entry), -1);
2175+
#endif
2176+
}
2177+
21472178
static void
21482179
find_replace_dialog_create(char_u *arg, int do_replace)
21492180
{
@@ -2198,10 +2229,9 @@ find_replace_dialog_create(char_u *arg, int do_replace)
21982229
* For :promptrepl dialog, give it to 'with' entry if 'what' has an
21992230
* non-empty entry; otherwise, to 'what' entry. */
22002231
gtk_widget_grab_focus(frdp->what);
2201-
if (do_replace && gtk_entry_get_text_length(GTK_ENTRY(frdp->what)))
2232+
if (do_replace && entry_get_text_length(GTK_ENTRY(frdp->what)) > 0)
22022233
gtk_widget_grab_focus(frdp->with);
22032234

2204-
22052235
vim_free(entry_text);
22062236
return;
22072237
}

0 commit comments

Comments
 (0)