diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-10-15 20:20:05 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-10-15 20:20:05 +0200 |
commit | f75d498844949f2389165eeefb75affb0efb73f0 (patch) | |
tree | c56ff5b61ab5431c5544465b8d4fdbe4cf87a9ea /src/ex_cmds.c | |
parent | b60574ba21c127acb31f0710518a673e86ad7fd2 (diff) | |
download | vim-git-f75d498844949f2389165eeefb75affb0efb73f0.tar.gz |
updated for version 7.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.
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index fb32545c1..b3f761921 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 |