Karsten Hopp ca111d
To: vim-dev@vim.org
Karsten Hopp ca111d
Subject: Patch 7.3.028
Karsten Hopp ca111d
Fcc: outbox
Karsten Hopp ca111d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp ca111d
Mime-Version: 1.0
Karsten Hopp ca111d
Content-Type: text/plain; charset=UTF-8
Karsten Hopp ca111d
Content-Transfer-Encoding: 8bit
Karsten Hopp ca111d
------------
Karsten Hopp ca111d
Karsten Hopp ca111d
Patch 7.3.028 (after 7.3.024)
Karsten Hopp ca111d
Problem:    Signs don't show up. (Charles Campbell)
Karsten Hopp ca111d
Solution:   Don't use negative numbers.  Also assign a number to signs that
Karsten Hopp ca111d
	    have a name of all digits to avoid using a sign number twice.
Karsten Hopp ca111d
Files:	    src/ex_cmds.c
Karsten Hopp ca111d
Karsten Hopp ca111d
Karsten Hopp ca111d
*** ../vim-7.3.027/src/ex_cmds.c	2010-10-13 16:44:17.000000000 +0200
Karsten Hopp ca111d
--- src/ex_cmds.c	2010-10-14 20:59:04.000000000 +0200
Karsten Hopp ca111d
***************
Karsten Hopp ca111d
*** 6569,6575 ****
Karsten Hopp ca111d
  };
Karsten Hopp ca111d
  
Karsten Hopp ca111d
  static sign_T	*first_sign = NULL;
Karsten Hopp ca111d
! static int	last_sign_typenr = MAX_TYPENR;	/* is decremented */
Karsten Hopp ca111d
  
Karsten Hopp ca111d
  static int sign_cmd_idx __ARGS((char_u *begin_cmd, char_u *end_cmd));
Karsten Hopp ca111d
  static void sign_list_defined __ARGS((sign_T *sp));
Karsten Hopp ca111d
--- 6569,6575 ----
Karsten Hopp ca111d
  };
Karsten Hopp ca111d
  
Karsten Hopp ca111d
  static sign_T	*first_sign = NULL;
Karsten Hopp ca111d
! static int	next_sign_typenr = 1;
Karsten Hopp ca111d
  
Karsten Hopp ca111d
  static int sign_cmd_idx __ARGS((char_u *begin_cmd, char_u *end_cmd));
Karsten Hopp ca111d
  static void sign_list_defined __ARGS((sign_T *sp));
Karsten Hopp ca111d
***************
Karsten Hopp ca111d
*** 6651,6659 ****
Karsten Hopp ca111d
--- 6651,6664 ----
Karsten Hopp ca111d
  	    EMSG(_("E156: Missing sign name"));
Karsten Hopp ca111d
  	else
