Patch 8.2.2933

15 views
Skip to first unread message

Bram Moolenaar

unread,
Jun 4, 2021, 11:23:55 AM6/4/21
to vim...@googlegroups.com

Patch 8.2.2933
Problem: When 'clipboard' is "unnamed" zp and zP do not work correctly.
Solution: Pass -1 to str_to_reg() and fix computing the character width
instead of using the byte length. (Christian Brabandt,
closes #8301, closes #8317)
Files: src/clipboard.c, src/mbyte.c, src/register.c


*** ../vim-8.2.2932/src/clipboard.c 2021-01-02 16:53:08.294010035 +0100
--- src/clipboard.c 2021-06-04 17:01:29.353519372 +0200
***************
*** 2090,2096 ****

clip_free_selection(cbd);

! str_to_reg(y_ptr, type, str, len, 0L, FALSE);
}

/*
--- 2090,2096 ----

clip_free_selection(cbd);

! str_to_reg(y_ptr, type, str, len, -1, FALSE);
}

/*
*** ../vim-8.2.2932/src/mbyte.c 2021-06-02 13:28:11.431120460 +0200
--- src/mbyte.c 2021-06-04 17:01:29.353519372 +0200
***************
*** 4308,4314 ****
return count;
}

- #if (defined(FEAT_SPELL) || defined(FEAT_EVAL)) || defined(PROTO)
/*
* Like mb_charlen() but for a string with specified length.
*/
--- 4308,4313 ----
***************
*** 4323,4329 ****

return count;
}
- #endif

/*
* Try to un-escape a multi-byte character.
--- 4322,4327 ----
*** ../vim-8.2.2932/src/register.c 2021-05-30 22:17:21.035457554 +0200
--- src/register.c 2021-06-04 17:01:29.353519372 +0200
***************
*** 2836,2841 ****
--- 2836,2842 ----
char_u **ss;
char_u **pp;
long maxlen;
+ int charlen;

if (y_ptr->y_array == NULL) // NULL means empty register
y_ptr->y_size = 0;
***************
*** 2894,2915 ****
{
for (ss = (char_u **) str; *ss != NULL; ++ss, ++lnum)
{
i = (long)STRLEN(*ss);
pp[lnum] = vim_strnsave(*ss, i);
! if (i > maxlen)
! maxlen = i;
}
}
else
{
for (start = 0; start < len + extraline; start += i + 1)
{
for (i = start; i < len; ++i) // find the end of the line
if (str[i] == '\n')
break;
i -= start; // i is now length of line
! if (i > maxlen)
! maxlen = i;
if (append)
{
--lnum;
--- 2895,2920 ----
{
for (ss = (char_u **) str; *ss != NULL; ++ss, ++lnum)
{
+ charlen = MB_CHARLEN(*ss);
i = (long)STRLEN(*ss);
pp[lnum] = vim_strnsave(*ss, i);
! if (charlen > maxlen)
! maxlen = charlen;
}
}
else
{
for (start = 0; start < len + extraline; start += i + 1)
{
+ charlen = 0;
for (i = start; i < len; ++i) // find the end of the line
if (str[i] == '\n')
break;
i -= start; // i is now length of line
! if (start < len)
! charlen = mb_charlen_len(str + start, i);
! if (charlen > maxlen)
! maxlen = charlen;
if (append)
{
--lnum;
*** ../vim-8.2.2932/src/version.c 2021-06-03 22:11:04.418516318 +0200
--- src/version.c 2021-06-04 17:10:27.524274273 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2933,
/**/

--
"Software is like sex... it's better when it's free."
-- Linus Torvalds, initiator of the free Linux OS
Makes me wonder what FSF stands for...?

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Bram Moolenaar

unread,
Jun 4, 2021, 12:18:41 PM6/4/21
to vim...@googlegroups.com, Bram Moolenaar

I wrote:

> Patch 8.2.2933
> Problem: When 'clipboard' is "unnamed" zp and zP do not work correctly.
> Solution: Pass -1 to str_to_reg() and fix computing the character width
> instead of using the byte length. (Christian Brabandt,
> closes #8301, closes #8317)
> Files: src/clipboard.c, src/mbyte.c, src/register.c

I thought the ASAN error was fixed, but apparently it isn't...

--
Lawmakers made it obligatory for everybody to take at least one bath
each week -- on Saturday night.
[real standing law in Vermont, United States of America]

Christian Brabandt

unread,
Jun 4, 2021, 12:25:38 PM6/4/21
to vim...@googlegroups.com

On Fr, 04 Jun 2021, Bram Moolenaar wrote:

>
> I wrote:
>
> > Patch 8.2.2933
> > Problem: When 'clipboard' is "unnamed" zp and zP do not work correctly.
> > Solution: Pass -1 to str_to_reg() and fix computing the character width
> > instead of using the byte length. (Christian Brabandt,
> > closes #8301, closes #8317)
> > Files: src/clipboard.c, src/mbyte.c, src/register.c
>
> I thought the ASAN error was fixed, but apparently it isn't...

No sorry, it wasn't but I still don't know what is causing this. BTW: it
might make sense to only call mb_charlen_len when we actually need to
calculate the width, not generally always.

Best,
Christian
--
Die ersten vierzig Jahre unseres Lebens liefern den Text, die
folgenden dreißig den Kommentar dazu.
-- Arthur Schopenhauer

Bram Moolenaar

unread,
Jun 4, 2021, 1:17:41 PM6/4/21
to vim...@googlegroups.com, Christian Brabandt

Christian wrote:

> > > Patch 8.2.2933
> > > Problem: When 'clipboard' is "unnamed" zp and zP do not work correctly.
> > > Solution: Pass -1 to str_to_reg() and fix computing the character width
> > > instead of using the byte length. (Christian Brabandt,
> > > closes #8301, closes #8317)
> > > Files: src/clipboard.c, src/mbyte.c, src/register.c
> >
> > I thought the ASAN error was fixed, but apparently it isn't...
>
> No sorry, it wasn't but I still don't know what is causing this. BTW: it
> might make sense to only call mb_charlen_len when we actually need to
> calculate the width, not generally always.

I managed to reproduce the error with valgrind using test_quotestar.
Instead of getting the length of the line, I used the length of each
character. Also fixed counting cells intead of characters. No more
ASAN error.

We could indeed check for MBLOCK to avoid overhead.

--
If you only have a hammer, you tend to see every problem as a nail.
If you only have MS-Windows, you tend to solve every problem by rebooting.

Christian Brabandt

unread,
Jun 4, 2021, 3:44:48 PM6/4/21
to vim...@googlegroups.com

On Fr, 04 Jun 2021, Bram Moolenaar wrote:

> I managed to reproduce the error with valgrind using test_quotestar.
> Instead of getting the length of the line, I used the length of each
> character. Also fixed counting cells intead of characters. No more
> ASAN error.
>
> We could indeed check for MBLOCK to avoid overhead.

Thanks for fixing up my mess :/

Best,
Christian
--
Heute sehen viele Mädchen aus wie Männer, die wie Mädchen aussehen.
-- John Wayne
Reply all
Reply to author
Forward
0 new messages