Skip to content

Commit ace9598

Browse files
committed
patch 8.0.0520: using a function pointer while the function is known
Problem: Using a function pointer instead of the actual function, which we know. Solution: Change mb_ functions to utf_ functions when already checked for Unicode. (Dominique Pelle, closes #1582)
1 parent 0c078fc commit ace9598

7 files changed

Lines changed: 21 additions & 19 deletions

File tree

src/message.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ trunc_string(
315315
for (;;)
316316
{
317317
do
318-
half = half - (*mb_head_off)(s, s + half - 1) - 1;
318+
half = half - utf_head_off(s, s + half - 1) - 1;
319319
while (half > 0 && utf_iscomposing(utf_ptr2char(s + half)));
320320
n = ptr2cells(s + half);
321321
if (len + n > room || half == 0)

src/misc2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,7 @@ vim_strchr(char_u *string, int c)
18741874
{
18751875
while (*p != NUL)
18761876
{
1877-
int l = (*mb_ptr2len)(p);
1877+
int l = utfc_ptr2len(p);
18781878

18791879
/* Avoid matching an illegal byte here. */
18801880
if (utf_ptr2char(p) == c && l > 1)

src/regexp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4732,7 +4732,7 @@ regmatch(
47324732
break;
47334733
}
47344734
if (enc_utf8)
4735-
opndc = mb_ptr2char(opnd);
4735+
opndc = utf_ptr2char(opnd);
47364736
if (enc_utf8 && utf_iscomposing(opndc))
47374737
{
47384738
/* When only a composing char is given match at any
@@ -4741,7 +4741,7 @@ regmatch(
47414741
for (i = 0; reginput[i] != NUL;
47424742
i += utf_ptr2len(reginput + i))
47434743
{
4744-
inpc = mb_ptr2char(reginput + i);
4744+
inpc = utf_ptr2char(reginput + i);
47454745
if (!utf_iscomposing(inpc))
47464746
{
47474747
if (i > 0)
@@ -4750,7 +4750,7 @@ regmatch(
47504750
else if (opndc == inpc)
47514751
{
47524752
/* Include all following composing chars. */
4753-
len = i + mb_ptr2len(reginput + i);
4753+
len = i + utfc_ptr2len(reginput + i);
47544754
status = RA_MATCH;
47554755
break;
47564756
}

src/regexp_nfa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@ nfa_regatom(void)
19741974
nfa_do_multibyte:
19751975
/* plen is length of current char with composing chars */
19761976
if (enc_utf8 && ((*mb_char2len)(c)
1977-
!= (plen = (*mb_ptr2len)(old_regparse))
1977+
!= (plen = utfc_ptr2len(old_regparse))
19781978
|| utf_iscomposing(c)))
19791979
{
19801980
int i = 0;

src/screen.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4119,7 +4119,7 @@ win_line(
41194119
c = c_extra;
41204120
#ifdef FEAT_MBYTE
41214121
mb_c = c; /* doesn't handle non-utf-8 multi-byte! */
4122-
if (enc_utf8 && (*mb_char2len)(c) > 1)
4122+
if (enc_utf8 && utf_char2len(c) > 1)
41234123
{
41244124
mb_utf8 = TRUE;
41254125
u8cc[0] = 0;
@@ -4140,7 +4140,7 @@ win_line(
41404140
{
41414141
/* If the UTF-8 character is more than one byte:
41424142
* Decode it into "mb_c". */
4143-
mb_l = (*mb_ptr2len)(p_extra);
4143+
mb_l = utfc_ptr2len(p_extra);
41444144
mb_utf8 = FALSE;
41454145
if (mb_l > n_extra)
41464146
mb_l = 1;
@@ -4219,7 +4219,7 @@ win_line(
42194219
{
42204220
/* If the UTF-8 character is more than one byte: Decode it
42214221
* into "mb_c". */
4222-
mb_l = (*mb_ptr2len)(ptr);
4222+
mb_l = utfc_ptr2len(ptr);
42234223
mb_utf8 = FALSE;
42244224
if (mb_l > 1)
42254225
{
@@ -4612,7 +4612,7 @@ win_line(
46124612
}
46134613
#ifdef FEAT_MBYTE
46144614
mb_c = c;
4615-
if (enc_utf8 && (*mb_char2len)(c) > 1)
4615+
if (enc_utf8 && utf_char2len(c) > 1)
46164616
{
46174617
mb_utf8 = TRUE;
46184618
u8cc[0] = 0;
@@ -4634,7 +4634,7 @@ win_line(
46344634
}
46354635
#ifdef FEAT_MBYTE
46364636
mb_c = c;
4637-
if (enc_utf8 && (*mb_char2len)(c) > 1)
4637+
if (enc_utf8 && utf_char2len(c) > 1)
46384638
{
46394639
mb_utf8 = TRUE;
46404640
u8cc[0] = 0;
@@ -4765,7 +4765,7 @@ win_line(
47654765
saved_attr2 = char_attr; /* save current attr */
47664766
#ifdef FEAT_MBYTE
47674767
mb_c = c;
4768-
if (enc_utf8 && (*mb_char2len)(c) > 1)
4768+
if (enc_utf8 && utf_char2len(c) > 1)
47694769
{
47704770
mb_utf8 = TRUE;
47714771
u8cc[0] = 0;
@@ -4839,7 +4839,7 @@ win_line(
48394839
}
48404840
#ifdef FEAT_MBYTE
48414841
mb_c = c;
4842-
if (enc_utf8 && (*mb_char2len)(c) > 1)
4842+
if (enc_utf8 && utf_char2len(c) > 1)
48434843
{
48444844
mb_utf8 = TRUE;
48454845
u8cc[0] = 0;
@@ -5003,7 +5003,7 @@ win_line(
50035003
}
50045004
# ifdef FEAT_MBYTE
50055005
mb_c = c;
5006-
if (enc_utf8 && (*mb_char2len)(c) > 1)
5006+
if (enc_utf8 && utf_char2len(c) > 1)
50075007
{
50085008
mb_utf8 = TRUE;
50095009
u8cc[0] = 0;
@@ -5110,7 +5110,7 @@ win_line(
51105110
extra_attr = HL_ATTR(HLF_AT);
51115111
}
51125112
mb_c = c;
5113-
if (enc_utf8 && (*mb_char2len)(c) > 1)
5113+
if (enc_utf8 && utf_char2len(c) > 1)
51145114
{
51155115
mb_utf8 = TRUE;
51165116
u8cc[0] = 0;
@@ -5383,7 +5383,7 @@ win_line(
53835383
char_attr = HL_ATTR(HLF_AT);
53845384
#ifdef FEAT_MBYTE
53855385
mb_c = c;
5386-
if (enc_utf8 && (*mb_char2len)(c) > 1)
5386+
if (enc_utf8 && utf_char2len(c) > 1)
53875387
{
53885388
mb_utf8 = TRUE;
53895389
u8cc[0] = 0;

src/spell.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ can_compound(slang_T *slang, char_u *word, char_u *flags)
12081208
/* Need to convert the single byte flags to utf8 characters. */
12091209
p = uflags;
12101210
for (i = 0; flags[i] != NUL; ++i)
1211-
p += mb_char2bytes(flags[i], p);
1211+
p += utf_char2bytes(flags[i], p);
12121212
*p = NUL;
12131213
p = uflags;
12141214
}
@@ -5117,11 +5117,11 @@ suggest_trie_walk(
51175117
* SCORE_SUBCOMP. */
51185118
if (enc_utf8
51195119
&& utf_iscomposing(
5120-
mb_ptr2char(tword
5120+
utf_ptr2char(tword
51215121
+ sp->ts_twordlen
51225122
- sp->ts_tcharlen))
51235123
&& utf_iscomposing(
5124-
mb_ptr2char(fword
5124+
utf_ptr2char(fword
51255125
+ sp->ts_fcharstart)))
51265126
sp->ts_score -=
51275127
SCORE_SUBST - SCORE_SUBCOMP;

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
520,
767769
/**/
768770
519,
769771
/**/

0 commit comments

Comments
 (0)