Re: Patch 7.3.024

2010-10-14 Fir de Conversatie Bram Moolenaar

Charles Campbell wrote:

> Bram Moolenaar wrote:
> > Patch 7.3.024
> > Problem:Named signs do not use a negative number as intended.
> > Solution:   Fix the numbering of named signs. (Xavier de Gaye)
> > Files:  src/ex_cmds.c
> >   
> Hello,
> 
> This patch is causing "vanishing signs syndrome".  Here's a test procedure:
> 
> When in .../vim73/src,
> ./vim -g -N -u NONE -S tst.vim
> 
> where  tst.vim is:
> 
> e! main.c
> 169
> sign define TestSign icon=../pixmaps/tb_close.xpm
> sign place 1234 line=169 name=TestSign file=main.c
> 
> With vim 7.3.1-23, the tb_close.xpm icon shows up on line 169 of main.c .
> With vim 7.3.1-24, a plain block is placed there instead.

Yeah, the negative number is stored in an unsigned array somewhere, thus
it actually doesn't work at all.

I'll have to think of another solution.

-- 
Error:015 - Unable to exit Windows.  Try the door.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

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


Re: Patch 7.3.024

2010-10-14 Fir de Conversatie Xavier de Gaye
On Thu, Oct 14, 2010 at 2:21 AM, Charles E Campbell Jr wrote:
>
> This patch is causing "vanishing signs syndrome".  Here's a test procedure:
>
> When in .../vim73/src,
> ./vim -g -N -u NONE -S tst.vim
>
> where  tst.vim is:
>
> e! main.c
> 169
> sign define TestSign icon=../pixmaps/tb_close.xpm
> sign place 1234 line=169 name=TestSign file=main.c
>
> With vim 7.3.1-23, the tb_close.xpm icon shows up on line 169 of main.c .
> With vim 7.3.1-24, a plain block is placed there instead.
>


When the sign is defined with an icon, its 'typenr' is stored in the
ScreenAttrs[] array.  The 'typenr' is later retrieved from this array when the
screen is redrawn (so that the icon may be redrawn: see gui_mch_drawsign()).
The problem is that the array is of type 'unsigned short' or 'unsigned char',
while 'typenr' is an 'int'.

See win_line() in screen.c:
line 3423:  set the value of 'icon_sign' to the sign 'typenr'
further down:   char_attr = icon_sign
much further:   ScreenAttrs[off] = char_attr;

There are two other problems that occur before and after this patch:

* buf_getsigntype() returns 'typenr' and 0 when not found, but 0 is a valid
  typenr when the sign has been defined with the name '0' (so placing such
  a sign does not display the icon or any highlighting)

* when defining a sign with a numeric name, no check is done currently to
  make sure that its value will fit in an 'unsigned short' or
'unsigned char'

A possible fix may be:

* cancel the patch

* treat all sign names, including numeric names, as alphabetic
  names and allocate a 'typenr' for each one with
  'last_sign_typenr', as it was done previously only for
  non-numeric names. In this case, 'sn_typenr' and 'sn_name' are
  unrelated.

This would fix the broken patch, and the two problems above.
I can send a patch, if this is acceptable.

-- 
Xavier

Les Chemins de Lokoti: http://lokoti.alwaysdata.net

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


Re: Patch 7.3.024

2010-10-13 Fir de Conversatie Charles E Campbell Jr

Bram Moolenaar wrote:

Patch 7.3.024
Problem:Named signs do not use a negative number as intended.
Solution:   Fix the numbering of named signs. (Xavier de Gaye)
Files:  src/ex_cmds.c
  

Hello,

This patch is causing "vanishing signs syndrome".  Here's a test procedure:

When in .../vim73/src,
./vim -g -N -u NONE -S tst.vim

where  tst.vim is:

e! main.c
169
sign define TestSign icon=../pixmaps/tb_close.xpm
sign place 1234 line=169 name=TestSign file=main.c

With vim 7.3.1-23, the tb_close.xpm icon shows up on line 169 of main.c .
With vim 7.3.1-24, a plain block is placed there instead.

Regards,
Chip Campbell

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


Patch 7.3.024

2010-10-13 Fir de Conversatie Bram Moolenaar

Patch 7.3.024
Problem:Named signs do not use a negative number as intended.
Solution:   Fix the numbering of named signs. (Xavier de Gaye)
Files:  src/ex_cmds.c


*** ../vim-7.3.023/src/ex_cmds.c2010-09-21 16:56:29.0 +0200
--- src/ex_cmds.c   2010-10-13 16:37:18.0 +0200
***
*** 6670,6680 
sp = (sign_T *)alloc_clear((unsigned)sizeof(sign_T));
if (sp == NULL)
return;
-   if (sp_prev == NULL)
-   first_sign = sp;
-   else
-   sp_prev->sn_next = sp;
-   sp->sn_name = vim_strnsave(arg, (int)(p - arg));
  
/* If the name is a number use that for the typenr,
 * otherwise use a negative number. */
--- 6670,6675 
***
*** 6687,6699 
  
for (lp = first_sign; lp != NULL; lp = lp->sn_next)
{
!   if (lp->sn_typenr == last_sign_typenr)
{
--last_sign_typenr;
if (last_sign_typenr == 0)
last_sign_typenr = MAX_TYPENR;
if (last_sign_typenr == start)
{
EMSG(_("E612: Too many signs defined"));
return;
}
--- 6682,6695 
  
for (lp = first_sign; lp != NULL; lp = lp->sn_next)
{
!   if (lp->sn_typenr == -last_sign_typenr)
{
--last_sign_typenr;
if (last_sign_typenr == 0)
last_sign_typenr = MAX_TYPENR;
if (last_sign_typenr == start)
{
+   vim_free(sp);
EMSG(_("E612: Too many signs defined"));
return;
}
***
*** 6702,6711 
}
}
  
!   sp->sn_typenr = last_sign_typenr--;
!   if (last_sign_typenr == 0)
last_sign_typenr = MAX_TYPENR; /* wrap around */
}
}
  
/* set values for a defined sign. */
--- 6698,6714 
}
}
  
!   sp->sn_typenr = -last_sign_typenr;
!   if (--last_sign_typenr == 0)
last_sign_typenr = MAX_TYPENR; /* wrap around */
}
+ 
+   /* add the new sign to the list of signs */
+   if (sp_prev == NULL)
+   first_sign = sp;
+   else
+   sp_prev->sn_next = sp;
+   sp->sn_name = vim_strnsave(arg, (int)(p - arg));
}
  
/* set values for a defined sign. */
*** ../vim-7.3.023/src/version.c2010-10-13 16:22:05.0 +0200
--- src/version.c   2010-10-13 16:42:14.0 +0200
***
*** 716,717 
--- 716,719 
  {   /* Add new patch number below this line */
+ /**/
+ 24,
  /**/

-- 
   In war we're tough and able.
   Quite indefatigable
   Between our quests
   We sequin vests
   And impersonate Clark Gable
   It's a busy life in Camelot.
   I have to push the pram a lot.
 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

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