Karsten Hopp ca111d
  	{
Karsten Hopp ca111d
+ 	    /* Isolate the sign name.  If it's a number skip leading zeroes,
Karsten Hopp ca111d
+ 	     * so that "099" and "99" are the same sign.  But keep "0". */
Karsten Hopp ca111d
  	    p = skiptowhite(arg);
Karsten Hopp ca111d
  	    if (*p != NUL)
Karsten Hopp ca111d
  		*p++ = NUL;
Karsten Hopp ca111d
+ 	    while (arg[0] == '0' && arg[1] != NUL)
Karsten Hopp ca111d
+ 		++arg;
Karsten Hopp ca111d
+ 
Karsten Hopp ca111d
  	    sp_prev = NULL;
Karsten Hopp ca111d
  	    for (sp = first_sign; sp != NULL; sp = sp->sn_next)
Karsten Hopp ca111d
  	    {
Karsten Hopp ca111d
***************
Karsten Hopp ca111d
*** 6666,6706 ****
Karsten Hopp ca111d
  		/* ":sign define {name} ...": define a sign */
Karsten Hopp ca111d
  		if (sp == NULL)
Karsten Hopp ca111d
  		{
Karsten Hopp ca111d
  		    /* Allocate a new sign. */
Karsten Hopp ca111d
  		    sp = (sign_T *)alloc_clear((unsigned)sizeof(sign_T));
Karsten Hopp ca111d
  		    if (sp == NULL)
Karsten Hopp ca111d
  			return;
Karsten Hopp ca111d
  
Karsten Hopp ca111d
! 		    /* If the name is a number use that for the typenr,
Karsten Hopp ca111d
! 		     * otherwise use a negative number. */
Karsten Hopp ca111d
! 		    if (VIM_ISDIGIT(*arg))
Karsten Hopp ca111d
! 			sp->sn_typenr = atoi((char *)arg);
Karsten Hopp ca111d
! 		    else
Karsten Hopp ca111d
  		    {
Karsten Hopp ca111d
! 			sign_T	*lp;
Karsten Hopp ca111d
! 			int	start = last_sign_typenr;
Karsten Hopp ca111d
! 
Karsten Hopp ca111d
! 			for (lp = first_sign; lp != NULL; lp = lp->sn_next)
Karsten Hopp ca111d
  			{
Karsten Hopp ca111d
! 			    if (lp->sn_typenr == -last_sign_typenr)
Karsten Hopp ca111d
  			    {
Karsten Hopp ca111d
! 				--last_sign_typenr;
Karsten Hopp ca111d
! 				if (last_sign_typenr == 0)
Karsten Hopp ca111d
! 				    last_sign_typenr = MAX_TYPENR;
Karsten Hopp ca111d
! 				if (last_sign_typenr == start)
Karsten Hopp ca111d
! 				{
Karsten Hopp ca111d
! 				    vim_free(sp);
Karsten Hopp ca111d
! 				    EMSG(_("E612: Too many signs defined"));
Karsten Hopp ca111d
! 				    return;
Karsten Hopp ca111d
! 				}
Karsten Hopp ca111d
! 				lp = first_sign;
Karsten Hopp ca111d
! 				continue;
Karsten Hopp ca111d
  			    }
Karsten Hopp ca111d
  			}
Karsten Hopp ca111d
  
Karsten Hopp ca111d
! 			sp->sn_typenr = -last_sign_typenr;
Karsten Hopp ca111d
! 			if (--last_sign_typenr == 0)
Karsten Hopp ca111d
! 			    last_sign_typenr = MAX_TYPENR; /* wrap around */
Karsten Hopp ca111d
  		    }
Karsten Hopp ca111d
  
Karsten Hopp ca111d
  		    /* add the new sign to the list of signs */
Karsten Hopp ca111d
--- 6671,6715 ----
Karsten Hopp ca111d
  		/* ":sign define {name} ...": define a sign */
Karsten Hopp ca111d
  		if (sp == NULL)
Karsten Hopp ca111d
  		{
Karsten Hopp ca111d
+ 		    sign_T	*lp;
Karsten Hopp ca111d
+ 		    int		start = next_sign_typenr;
Karsten Hopp ca111d
+ 
Karsten Hopp ca111d
  		    /* Allocate a new sign. */
Karsten Hopp ca111d
  		    sp = (sign_T *)alloc_clear((unsigned)sizeof(sign_T));
Karsten Hopp ca111d
  		    if (sp == NULL)
Karsten Hopp ca111d
  			return;
Karsten Hopp ca111d
  
Karsten Hopp ca111d
! 		    /* Check that next_sign_typenr is not already being used.
Karsten Hopp ca111d
! 		     * This only happens after wrapping around.  Hopefully
Karsten Hopp ca111d
! 		     * another one got deleted and we can use its number. */
Karsten Hopp ca111d
! 		    for (lp = first_sign; lp != NULL; )
Karsten Hopp ca111d
  		    {
Karsten Hopp ca111d
! 			if (lp->sn_typenr == next_sign_typenr)
Karsten Hopp ca111d
  			{
Karsten Hopp ca111d
! 			    ++next_sign_typenr;
Karsten Hopp ca111d
! 			    if (next_sign_typenr == MAX_TYPENR)
Karsten Hopp ca111d
! 				next_sign_typenr = 1;
Karsten Hopp ca111d
! 			    if (next_sign_typenr == start)
Karsten Hopp ca111d
  			    {
Karsten Hopp ca111d
! 				vim_free(sp);
Karsten Hopp ca111d
! 				EMSG(_("E612: Too many signs defined"));
Karsten Hopp ca111d
! 				return;
Karsten Hopp ca111d
  			    }
Karsten Hopp ca111d
+ 			    lp = first_sign;  /* start all over */
Karsten Hopp ca111d
+ 			    continue;
Karsten Hopp ca111d
  			}
Karsten Hopp ca111d
+ 			lp = lp->sn_next;
Karsten Hopp ca111d
+ 		    }
Karsten Hopp ca111d
+ 
Karsten Hopp ca111d
+ 		    sp->sn_typenr = next_sign_typenr;
Karsten Hopp ca111d
+ 		    if (++next_sign_typenr == MAX_TYPENR)
Karsten Hopp ca111d
+ 			next_sign_typenr = 1; /* wrap around */
Karsten Hopp ca111d
  
Karsten Hopp ca111d
! 		    sp->sn_name = vim_strsave(arg);
Karsten Hopp ca111d
! 		    if (sp->sn_name == NULL)  /* out of memory */
Karsten Hopp ca111d
! 		    {
Karsten Hopp ca111d
! 			vim_free(sp);
Karsten Hopp ca111d
! 			return;
Karsten Hopp ca111d
  		    }
Karsten Hopp ca111d
  
Karsten Hopp ca111d
  		    /* add the new sign to the list of signs */
Karsten Hopp ca111d
***************
Karsten Hopp ca111d
*** 6708,6714 ****
Karsten Hopp ca111d
  			first_sign = sp;
Karsten Hopp ca111d
  		    else
Karsten Hopp ca111d
  			sp_prev->sn_next = sp;
Karsten Hopp ca111d
- 		    sp->sn_name = vim_strnsave(arg, (int)(p - arg));
Karsten Hopp ca111d
  		}
Karsten Hopp ca111d
  
Karsten Hopp ca111d
  		/* set values for a defined sign. */
Karsten Hopp ca111d
--- 6717,6722 ----
Karsten Hopp ca111d
***************
Karsten Hopp ca111d
*** 6886,6891 ****
Karsten Hopp ca111d
--- 6894,6901 ----
Karsten Hopp ca111d
  		arg = skiptowhite(arg);
Karsten Hopp ca111d
  		if (*arg != NUL)
Karsten Hopp ca111d
  		    *arg++ = NUL;
Karsten Hopp ca111d
+ 		while (sign_name[0] == '0' && sign_name[1] != NUL)
Karsten Hopp ca111d
+ 		    ++sign_name;
Karsten Hopp ca111d
  	    }
Karsten Hopp ca111d
  	    else if (STRNCMP(arg, "file=", 5) == 0)
Karsten Hopp ca111d
  	    {
Karsten Hopp ca111d
*** ../vim-7.3.027/src/version.c	2010-10-13 20:37:37.000000000 +0200
Karsten Hopp ca111d
--- src/version.c	2010-10-14 20:50:54.000000000 +0200
Karsten Hopp ca111d
***************
Karsten Hopp ca111d
*** 716,717 ****
Karsten Hopp ca111d
--- 716,719 ----
Karsten Hopp ca111d
  {   /* Add new patch number below this line */
Karsten Hopp ca111d
+ /**/
Karsten Hopp ca111d
+     28,
Karsten Hopp ca111d
  /**/
Karsten Hopp ca111d
Karsten Hopp ca111d
-- 
Karsten Hopp ca111d
This is an airconditioned room, do not open Windows.
Karsten Hopp ca111d
Karsten Hopp ca111d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp ca111d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp ca111d
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp ca111d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///