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

updated for version 7.3.029

Problem:    ":sort n" sorts lines without a number as number zero. (Beeyawned)
Solution:   Make lines without a number sort before lines with a number.  Also
            fix sorting negative numbers.
This commit is contained in:
Bram Moolenaar 2010-10-15 20:20:05 +02:00
parent b60574ba21
commit f75d498844
4 changed files with 22 additions and 8 deletions

View File

@ -323,7 +323,8 @@ sort_compare(s1, s2)
/* When sorting numbers "start_col_nr" is the number, not the column /* When sorting numbers "start_col_nr" is the number, not the column
* number. */ * number. */
if (sort_nr) if (sort_nr)
result = l1.start_col_nr - l2.start_col_nr; result = l1.start_col_nr == l2.start_col_nr ? 0
: l1.start_col_nr > l2.start_col_nr ? 1 : -1;
else else
{ {
/* We need to copy one line into "sortbuf1", because there is no /* We need to copy one line into "sortbuf1", because there is no
@ -482,7 +483,7 @@ ex_sort(eap)
* of the match, by temporarily terminating the string there */ * of the match, by temporarily terminating the string there */
s2 = s + end_col; s2 = s + end_col;
c = *s2; c = *s2;
(*s2) = 0; *s2 = NUL;
/* Sorting on number: Store the number itself. */ /* Sorting on number: Store the number itself. */
p = s + start_col; p = s + start_col;
if (sort_hex) if (sort_hex)
@ -491,9 +492,13 @@ ex_sort(eap)
s = skiptodigit(p); s = skiptodigit(p);
if (s > p && s[-1] == '-') if (s > p && s[-1] == '-')
--s; /* include preceding negative sign */ --s; /* include preceding negative sign */
vim_str2nr(s, NULL, NULL, sort_oct, sort_hex, if (*s == NUL)
&nrs[lnum - eap->line1].start_col_nr, NULL); /* empty line should sort before any number */
(*s2) = c; nrs[lnum - eap->line1].start_col_nr = -MAXLNUM;
else
vim_str2nr(s, NULL, NULL, sort_oct, sort_hex,
&nrs[lnum - eap->line1].start_col_nr, NULL);
*s2 = c;
} }
else else
{ {
@ -6556,8 +6561,7 @@ typedef struct sign sign_T;
struct sign struct sign
{ {
sign_T *sn_next; /* next sign in list */ sign_T *sn_next; /* next sign in list */
int sn_typenr; /* type number of sign (negative if not equal int sn_typenr; /* type number of sign */
to name) */
char_u *sn_name; /* name of sign */ char_u *sn_name; /* name of sign */
char_u *sn_icon; /* name of pixmap */ char_u *sn_icon; /* name of pixmap */
#ifdef FEAT_SIGN_ICONS #ifdef FEAT_SIGN_ICONS

View File

@ -53,15 +53,19 @@ b321b
t02: numeric t02: numeric
abc abc
ab ab
a
a321 a321
a123 a123
a122 a122
a
x-22
b321 b321
b123 b123
c123d c123d
-24
123b 123b
c321d c321d
0
b322b b322b
b321 b321
b321b b321b

View File

@ -21,6 +21,10 @@ ab
a a
-24
x-22
0
a122 a122
a123 a123
b123 b123

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 */
/**/
29,
/**/ /**/
28, 28,
/**/ /**/