Skip to content

Commit 0410900

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 783f281 + d1bc96c commit 0410900

File tree

18 files changed

+299
-75
lines changed

18 files changed

+299
-75
lines changed

Filelist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ SRC_ALL = \
136136
src/testdir/bench*.vim \
137137
src/testdir/samples/*.txt \
138138
src/testdir/if_ver*.vim \
139+
src/testdir/xterm_ramp.vim \
139140
src/proto.h \
140141
src/proto/arabic.pro \
141142
src/proto/blowfish.pro \

src/edit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8216,7 +8216,7 @@ in_cinkeys(
82168216
{
82178217
/* "0=word": Check if there are only blanks before the
82188218
* word. */
8219-
if (getwhitecols(line) !=
8219+
if (getwhitecols_curline() !=
82208220
(int)(curwin->w_cursor.col - (p - look)))
82218221
match = FALSE;
82228222
}

src/ex_docmd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10321,6 +10321,9 @@ ex_startinsert(exarg_T *eap)
1032110321
{
1032210322
if (eap->forceit)
1032310323
{
10324+
/* cursor line can be zero on startup */
10325+
if (!curwin->w_cursor.lnum)
10326+
curwin->w_cursor.lnum = 1;
1032410327
coladvance((colnr_T)MAXCOL);
1032510328
curwin->w_curswant = MAXCOL;
1032610329
curwin->w_set_curswant = FALSE;

src/gui_w32.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4384,7 +4384,7 @@ add_dialog_element(
43844384
WORD clss,
43854385
const char *caption);
43864386
static LPWORD lpwAlign(LPWORD);
4387-
static int nCopyAnsiToWideChar(LPWORD, LPSTR);
4387+
static int nCopyAnsiToWideChar(LPWORD, LPSTR, BOOL);
43884388
#if defined(FEAT_MENU) && defined(FEAT_TEAROFF)
43894389
static void gui_mch_tearoff(char_u *title, vimmenu_T *menu, int initX, int initY);
43904390
#endif
@@ -7284,9 +7284,8 @@ gui_mch_dialog(
72847284
add_word(0); // Class
72857285

72867286
/* copy the title of the dialog */
7287-
nchar = nCopyAnsiToWideChar(p, (title ?
7288-
(LPSTR)title :
7289-
(LPSTR)("Vim "VIM_VERSION_MEDIUM)));
7287+
nchar = nCopyAnsiToWideChar(p, (title ? (LPSTR)title
7288+
: (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE);
72907289
p += nchar;
72917290

72927291
if (s_usenewlook)
@@ -7298,13 +7297,13 @@ gui_mch_dialog(
72987297
/* point size */
72997298
*p++ = -MulDiv(lfSysmenu.lfHeight, 72,
73007299
GetDeviceCaps(hdc, LOGPIXELSY));
7301-
nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName));
7300+
nchar = nCopyAnsiToWideChar(p, lfSysmenu.lfFaceName, FALSE);
73027301
}
73037302
else
73047303
#endif
73057304
{
73067305
*p++ = DLG_FONT_POINT_SIZE; // point size
7307-
nchar = nCopyAnsiToWideChar(p, TEXT(DLG_FONT_NAME));
7306+
nchar = nCopyAnsiToWideChar(p, DLG_FONT_NAME, FALSE);
73087307
}
73097308
p += nchar;
73107309
}
@@ -7485,7 +7484,7 @@ add_dialog_element(
74857484
*p++ = (WORD)0xffff;
74867485
*p++ = clss; //2 more here
74877486

7488-
nchar = nCopyAnsiToWideChar(p, (LPSTR)caption); //strlen(caption)+1
7487+
nchar = nCopyAnsiToWideChar(p, (LPSTR)caption, TRUE); //strlen(caption)+1
74897488
p += nchar;
74907489

74917490
*p++ = 0; // advance pointer over nExtraStuff WORD - 2 more
@@ -7517,19 +7516,21 @@ lpwAlign(
75177516
* parameter as wide character (16-bits / char) string, and returns integer
75187517
* number of wide characters (words) in string (including the trailing wide
75197518
* char NULL). Partly taken from the Win32SDK samples.
7520-
*/
7519+
* If "use_enc" is TRUE, 'encoding' is used for "lpAnsiIn". If FALSE, current
7520+
* ACP is used for "lpAnsiIn". */
75217521
static int
75227522
nCopyAnsiToWideChar(
75237523
LPWORD lpWCStr,
7524-
LPSTR lpAnsiIn)
7524+
LPSTR lpAnsiIn,
7525+
BOOL use_enc)
75257526
{
75267527
int nChar = 0;
75277528
#ifdef FEAT_MBYTE
75287529
int len = lstrlen(lpAnsiIn) + 1; /* include NUL character */
75297530
int i;
75307531
WCHAR *wn;
75317532

7532-
if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
7533+
if (use_enc && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
75337534
{
75347535
/* Not a codepage, use our own conversion function. */
75357536
wn = enc_to_utf16((char_u *)lpAnsiIn, NULL);
@@ -7852,8 +7853,8 @@ gui_mch_tearoff(
78527853

78537854
/* copy the title of the dialog */
78547855
nchar = nCopyAnsiToWideChar(p, ((*title)
7855-
? (LPSTR)title
7856-
: (LPSTR)("Vim "VIM_VERSION_MEDIUM)));
7856+
? (LPSTR)title
7857+
: (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE);
78577858
p += nchar;
78587859

78597860
if (s_usenewlook)
@@ -7865,13 +7866,13 @@ gui_mch_tearoff(
78657866
/* point size */
78667867
*p++ = -MulDiv(lfSysmenu.lfHeight, 72,
78677868
GetDeviceCaps(hdc, LOGPIXELSY));
7868-
nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName));
7869+
nchar = nCopyAnsiToWideChar(p, lfSysmenu.lfFaceName, FALSE);
78697870
}
78707871
else
78717872
#endif
78727873
{
78737874
*p++ = DLG_FONT_POINT_SIZE; // point size
7874-
nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME));
7875+
nchar = nCopyAnsiToWideChar(p, DLG_FONT_NAME, FALSE);
78757876
}
78767877
p += nchar;
78777878
}

src/if_ruby.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ static int ensure_ruby_initialized(void)
891891
#ifdef RUBY19_OR_LATER
892892
{
893893
int dummy_argc = 2;
894-
char *dummy_argv[] = {"vim-ruby", "-e0"};
894+
char *dummy_argv[] = {"vim-ruby", "-e_=0"};
895895
ruby_options(dummy_argc, dummy_argv);
896896
}
897897
ruby_script("vim-ruby");

src/libvterm/src/pen.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ static const VTermColor ansi_colors[] = {
2525
};
2626

2727
static int ramp6[] = {
28-
0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF,
28+
0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF,
2929
};
3030

31+
/* Use 0x81 instead of 0x80 to be able to distinguish from ansi black */
3132
static int ramp24[] = {
32-
0x00, 0x0B, 0x16, 0x21, 0x2C, 0x37, 0x42, 0x4D, 0x58, 0x63, 0x6E, 0x79,
33-
0x85, 0x90, 0x9B, 0xA6, 0xB1, 0xBC, 0xC7, 0xD2, 0xDD, 0xE8, 0xF3, 0xFF,
33+
0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76,
34+
0x81, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE,
3435
};
3536

3637
static int lookup_colour_ansi(const VTermState *state, long index, VTermColor *col)

src/main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,6 +2648,21 @@ check_tty(mparm_T *parmp)
26482648
#if defined(WIN3264) && !defined(FEAT_GUI_W32)
26492649
if (is_cygpty_used())
26502650
{
2651+
# if defined(FEAT_MBYTE) && defined(HAVE_BIND_TEXTDOMAIN_CODESET) \
2652+
&& defined(FEAT_GETTEXT)
2653+
char *s, *tofree = NULL;
2654+
2655+
/* Set the encoding of the error message based on $LC_ALL or
2656+
* other environment variables instead of 'encoding'.
2657+
* Note that the message is shown on a Cygwin terminal (e.g.
2658+
* mintty) which encoding is based on $LC_ALL or etc., not the
2659+
* current codepage used by normal Win32 console programs. */
2660+
tofree = s = enc_locale_env(NULL);
2661+
if (s == NULL)
2662+
s = "utf-8"; /* Use "utf-8" by default. */
2663+
(void)bind_textdomain_codeset(VIMPACKAGE, s);
2664+
vim_free(tofree);
2665+
# endif
26512666
mch_errmsg(_("Vim: Error: This version of Vim does not run in a Cygwin terminal\n"));
26522667
exit(1);
26532668
}

src/mbyte.c

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4385,45 +4385,31 @@ enc_alias_search(char_u *name)
43854385

43864386
#if defined(FEAT_MBYTE) || defined(PROTO)
43874387

4388-
#ifdef HAVE_LANGINFO_H
4389-
# include <langinfo.h>
4390-
#endif
4388+
# ifdef HAVE_LANGINFO_H
4389+
# include <langinfo.h>
4390+
# endif
43914391

4392+
# ifndef FEAT_GUI_W32
43924393
/*
4393-
* Get the canonicalized encoding of the current locale.
4394+
* Get the canonicalized encoding from the specified locale string "locale"
4395+
* or from the environment variables LC_ALL, LC_CTYPE and LANG.
43944396
* Returns an allocated string when successful, NULL when not.
43954397
*/
43964398
char_u *
4397-
enc_locale(void)
4399+
enc_locale_env(char *locale)
43984400
{
4399-
#ifndef WIN3264
4400-
char *s;
4401+
char *s = locale;
44014402
char *p;
44024403
int i;
4403-
#endif
44044404
char buf[50];
4405-
#ifdef WIN3264
4406-
long acp = GetACP();
44074405

4408-
if (acp == 1200)
4409-
STRCPY(buf, "ucs-2le");
4410-
else if (acp == 1252) /* cp1252 is used as latin1 */
4411-
STRCPY(buf, "latin1");
4412-
else
4413-
sprintf(buf, "cp%ld", acp);
4414-
#else
4415-
# ifdef HAVE_NL_LANGINFO_CODESET
4416-
if ((s = nl_langinfo(CODESET)) == NULL || *s == NUL)
4417-
# endif
4418-
# if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
4419-
if ((s = setlocale(LC_CTYPE, NULL)) == NULL || *s == NUL)
4420-
# endif
4421-
if ((s = getenv("LC_ALL")) == NULL || *s == NUL)
4422-
if ((s = getenv("LC_CTYPE")) == NULL || *s == NUL)
4423-
s = getenv("LANG");
4406+
if (s == NULL || *s == NUL)
4407+
if ((s = getenv("LC_ALL")) == NULL || *s == NUL)
4408+
if ((s = getenv("LC_CTYPE")) == NULL || *s == NUL)
4409+
s = getenv("LANG");
44244410

44254411
if (s == NULL || *s == NUL)
4426-
return FAIL;
4412+
return NULL;
44274413

44284414
/* The most generic locale format is:
44294415
* language[_territory][.codeset][@modifier][+special][,[sponsor][_revision]]
@@ -4458,12 +4444,46 @@ enc_locale(void)
44584444
break;
44594445
}
44604446
buf[i] = NUL;
4461-
#endif
44624447

44634448
return enc_canonize((char_u *)buf);
44644449
}
4450+
# endif
4451+
4452+
/*
4453+
* Get the canonicalized encoding of the current locale.
4454+
* Returns an allocated string when successful, NULL when not.
4455+
*/
4456+
char_u *
4457+
enc_locale(void)
4458+
{
4459+
# ifdef WIN3264
4460+
char buf[50];
4461+
long acp = GetACP();
4462+
4463+
if (acp == 1200)
4464+
STRCPY(buf, "ucs-2le");
4465+
else if (acp == 1252) /* cp1252 is used as latin1 */
4466+
STRCPY(buf, "latin1");
4467+
else
4468+
sprintf(buf, "cp%ld", acp);
4469+
4470+
return enc_canonize((char_u *)buf);
4471+
# else
4472+
char *s;
4473+
4474+
# ifdef HAVE_NL_LANGINFO_CODESET
4475+
if ((s = nl_langinfo(CODESET)) == NULL || *s == NUL)
4476+
# endif
4477+
# if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
4478+
if ((s = setlocale(LC_CTYPE, NULL)) == NULL || *s == NUL)
4479+
# endif
4480+
s = NULL;
4481+
4482+
return enc_locale_env(s);
4483+
# endif
4484+
}
44654485

4466-
#if defined(WIN3264) || defined(PROTO) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD)
4486+
# if defined(WIN3264) || defined(PROTO) || defined(FEAT_CYGWIN_WIN32_CLIPBOARD)
44674487
/*
44684488
* Convert an encoding name to an MS-Windows codepage.
44694489
* Returns zero if no codepage can be figured out.
@@ -4490,7 +4510,7 @@ encname2codepage(char_u *name)
44904510
return cp;
44914511
return 0;
44924512
}
4493-
#endif
4513+
# endif
44944514

44954515
# if defined(USE_ICONV) || defined(PROTO)
44964516

src/proto/mbyte.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ int mb_lefthalve(int row, int col);
7171
int mb_fix_col(int col, int row);
7272
char_u *enc_skip(char_u *p);
7373
char_u *enc_canonize(char_u *enc);
74+
char_u *enc_locale_env(char *locale);
7475
char_u *enc_locale(void);
7576
int encname2codepage(char_u *name);
7677
void *my_iconv_open(char_u *to, char_u *from);

src/search.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4620,7 +4620,7 @@ current_quote(
46204620

46214621
#endif /* FEAT_TEXTOBJ */
46224622

4623-
static int is_one_char(char_u *pattern, int move, pos_T *cur);
4623+
static int is_one_char(char_u *pattern, int move, pos_T *cur, int direction);
46244624

46254625
/*
46264626
* Find next search match under cursor, cursor at end.
@@ -4641,6 +4641,7 @@ current_search(
46414641
int flags = 0;
46424642
pos_T save_VIsual = VIsual;
46434643
int one_char;
4644+
int direction = forward ? FORWARD : BACKWARD;
46444645

46454646
/* wrapping should not occur */
46464647
p_ws = FALSE;
@@ -4667,8 +4668,10 @@ current_search(
46674668
else
46684669
orig_pos = pos = curwin->w_cursor;
46694670

4670-
/* Is the pattern is zero-width? */
4671-
one_char = is_one_char(spats[last_idx].pat, TRUE, &curwin->w_cursor);
4671+
/* Is the pattern is zero-width?, this time, don't care about the direction
4672+
*/
4673+
one_char = is_one_char(spats[last_idx].pat, TRUE, &curwin->w_cursor,
4674+
FORWARD);
46724675
if (one_char == -1)
46734676
{
46744677
p_ws = old_p_ws;
@@ -4727,19 +4730,19 @@ current_search(
47274730
}
47284731

47294732
start_pos = pos;
4730-
flags = forward ? SEARCH_END : 0;
4733+
flags = forward ? SEARCH_END : SEARCH_START;
47314734

47324735
/* Check again from the current cursor position,
47334736
* since the next match might actually by only one char wide */
4734-
one_char = is_one_char(spats[last_idx].pat, FALSE, &pos);
4737+
one_char = is_one_char(spats[last_idx].pat, FALSE, &pos, direction);
47354738
if (one_char < 0)
47364739
/* search failed, abort */
47374740
return FAIL;
47384741

47394742
/* move to match, except for zero-width matches, in which case, we are
47404743
* already on the next match */
47414744
if (!one_char)
4742-
result = searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD),
4745+
result = searchit(curwin, curbuf, &pos, direction,
47434746
spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0,
47444747
NULL, NULL);
47454748

@@ -4788,10 +4791,11 @@ current_search(
47884791
* Check if the pattern is one character long or zero-width.
47894792
* If move is TRUE, check from the beginning of the buffer, else from position
47904793
* "cur".
4794+
* "direction" is FORWARD or BACKWARD.
47914795
* Returns TRUE, FALSE or -1 for failure.
47924796
*/
47934797
static int
4794-
is_one_char(char_u *pattern, int move, pos_T *cur)
4798+
is_one_char(char_u *pattern, int move, pos_T *cur, int direction)
47954799
{
47964800
regmmatch_T regmatch;
47974801
int nmatched = 0;
@@ -4821,7 +4825,7 @@ is_one_char(char_u *pattern, int move, pos_T *cur)
48214825
flag = SEARCH_START;
48224826
}
48234827

4824-
if (searchit(curwin, curbuf, &pos, FORWARD, pattern, 1,
4828+
if (searchit(curwin, curbuf, &pos, direction, pattern, 1,
48254829
SEARCH_KEEP + flag, RE_SEARCH, 0, NULL, NULL) != FAIL)
48264830
{
48274831
/* Zero-width pattern should match somewhere, then we can check if
@@ -4834,7 +4838,8 @@ is_one_char(char_u *pattern, int move, pos_T *cur)
48344838
pos.lnum, regmatch.startpos[0].col, NULL, NULL);
48354839
if (!nmatched)
48364840
break;
4837-
} while (regmatch.startpos[0].col < pos.col);
4841+
} while (direction == FORWARD ? regmatch.startpos[0].col < pos.col
4842+
: regmatch.startpos[0].col > pos.col);
48384843

48394844
if (!called_emsg)
48404845
{

0 commit comments

Comments
 (0)