Hi Bram and list,
How to reproduce:
- Start naked Vim with some options.
$ vim -Nu NONE --cmd "set enc=cp932 tenc=utf8" -c "set nf+=alpha"
- Enter insert mode and type 山1 and leave insert mode.
i山1<Esc>
- Cursor move to top of line and type <C-A> in normal mode.
0<C-A>
Expected behavior:
- The following string is displayed.
山2
Actual behavior:
- There is generating garbled.
S1
I wrote a patch.
Please include this.
--
Best regards,
Hirohito Higashi (a.k.a. h_east)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ops.c b/src/ops.c
index d97107e..9e86b75 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -5488,11 +5488,23 @@ do_addsub(
{
if (dobin)
while (col > 0 && vim_isbdigit(ptr[col]))
+ {
--col;
+#ifdef FEAT_MBYTE
+ if (has_mbyte)
+ col -= (*mb_head_off)(ptr, ptr + col);
+#endif
+ }
if (dohex)
while (col > 0 && vim_isxdigit(ptr[col]))
+ {
--col;
+#ifdef FEAT_MBYTE
+ if (has_mbyte)
+ col -= (*mb_head_off)(ptr, ptr + col);
+#endif
+ }
if ( dobin
&& dohex
@@ -5500,6 +5512,10 @@ do_addsub(
&& (ptr[col] == 'X'
|| ptr[col] == 'x')
&& ptr[col - 1] == '0'
+#ifdef FEAT_MBYTE
+ && (!has_mbyte ||
+ !(*mb_head_off)(ptr, ptr + col - 1))
+#endif
&& vim_isxdigit(ptr[col + 1]))))
{
@@ -5508,7 +5524,13 @@ do_addsub(
col = pos->col;
while (col > 0 && vim_isdigit(ptr[col]))
+ {
col--;
+#ifdef FEAT_MBYTE
+ if (has_mbyte)
+ col -= (*mb_head_off)(ptr, ptr + col);
+#endif
+ }
}
if (( dohex
@@ -5516,16 +5538,28 @@ do_addsub(
&& (ptr[col] == 'X'
|| ptr[col] == 'x')
&& ptr[col - 1] == '0'
+#ifdef FEAT_MBYTE
+ && (!has_mbyte ||
+ !(*mb_head_off)(ptr, ptr + col - 1))
+#endif
&& vim_isxdigit(ptr[col + 1])) ||
( dobin
&& col > 0
&& (ptr[col] == 'B'
|| ptr[col] == 'b')
&& ptr[col - 1] == '0'
+#ifdef FEAT_MBYTE
+ && (!has_mbyte ||
+ !(*mb_head_off)(ptr, ptr + col - 1))
+#endif
&& vim_isbdigit(ptr[col + 1])))
{
/* Found hexadecimal or binary number, move to its start. */
--col;
+#ifdef FEAT_MBYTE
+ if (has_mbyte)
+ col -= (*mb_head_off)(ptr, ptr + col);
+#endif
}
else
{
@@ -5537,12 +5571,18 @@ do_addsub(
while (ptr[col] != NUL
&& !vim_isdigit(ptr[col])
&& !(doalp && ASCII_ISALPHA(ptr[col])))
- ++col;
+ col += MB_PTR2LEN(ptr + col);
while (col > 0
&& vim_isdigit(ptr[col - 1])
&& !(doalp && ASCII_ISALPHA(ptr[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])
&& !(doalp && ASCII_ISALPHA(ptr[col])))
{
- ++col;
- --length;
+ int mb_len = MB_PTR2LEN(ptr + col);
+
+ col += mb_len;
+ length -= mb_len;
}
if (length == 0)
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;
was_positive = FALSE;
@@ -5622,7 +5669,12 @@ do_addsub(
}
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 */
--col;