| To: vim-dev@vim.org |
| Subject: Patch 7.3.029 |
| Fcc: outbox |
| From: Bram Moolenaar <Bram@moolenaar.net> |
| Mime-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| |
| Patch 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. |
| Files: src/ex_cmds.c, src/testdir/test57.in, src/testdir/test57.ok |
| |
| |
| |
| |
| |
| *** 323,329 **** |
| /* 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; |
| else |
| { |
| /* We need to copy one line into "sortbuf1", because there is no |
| --- 323,330 ---- |
| /* 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 ? 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,488 **** |
| * of the match, by temporarily terminating the string there */ |
| s2 = s + end_col; |
| c = *s2; |
| ! (*s2) = 0; |
| /* Sorting on number: Store the number itself. */ |
| p = s + start_col; |
| if (sort_hex) |
| --- 483,489 ---- |
| * of the match, by temporarily terminating the string there */ |
| s2 = s + end_col; |
| c = *s2; |
| ! *s2 = NUL; |
| /* Sorting on number: Store the number itself. */ |
| p = s + start_col; |
| if (sort_hex) |
| |
| *** 491,499 **** |
| 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; |
| } |
| else |
| { |
| --- 492,504 ---- |
| s = skiptodigit(p); |
| if (s > p && s[-1] == '-') |
| --s; /* include preceding negative sign */ |
| ! 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,6563 **** |
| struct sign |
| { |
| sign_T *sn_next; /* next sign in list */ |
| ! int sn_typenr; /* type number of sign (negative if not equal |
| ! to name) */ |
| char_u *sn_name; /* name of sign */ |
| char_u *sn_icon; /* name of pixmap */ |
| #ifdef FEAT_SIGN_ICONS |
| --- 6561,6567 ---- |
| struct sign |
| { |
| sign_T *sn_next; /* next sign in list */ |
| ! 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 |
| |
| |
| |
| *** 53,67 **** |
| t02: numeric |
| abc |
| ab |
| - a |
| a321 |
| a123 |
| a122 |
| b321 |
| b123 |
| c123d |
| 123b |
| c321d |
| b322b |
| b321 |
| b321b |
| --- 53,71 ---- |
| t02: numeric |
| abc |
| ab |
| a321 |
| a123 |
| a122 |
| + a |
| + x-22 |
| b321 |
| b123 |
| + |
| c123d |
| + -24 |
| 123b |
| c321d |
| + 0 |
| b322b |
| b321 |
| b321b |
| |
| |
| |
| *** 21,26 **** |
| --- 21,30 ---- |
| a |
| |
| |
| + |
| + -24 |
| + x-22 |
| + 0 |
| a122 |
| a123 |
| b123 |
| |
| |
| |
| *** 716,717 **** |
| --- 716,719 ---- |
| { /* Add new patch number below this line */ |
| + /**/ |
| + 29, |
| /**/ |
| |
| -- |
| When danger reared its ugly head, |
| He bravely turned his tail and fled |
| Yes, Brave Sir Robin turned about |
| And gallantly he chickened out |
| Bravely taking to his feet |
| He beat a very brave retreat |
| Bravest of the brave Sir Robin |
| Petrified of being dead |
| Soiled his pants then brave Sir Robin |
| Turned away and fled. |
| "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD |
| |
| /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ |
| /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ |
| \\\ download, build and distribute -- http://www.A-A-P.org /// |
| \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |