0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

updated for version 7.3.028

Problem:    Signs don't show up. (Charles Campbell)
Solution:   Don't use negative numbers.  Also assign a number to signs that
            have a name of all digits to avoid using a sign number twice.
This commit is contained in:
Bram Moolenaar 2010-10-14 21:29:37 +02:00
parent 464c92545a
commit b60574ba21
2 changed files with 38 additions and 26 deletions

View File

@ -6569,7 +6569,7 @@ struct sign
}; };
static sign_T *first_sign = NULL; static sign_T *first_sign = NULL;
static int last_sign_typenr = MAX_TYPENR; /* is decremented */ static int next_sign_typenr = 1;
static int sign_cmd_idx __ARGS((char_u *begin_cmd, char_u *end_cmd)); static int sign_cmd_idx __ARGS((char_u *begin_cmd, char_u *end_cmd));
static void sign_list_defined __ARGS((sign_T *sp)); static void sign_list_defined __ARGS((sign_T *sp));
@ -6651,9 +6651,14 @@ ex_sign(eap)
EMSG(_("E156: Missing sign name")); EMSG(_("E156: Missing sign name"));
else else
{ {
/* Isolate the sign name. If it's a number skip leading zeroes,
* so that "099" and "99" are the same sign. But keep "0". */
p = skiptowhite(arg); p = skiptowhite(arg);
if (*p != NUL) if (*p != NUL)
*p++ = NUL; *p++ = NUL;
while (arg[0] == '0' && arg[1] != NUL)
++arg;
sp_prev = NULL; sp_prev = NULL;
for (sp = first_sign; sp != NULL; sp = sp->sn_next) for (sp = first_sign; sp != NULL; sp = sp->sn_next)
{ {
@ -6666,41 +6671,45 @@ ex_sign(eap)
/* ":sign define {name} ...": define a sign */ /* ":sign define {name} ...": define a sign */
if (sp == NULL) if (sp == NULL)
{ {
sign_T *lp;
int start = next_sign_typenr;
/* Allocate a new sign. */ /* Allocate a new sign. */
sp = (sign_T *)alloc_clear((unsigned)sizeof(sign_T)); sp = (sign_T *)alloc_clear((unsigned)sizeof(sign_T));
if (sp == NULL) if (sp == NULL)
return; return;
/* If the name is a number use that for the typenr, /* Check that next_sign_typenr is not already being used.
* otherwise use a negative number. */ * This only happens after wrapping around. Hopefully
if (VIM_ISDIGIT(*arg)) * another one got deleted and we can use its number. */
sp->sn_typenr = atoi((char *)arg); for (lp = first_sign; lp != NULL; )
else
{ {
sign_T *lp; if (lp->sn_typenr == next_sign_typenr)
int start = last_sign_typenr;
for (lp = first_sign; lp != NULL; lp = lp->sn_next)
{ {
if (lp->sn_typenr == -last_sign_typenr) ++next_sign_typenr;
if (next_sign_typenr == MAX_TYPENR)
next_sign_typenr = 1;
if (next_sign_typenr == start)
{ {
--last_sign_typenr; vim_free(sp);
if (last_sign_typenr == 0) EMSG(_("E612: Too many signs defined"));
last_sign_typenr = MAX_TYPENR; return;
if (last_sign_typenr == start)
{
vim_free(sp);
EMSG(_("E612: Too many signs defined"));
return;
}
lp = first_sign;
continue;
} }
lp = first_sign; /* start all over */
continue;
} }
lp = lp->sn_next;
}
sp->sn_typenr = -last_sign_typenr; sp->sn_typenr = next_sign_typenr;
if (--last_sign_typenr == 0) if (++next_sign_typenr == MAX_TYPENR)
last_sign_typenr = MAX_TYPENR; /* wrap around */ next_sign_typenr = 1; /* wrap around */
sp->sn_name = vim_strsave(arg);
if (sp->sn_name == NULL) /* out of memory */
{
vim_free(sp);
return;
} }
/* add the new sign to the list of signs */ /* add the new sign to the list of signs */
@ -6708,7 +6717,6 @@ ex_sign(eap)
first_sign = sp; first_sign = sp;
else else
sp_prev->sn_next = sp; sp_prev->sn_next = sp;
sp->sn_name = vim_strnsave(arg, (int)(p - arg));
} }
/* set values for a defined sign. */ /* set values for a defined sign. */
@ -6886,6 +6894,8 @@ ex_sign(eap)
arg = skiptowhite(arg); arg = skiptowhite(arg);
if (*arg != NUL) if (*arg != NUL)
*arg++ = NUL; *arg++ = NUL;
while (sign_name[0] == '0' && sign_name[1] != NUL)
++sign_name;
} }
else if (STRNCMP(arg, "file=", 5) == 0) else if (STRNCMP(arg, "file=", 5) == 0)
{ {

View File

@ -714,6 +714,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
28,
/**/ /**/
27, 27,
/**/ /**/