summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2010-10-15 20:20:05 +0200
committerBram Moolenaar <bram@vim.org>2010-10-15 20:20:05 +0200
commit565aefe29c6e4504c83448a9e96f8591cf6ddefa (patch)
tree293b227493ed9ddee4e377b5da141da99aa21451
parent755dca1ae41ee0b203d8f0e3336783452e970d12 (diff)
downloadvim-565aefe29c6e4504c83448a9e96f8591cf6ddefa.tar.gz
updated for version 7.3.029v7.3.029v7-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.
-rw-r--r--src/ex_cmds.c18
-rw-r--r--src/testdir/test57.in6
-rw-r--r--src/testdir/test57.ok4
-rw-r--r--src/version.c2
4 files changed, 22 insertions, 8 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index fb32545c..b3f76192 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -323,7 +323,8 @@ sort_compare(s1, s2)
/* When sorting numbers "start_col_nr" is the number, not the column
* number. */
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
{
/* 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 */
s2 = s + end_col;
c = *s2;
- (*s2) = 0;
+ *s2 = NUL;
/* Sorting on number: Store the number itself. */
p = s + start_col;
if (sort_hex)
@@ -491,9 +492,13 @@ ex_sort(eap)
s = skiptodigit(p);
if (s > p && s[-1] == '-')
--s; /* include preceding negative sign */
- vim_str2nr(s, NULL, NULL, sort_oct, sort_hex,
- &nrs[lnum - eap->line1].start_col_nr, NULL);
- (*s2) = c;
+ if (*s == NUL)
+ /* empty line should sort before any number */
+ 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
{
@@ -6556,8 +6561,7 @@ typedef struct sign sign_T;
struct sign
{
sign_T *sn_next; /* next sign in list */
- int sn_typenr; /* type number of sign (negative if not equal
- to name) */
+ int sn_typenr; /* type number of sign */
char_u *sn_name; /* name of sign */
char_u *sn_icon; /* name of pixmap */
#ifdef FEAT_SIGN_ICONS
diff --git a/src/testdir/test57.in b/src/testdir/test57.in
index d74af579..8d972e4a 100644
--- a/src/testdir/test57.in
+++ b/src/testdir/test57.in
@@ -53,15 +53,19 @@ b321b
t02: numeric
abc
ab
-a
a321
a123
a122
+a
+x-22
b321
b123
+
c123d
+-24
123b
c321d
+0
b322b
b321
b321b
diff --git a/src/testdir/test57.ok b/src/testdir/test57.ok
index 17771334..aa3d3731 100644
--- a/src/testdir/test57.ok
+++ b/src/testdir/test57.ok
@@ -21,6 +21,10 @@ ab
a
+
+-24
+x-22
+0
a122
a123
b123
diff --git a/src/version.c b/src/version.c
index 9b49122e..9584550b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 29,
+/**/
28,
/**/
27,