Skip to content

Commit f8dd3eb

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 84ffb58 + fca6600 commit f8dd3eb

File tree

8 files changed

+41
-16
lines changed

8 files changed

+41
-16
lines changed

src/eval.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19791,7 +19791,7 @@ f_strcharpart(typval_T *argvars, typval_T *rettv)
1979119791
if (nchar > 0)
1979219792
while (nchar > 0 && nbyte < slen)
1979319793
{
19794-
nbyte += mb_char2len(p[nbyte]);
19794+
nbyte += mb_cptr2len(p + nbyte);
1979519795
--nchar;
1979619796
}
1979719797
else
@@ -19801,7 +19801,12 @@ f_strcharpart(typval_T *argvars, typval_T *rettv)
1980119801
charlen = get_tv_number(&argvars[2]);
1980219802
while (charlen > 0 && nbyte + len < slen)
1980319803
{
19804-
len += mb_char2len(p[nbyte + len]);
19804+
int off = nbyte + len;
19805+
19806+
if (off < 0)
19807+
len += 1;
19808+
else
19809+
len += mb_cptr2len(p + off);
1980519810
--charlen;
1980619811
}
1980719812
}
@@ -20041,8 +20046,8 @@ f_synIDattr(typval_T *argvars UNUSED, typval_T *rettv)
2004120046
}
2004220047
else
2004320048
{
20044-
#ifdef FEAT_GUI
20045-
if (gui.in_use)
20049+
#if defined(FEAT_GUI) || defined(FEAT_TERMTRUECOLOR)
20050+
if (USE_24BIT)
2004620051
modec = 'g';
2004720052
else
2004820053
#endif

src/ex_cmds2.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,8 @@ do_debug(char_u *cmd)
335335
get_maxbacktrace_level(void)
336336
{
337337
char *p, *q;
338-
int maxbacktrace = 1;
338+
int maxbacktrace = 0;
339339

340-
maxbacktrace = 0;
341340
if (sourcing_name != NULL)
342341
{
343342
p = (char *)sourcing_name;

src/json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,6 @@ json_decode_string(js_read_T *reader, typval_T *res)
539539
char_u *p;
540540
int c;
541541
long nr;
542-
char_u buf[NUMBUFLEN];
543542

544543
if (res != NULL)
545544
ga_init2(&ga, 1, 200);
@@ -617,6 +616,7 @@ json_decode_string(js_read_T *reader, typval_T *res)
617616
if (res != NULL)
618617
{
619618
#ifdef FEAT_MBYTE
619+
char_u buf[NUMBUFLEN];
620620
buf[utf_char2bytes((int)nr, buf)] = NUL;
621621
ga_concat(&ga, buf);
622622
#else

src/misc1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ open_line(
11971197
int i;
11981198
int l;
11991199

1200-
for (i = 0; p[i] != NUL && i < lead_len; i += l)
1200+
for (i = 0; i < lead_len && p[i] != NUL; i += l)
12011201
{
12021202
l = (*mb_ptr2len)(p + i);
12031203
if (vim_strnsize(p, i + l) > repl_size)

src/ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5709,7 +5709,7 @@ do_addsub(
57095709
if (buf1 == NULL)
57105710
goto theend;
57115711
ptr = buf1;
5712-
if (negative && (!visual || (visual && was_positive)))
5712+
if (negative && (!visual || was_positive))
57135713
{
57145714
*ptr++ = '-';
57155715
}

src/regexp_nfa.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5515,14 +5515,9 @@ nfa_regmatch(
55155515
int add_off = 0;
55165516
int toplevel = start->c == NFA_MOPEN;
55175517
#ifdef NFA_REGEXP_DEBUG_LOG
5518-
FILE *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a");
5519-
5520-
if (debug == NULL)
5521-
{
5522-
EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG);
5523-
return FALSE;
5524-
}
5518+
FILE *debug;
55255519
#endif
5520+
55265521
/* Some patterns may take a long time to match, especially when using
55275522
* recursive_regmatch(). Allow interrupting them with CTRL-C. */
55285523
fast_breakcheck();
@@ -5533,6 +5528,14 @@ nfa_regmatch(
55335528
return FALSE;
55345529
#endif
55355530

5531+
#ifdef NFA_REGEXP_DEBUG_LOG
5532+
debug = fopen(NFA_REGEXP_DEBUG_LOG, "a");
5533+
if (debug == NULL)
5534+
{
5535+
EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG);
5536+
return FALSE;
5537+
}
5538+
#endif
55365539
nfa_match = FALSE;
55375540

55385541
/* Allocate memory for the lists of nodes. */

src/testdir/test_expr_utf8.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ func Test_strcharpart()
2323
call assert_equal('á', strcharpart('áxb', 0, 1))
2424
call assert_equal('x', strcharpart('áxb', 1, 1))
2525

26+
call assert_equal('いうeお', strcharpart('あいうeお', 1))
27+
call assert_equal('', strcharpart('あいうeお', 1, 1))
28+
call assert_equal('いう', strcharpart('あいうeお', 1, 2))
29+
call assert_equal('いうe', strcharpart('あいうeお', 1, 3))
30+
call assert_equal('いうeお', strcharpart('あいうeお', 1, 4))
31+
call assert_equal('eお', strcharpart('あいうeお', 3))
32+
call assert_equal('e', strcharpart('あいうeお', 3, 1))
33+
34+
call assert_equal('', strcharpart('あいうeお', -3, 4))
35+
2636
call assert_equal('a', strcharpart('àxb', 0, 1))
2737
call assert_equal('̀', strcharpart('àxb', 1, 1))
2838
call assert_equal('x', strcharpart('àxb', 2, 1))

src/version.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,14 @@ static char *(features[]) =
768768

769769
static int included_patches[] =
770770
{ /* Add new patch number below this line */
771+
/**/
772+
1782,
773+
/**/
774+
1781,
775+
/**/
776+
1780,
777+
/**/
778+
1779,
771779
/**/
772780
1778,
773781
/**/

0 commit comments

Comments
 (0)