Patch 8.2.3748

20 views
Skip to first unread message

Bram Moolenaar

unread,
Dec 5, 2021, 2:11:06 PM12/5/21
to vim...@googlegroups.com

Patch 8.2.3748 (after 8.2.3747)
Problem: Giving an error for an empty sign argument breaks a plugin.
Solution: Do not give an error.
Files: src/sign.c, src/errors.h, src/testdir/test_signs.vim


*** ../vim-8.2.3747/src/sign.c 2021-12-05 17:45:46.235175728 +0000
--- src/sign.c 2021-12-05 19:07:41.775972281 +0000
***************
*** 1310,1326 ****
return lnum;
}

- static int
- check_empty_group(size_t len, char *name)
- {
- if (len == 0)
- {
- semsg(_(e_group_name_missing_for_str), name);
- return FAIL;
- }
- return OK;
- }
-
/*
* ":sign define {name} ..." command
*/
--- 1310,1315 ----
***************
*** 1335,1344 ****
char_u *texthl = NULL;
char_u *culhl = NULL;
int failed = FALSE;
- sign_T *sp_prev;
- int exists;
-
- exists = sign_find(sign_name, &sp_prev) != NULL;

// set values for a defined sign.
for (;;)
--- 1324,1329 ----
***************
*** 1360,1390 ****
else if (STRNCMP(arg, "linehl=", 7) == 0)
{
arg += 7;
- if (!exists && check_empty_group(p - arg, "linehl") == FAIL)
- {
- failed = TRUE;
- break;
- }
linehl = vim_strnsave(arg, p - arg);
}
else if (STRNCMP(arg, "texthl=", 7) == 0)
{
arg += 7;
- if (!exists && check_empty_group(p - arg, "texthl") == FAIL)
- {
- failed = TRUE;
- break;
- }
texthl = vim_strnsave(arg, p - arg);
}
else if (STRNCMP(arg, "culhl=", 6) == 0)
{
arg += 6;
- if (!exists && check_empty_group(p - arg, "culhl") == FAIL)
- {
- failed = TRUE;
- break;
- }
culhl = vim_strnsave(arg, p - arg);
}
else
--- 1345,1360 ----
*** ../vim-8.2.3747/src/errors.h 2021-12-05 13:02:47.028928408 +0000
--- src/errors.h 2021-12-05 19:05:16.428250263 +0000
***************
*** 694,698 ****
INIT(= N_("E1247: Line number out of range"));
EXTERN char e_closure_called_from_invalid_context[]
INIT(= N_("E1248: Closure called from invalid context"));
- EXTERN char e_group_name_missing_for_str[]
- INIT(= N_("E1249: Group name missing for %s"));
--- 694,696 ----
*** ../vim-8.2.3747/src/testdir/test_signs.vim 2021-12-05 17:45:46.235175728 +0000
--- src/testdir/test_signs.vim 2021-12-05 19:09:12.063798695 +0000
***************
*** 126,136 ****
call assert_fails("sign define Sign4 text= linehl=Comment", 'E239:')
call assert_fails("sign define Sign4 text=\\ ab linehl=Comment", 'E239:')

- " an empty highlight argument for a new sign is an error
- call assert_fails("sign define SignX linehl=", 'E1249: Group name missing for linehl')
- call assert_fails("sign define SignX culhl=", 'E1249: Group name missing for culhl')
- call assert_fails("sign define SignX texthl=", 'E1249: Group name missing for texthl')
-
" an empty highlight argument for an existing sign clears it
sign define SignY texthl=TextHl culhl=CulHl linehl=LineHl
let sl = sign_getdefined('SignY')[0]
--- 126,131 ----
*** ../vim-8.2.3747/src/version.c 2021-12-05 17:45:46.235175728 +0000
--- src/version.c 2021-12-05 19:06:15.836136890 +0000
***************
*** 755,756 ****
--- 755,758 ----
{ /* Add new patch number below this line */
+ /**/
+ 3748,
/**/

--
Imagine a world without hypothetical situations.

/// 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 ///

James McCoy

unread,
Dec 5, 2021, 2:57:22 PM12/5/21
to vim...@googlegroups.com
On Sun, Dec 05, 2021 at 07:11:00PM +0000, Bram Moolenaar wrote:
>
> Patch 8.2.3748 (after 8.2.3747)
> Problem: Giving an error for an empty sign argument breaks a plugin.
> Solution: Do not give an error.
> Files: src/sign.c, src/errors.h, src/testdir/test_signs.vim

Since the error has been reverted, the original issue reported in
https://github.com/vim/vim/pull/9280 still stands -- this creates a
highlight group with an empty string for a name. Should that be
addressed, as was proposed in the PR?

Cheers,
--
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7 2D23 DFE6 91AE 331B A3DB

Bram Moolenaar

unread,
Dec 5, 2021, 3:17:50 PM12/5/21
to vim...@googlegroups.com, James McCoy

James McCoy wrote:

> On Sun, Dec 05, 2021 at 07:11:00PM +0000, Bram Moolenaar wrote:
> >
> > Patch 8.2.3748 (after 8.2.3747)
> > Problem: Giving an error for an empty sign argument breaks a plugin.
> > Solution: Do not give an error.
> > Files: src/sign.c, src/errors.h, src/testdir/test_signs.vim
>
> Since the error has been reverted, the original issue reported in
> https://github.com/vim/vim/pull/9280 still stands -- this creates a
> highlight group with an empty string for a name. Should that be
> addressed, as was proposed in the PR?

It should not:

if (linehl != NULL)
{
if (*linehl == NUL)
sp->sn_line_hl = 0;
else
sp->sn_line_hl = syn_check_group(linehl, (int)STRLEN(linehl));
}

With an empty name the highlight group is reset to zero.

--
Bad fashion can discourage normal people from interacting with the engineer
and talking about the cute things their children do.
(Scott Adams - The Dilbert principle)

James McCoy

unread,
Dec 5, 2021, 3:28:12 PM12/5/21
to vim...@googlegroups.com
On Sun, Dec 05, 2021 at 08:17:43PM +0000, Bram Moolenaar wrote:
>
> James McCoy wrote:
>
> > On Sun, Dec 05, 2021 at 07:11:00PM +0000, Bram Moolenaar wrote:
> > >
> > > Patch 8.2.3748 (after 8.2.3747)
> > > Problem: Giving an error for an empty sign argument breaks a plugin.
> > > Solution: Do not give an error.
> > > Files: src/sign.c, src/errors.h, src/testdir/test_signs.vim
> >
> > Since the error has been reverted, the original issue reported in
> > https://github.com/vim/vim/pull/9280 still stands -- this creates a
> > highlight group with an empty string for a name. Should that be
> > addressed, as was proposed in the PR?
>
> It should not:
>
> if (linehl != NULL)
> {
> if (*linehl == NUL)
> sp->sn_line_hl = 0;
> else
> sp->sn_line_hl = syn_check_group(linehl, (int)STRLEN(linehl));
> }
>
> With an empty name the highlight group is reset to zero.

Ah, right. Thanks!
Reply all
Reply to author
Forward
0 new messages