mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 7.4.1948
Problem: Using Ctrl-A with double-byte encoding may result in garbled text. Solution: Skip to the start of a character. (Hirohito Higashi)
This commit is contained in:
parent
ecefe71704
commit
ad5ca9bc1e
63
src/ops.c
63
src/ops.c
@ -5488,11 +5488,23 @@ do_addsub(
|
|||||||
{
|
{
|
||||||
if (dobin)
|
if (dobin)
|
||||||
while (col > 0 && vim_isbdigit(ptr[col]))
|
while (col > 0 && vim_isbdigit(ptr[col]))
|
||||||
|
{
|
||||||
--col;
|
--col;
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
if (has_mbyte)
|
||||||
|
col -= (*mb_head_off)(ptr, ptr + col);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (dohex)
|
if (dohex)
|
||||||
while (col > 0 && vim_isxdigit(ptr[col]))
|
while (col > 0 && vim_isxdigit(ptr[col]))
|
||||||
|
{
|
||||||
--col;
|
--col;
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
if (has_mbyte)
|
||||||
|
col -= (*mb_head_off)(ptr, ptr + col);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if ( dobin
|
if ( dobin
|
||||||
&& dohex
|
&& dohex
|
||||||
@ -5500,6 +5512,10 @@ do_addsub(
|
|||||||
&& (ptr[col] == 'X'
|
&& (ptr[col] == 'X'
|
||||||
|| ptr[col] == 'x')
|
|| ptr[col] == 'x')
|
||||||
&& ptr[col - 1] == '0'
|
&& ptr[col - 1] == '0'
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
&& (!has_mbyte ||
|
||||||
|
!(*mb_head_off)(ptr, ptr + col - 1))
|
||||||
|
#endif
|
||||||
&& vim_isxdigit(ptr[col + 1]))))
|
&& vim_isxdigit(ptr[col + 1]))))
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -5508,7 +5524,13 @@ do_addsub(
|
|||||||
col = pos->col;
|
col = pos->col;
|
||||||
|
|
||||||
while (col > 0 && vim_isdigit(ptr[col]))
|
while (col > 0 && vim_isdigit(ptr[col]))
|
||||||
|
{
|
||||||
col--;
|
col--;
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
if (has_mbyte)
|
||||||
|
col -= (*mb_head_off)(ptr, ptr + col);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( dohex
|
if (( dohex
|
||||||
@ -5516,16 +5538,28 @@ do_addsub(
|
|||||||
&& (ptr[col] == 'X'
|
&& (ptr[col] == 'X'
|
||||||
|| ptr[col] == 'x')
|
|| ptr[col] == 'x')
|
||||||
&& ptr[col - 1] == '0'
|
&& ptr[col - 1] == '0'
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
&& (!has_mbyte ||
|
||||||
|
!(*mb_head_off)(ptr, ptr + col - 1))
|
||||||
|
#endif
|
||||||
&& vim_isxdigit(ptr[col + 1])) ||
|
&& vim_isxdigit(ptr[col + 1])) ||
|
||||||
( dobin
|
( dobin
|
||||||
&& col > 0
|
&& col > 0
|
||||||
&& (ptr[col] == 'B'
|
&& (ptr[col] == 'B'
|
||||||
|| ptr[col] == 'b')
|
|| ptr[col] == 'b')
|
||||||
&& ptr[col - 1] == '0'
|
&& ptr[col - 1] == '0'
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
&& (!has_mbyte ||
|
||||||
|
!(*mb_head_off)(ptr, ptr + col - 1))
|
||||||
|
#endif
|
||||||
&& vim_isbdigit(ptr[col + 1])))
|
&& vim_isbdigit(ptr[col + 1])))
|
||||||
{
|
{
|
||||||
/* Found hexadecimal or binary number, move to its start. */
|
/* Found hexadecimal or binary number, move to its start. */
|
||||||
--col;
|
--col;
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
if (has_mbyte)
|
||||||
|
col -= (*mb_head_off)(ptr, ptr + col);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -5537,12 +5571,18 @@ do_addsub(
|
|||||||
while (ptr[col] != NUL
|
while (ptr[col] != NUL
|
||||||
&& !vim_isdigit(ptr[col])
|
&& !vim_isdigit(ptr[col])
|
||||||
&& !(doalp && ASCII_ISALPHA(ptr[col])))
|
&& !(doalp && ASCII_ISALPHA(ptr[col])))
|
||||||
++col;
|
col += MB_PTR2LEN(ptr + col);
|
||||||
|
|
||||||
while (col > 0
|
while (col > 0
|
||||||
&& vim_isdigit(ptr[col - 1])
|
&& vim_isdigit(ptr[col - 1])
|
||||||
&& !(doalp && ASCII_ISALPHA(ptr[col])))
|
&& !(doalp && ASCII_ISALPHA(ptr[col])))
|
||||||
|
{
|
||||||
--col;
|
--col;
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
if (has_mbyte)
|
||||||
|
col -= (*mb_head_off)(ptr, ptr + col);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5552,14 +5592,21 @@ do_addsub(
|
|||||||
&& !vim_isdigit(ptr[col])
|
&& !vim_isdigit(ptr[col])
|
||||||
&& !(doalp && ASCII_ISALPHA(ptr[col])))
|
&& !(doalp && ASCII_ISALPHA(ptr[col])))
|
||||||
{
|
{
|
||||||
++col;
|
int mb_len = MB_PTR2LEN(ptr + col);
|
||||||
--length;
|
|
||||||
|
col += mb_len;
|
||||||
|
length -= mb_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
goto theend;
|
goto theend;
|
||||||
|
|
||||||
if (col > pos->col && ptr[col - 1] == '-')
|
if (col > pos->col && ptr[col - 1] == '-'
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
&& (!has_mbyte ||
|
||||||
|
!(*mb_head_off)(ptr, ptr + col - 1))
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
negative = TRUE;
|
negative = TRUE;
|
||||||
was_positive = FALSE;
|
was_positive = FALSE;
|
||||||
@ -5622,7 +5669,12 @@ do_addsub(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (col > 0 && ptr[col - 1] == '-' && !visual)
|
if (col > 0 && ptr[col - 1] == '-'
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
&& (!has_mbyte ||
|
||||||
|
!(*mb_head_off)(ptr, ptr + col - 1))
|
||||||
|
#endif
|
||||||
|
&& !visual)
|
||||||
{
|
{
|
||||||
/* negative number */
|
/* negative number */
|
||||||
--col;
|
--col;
|
||||||
@ -6036,6 +6088,7 @@ handle_viminfo_register(garray_T *values, int force)
|
|||||||
&& (timestamp == 0 || y_ptr->y_time_set > timestamp))
|
&& (timestamp == 0 || y_ptr->y_time_set > timestamp))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (y_ptr->y_array != NULL)
|
||||||
for (i = 0; i < y_ptr->y_size; i++)
|
for (i = 0; i < y_ptr->y_size; i++)
|
||||||
vim_free(y_ptr->y_array[i]);
|
vim_free(y_ptr->y_array[i]);
|
||||||
vim_free(y_ptr->y_array);
|
vim_free(y_ptr->y_array);
|
||||||
|
@ -753,6 +753,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1948,
|
||||||
/**/
|
/**/
|
||||||
1947,
|
1947,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user