To: vim-dev@vim.org Subject: Patch 7.2b.020 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 7.2b.020 Problem: ":sort n" doesn't handle negative numbers. (James Vega) Solution: Include '-' in the number. Files: src/charset.c, src/ex_cmds.c *** ../vim-7.2b.019/src/charset.c Sat Jun 28 13:03:34 2008 --- src/charset.c Thu Jul 24 16:59:44 2008 *************** *** 1466,1474 **** * skipwhite: skip over ' ' and '\t'. */ char_u * ! skipwhite(p) ! char_u *p; { while (vim_iswhite(*p)) /* skip to next non-white */ ++p; return p; --- 1466,1476 ---- * skipwhite: skip over ' ' and '\t'. */ char_u * ! skipwhite(q) ! char_u *q; { + char_u *p = q; + while (vim_iswhite(*p)) /* skip to next non-white */ ++p; return p; *************** *** 1478,1486 **** * skip over digits */ char_u * ! skipdigits(p) ! char_u *p; { while (VIM_ISDIGIT(*p)) /* skip to next non-digit */ ++p; return p; --- 1480,1490 ---- * skip over digits */ char_u * ! skipdigits(q) ! char_u *q; { + char_u *p = q; + while (VIM_ISDIGIT(*p)) /* skip to next non-digit */ ++p; return p; *************** *** 1491,1499 **** * skip over digits and hex characters */ char_u * ! skiphex(p) ! char_u *p; { while (vim_isxdigit(*p)) /* skip to next non-digit */ ++p; return p; --- 1495,1505 ---- * skip over digits and hex characters */ char_u * ! skiphex(q) ! char_u *q; { + char_u *p = q; + while (vim_isxdigit(*p)) /* skip to next non-digit */ ++p; return p; *************** *** 1505,1513 **** * skip to digit (or NUL after the string) */ char_u * ! skiptodigit(p) ! char_u *p; { while (*p != NUL && !VIM_ISDIGIT(*p)) /* skip to next digit */ ++p; return p; --- 1511,1521 ---- * skip to digit (or NUL after the string) */ char_u * ! skiptodigit(q) ! char_u *q; { + char_u *p = q; + while (*p != NUL && !VIM_ISDIGIT(*p)) /* skip to next digit */ ++p; return p; *************** *** 1517,1525 **** * skip to hex character (or NUL after the string) */ char_u * ! skiptohex(p) ! char_u *p; { while (*p != NUL && !vim_isxdigit(*p)) /* skip to next digit */ ++p; return p; --- 1525,1535 ---- * skip to hex character (or NUL after the string) */ char_u * ! skiptohex(q) ! char_u *q; { + char_u *p = q; + while (*p != NUL && !vim_isxdigit(*p)) /* skip to next digit */ ++p; return p; *** ../vim-7.2b.019/src/ex_cmds.c Thu Jul 24 18:44:23 2008 --- src/ex_cmds.c Thu Jul 24 17:03:48 2008 *************** *** 479,488 **** c = *s2; (*s2) = 0; /* Sorting on number: Store the number itself. */ if (sort_hex) ! s = skiptohex(s + start_col); else ! s = skiptodigit(s + start_col); vim_str2nr(s, NULL, NULL, sort_oct, sort_hex, &nrs[lnum - eap->line1].start_col_nr, NULL); (*s2) = c; --- 479,491 ---- c = *s2; (*s2) = 0; /* Sorting on number: Store the number itself. */ + p = s + start_col; if (sort_hex) ! s = skiptohex(p); else ! 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; *** ../vim-7.2b.019/src/version.c Thu Jul 24 20:49:38 2008 --- src/version.c Thu Jul 24 21:28:57 2008 *************** *** 678,679 **** --- 678,681 ---- { /* Add new patch number below this line */ + /**/ + 20, /**/ -- ARTHUR: Well, it doesn't matter. Will you go and tell your master that Arthur from the Court of Camelot is here. GUARD #1: Listen, in order to maintain air-speed velocity, a swallow needs to beat its wings 43 times every second, right? ARTHUR: Please! The Quest for the Holy Grail (Monty Python) /// 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 ///