Karsten Hopp cf26db
To: vim-dev@vim.org
Karsten Hopp cf26db
Subject: Patch 7.3.029
Karsten Hopp cf26db
Fcc: outbox
Karsten Hopp cf26db
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp cf26db
Mime-Version: 1.0
Karsten Hopp cf26db
Content-Type: text/plain; charset=UTF-8
Karsten Hopp cf26db
Content-Transfer-Encoding: 8bit
Karsten Hopp cf26db
------------
Karsten Hopp cf26db
Karsten Hopp cf26db
Patch 7.3.029
Karsten Hopp cf26db
Problem:    ":sort n" sorts lines without a number as number zero. (Beeyawned)
Karsten Hopp cf26db
Solution:   Make lines without a number sort before lines with a number.  Also
Karsten Hopp cf26db
	    fix sorting negative numbers.
Karsten Hopp cf26db
Files:	    src/ex_cmds.c, src/testdir/test57.in, src/testdir/test57.ok
Karsten Hopp cf26db
Karsten Hopp cf26db
Karsten Hopp cf26db
*** ../vim-7.3.028/src/ex_cmds.c	2010-10-14 21:29:31.000000000 +0200
Karsten Hopp cf26db
--- src/ex_cmds.c	2010-10-15 20:04:25.000000000 +0200
Karsten Hopp cf26db
***************
Karsten Hopp cf26db
*** 323,329 ****
Karsten Hopp cf26db
      /* When sorting numbers "start_col_nr" is the number, not the column
Karsten Hopp cf26db
       * number. */
Karsten Hopp cf26db
      if (sort_nr)
Karsten Hopp cf26db
! 	result = l1.start_col_nr - l2.start_col_nr;
Karsten Hopp cf26db
      else
Karsten Hopp cf26db
      {
Karsten Hopp cf26db
  	/* We need to copy one line into "sortbuf1", because there is no
Karsten Hopp cf26db
--- 323,330 ----
Karsten Hopp cf26db
      /* When sorting numbers "start_col_nr" is the number, not the column
Karsten Hopp cf26db
       * number. */
Karsten Hopp cf26db
      if (sort_nr)
Karsten Hopp cf26db
! 	result = l1.start_col_nr == l2.start_col_nr ? 0
Karsten Hopp cf26db
! 				 : l1.start_col_nr > l2.start_col_nr ? 1 : -1;
Karsten Hopp cf26db
      else
Karsten Hopp cf26db
      {
Karsten Hopp cf26db
  	/* We need to copy one line into "sortbuf1", because there is no
Karsten Hopp cf26db
***************
Karsten Hopp cf26db
*** 482,488 ****
Karsten Hopp cf26db
  	     * of the match, by temporarily terminating the string there */
Karsten Hopp cf26db
  	    s2 = s + end_col;
Karsten Hopp cf26db
  	    c = *s2;
Karsten Hopp cf26db
! 	    (*s2) = 0;
Karsten Hopp cf26db
  	    /* Sorting on number: Store the number itself. */
Karsten Hopp cf26db
  	    p = s + start_col;
Karsten Hopp cf26db
  	    if (sort_hex)
Karsten Hopp cf26db
--- 483,489 ----
Karsten Hopp cf26db
  	     * of the match, by temporarily terminating the string there */
Karsten Hopp cf26db
  	    s2 = s + end_col;
Karsten Hopp cf26db
  	    c = *s2;
Karsten Hopp cf26db
! 	    *s2 = NUL;
Karsten Hopp cf26db
  	    /* Sorting on number: Store the number itself. */
Karsten Hopp cf26db
  	    p = s + start_col;
Karsten Hopp cf26db
  	    if (sort_hex)
Karsten Hopp cf26db
***************
Karsten Hopp cf26db
*** 491,499 ****
Karsten Hopp cf26db
  		s = skiptodigit(p);
Karsten Hopp cf26db
  	    if (s > p && s[-1] == '-')
Karsten Hopp cf26db
  		--s;  /* include preceding negative sign */
Karsten Hopp cf26db
! 	    vim_str2nr(s, NULL, NULL, sort_oct, sort_hex,
Karsten Hopp cf26db
! 					&nrs[lnum - eap->line1].start_col_nr, NULL);
Karsten Hopp cf26db
! 	    (*s2) = c;
Karsten Hopp cf26db
  	}
Karsten Hopp cf26db
  	else
Karsten Hopp cf26db
  	{
Karsten Hopp cf26db
--- 492,504 ----
Karsten Hopp cf26db
  		s = skiptodigit(p);
Karsten Hopp cf26db
  	    if (s > p && s[-1] == '-')
Karsten Hopp cf26db
  		--s;  /* include preceding negative sign */
Karsten Hopp cf26db
! 	    if (*s == NUL)
Karsten Hopp cf26db
! 		/* empty line should sort before any number */
Karsten Hopp cf26db
! 		nrs[lnum - eap->line1].start_col_nr = -MAXLNUM;
Karsten Hopp cf26db
! 	    else
Karsten Hopp cf26db
! 		vim_str2nr(s, NULL, NULL, sort_oct, sort_hex,
Karsten Hopp cf26db
! 				  &nrs[lnum - eap->line1].start_col_nr, NULL);
Karsten Hopp cf26db
! 	    *s2 = c;
Karsten Hopp cf26db
  	}
Karsten Hopp cf26db
  	else
Karsten Hopp cf26db
  	{
Karsten Hopp cf26db
***************
Karsten Hopp cf26db
*** 6556,6563 ****
Karsten Hopp cf26db
  struct sign
Karsten Hopp cf26db
  {
Karsten Hopp cf26db
      sign_T	*sn_next;	/* next sign in list */
Karsten Hopp cf26db
!     int		sn_typenr;	/* type number of sign (negative if not equal
Karsten Hopp cf26db
! 				   to name) */
Karsten Hopp cf26db
      char_u	*sn_name;	/* name of sign */
Karsten Hopp cf26db
      char_u	*sn_icon;	/* name of pixmap */
Karsten Hopp cf26db
  #ifdef FEAT_SIGN_ICONS
Karsten Hopp cf26db
--- 6561,6567 ----
Karsten Hopp cf26db
  struct sign
Karsten Hopp cf26db
  {
Karsten Hopp cf26db
      sign_T	*sn_next;	/* next sign in list */
Karsten Hopp cf26db
!     int		sn_typenr;	/* type number of sign */
Karsten Hopp cf26db
      char_u	*sn_name;	/* name of sign */
Karsten Hopp cf26db
      char_u	*sn_icon;	/* name of pixmap */
Karsten Hopp cf26db
  #ifdef FEAT_SIGN_ICONS
Karsten Hopp cf26db
*** ../vim-7.3.028/src/testdir/test57.in	2010-08-15 21:57:29.000000000 +0200
Karsten Hopp cf26db
--- src/testdir/test57.in	2010-10-15 20:12:23.000000000 +0200
Karsten Hopp cf26db
***************
Karsten Hopp cf26db
*** 53,67 ****
Karsten Hopp cf26db
  t02: numeric
Karsten Hopp cf26db
  abc
Karsten Hopp cf26db
  ab
Karsten Hopp cf26db
- a
Karsten Hopp cf26db
  a321
Karsten Hopp cf26db
  a123
Karsten Hopp cf26db
  a122
Karsten Hopp cf26db
  b321
Karsten Hopp cf26db
  b123
Karsten Hopp cf26db
  c123d
Karsten Hopp cf26db
   123b
Karsten Hopp cf26db
  c321d
Karsten Hopp cf26db
  b322b
Karsten Hopp cf26db
  b321
Karsten Hopp cf26db
  b321b
Karsten Hopp cf26db
--- 53,71 ----
Karsten Hopp cf26db
  t02: numeric
Karsten Hopp cf26db
  abc
Karsten Hopp cf26db
  ab
Karsten Hopp cf26db
  a321
Karsten Hopp cf26db
  a123
Karsten Hopp cf26db
  a122
Karsten Hopp cf26db
+ a
Karsten Hopp cf26db
+ x-22
Karsten Hopp cf26db
  b321
Karsten Hopp cf26db
  b123
Karsten Hopp cf26db
+ 
Karsten Hopp cf26db
  c123d
Karsten Hopp cf26db
+ -24
Karsten Hopp cf26db
   123b
Karsten Hopp cf26db
  c321d
Karsten Hopp cf26db
+ 0
Karsten Hopp cf26db
  b322b
Karsten Hopp cf26db
  b321
Karsten Hopp cf26db
  b321b
Karsten Hopp cf26db
*** ../vim-7.3.028/src/testdir/test57.ok	2010-08-15 21:57:29.000000000 +0200
Karsten Hopp cf26db
--- src/testdir/test57.ok	2010-10-15 20:11:42.000000000 +0200
Karsten Hopp cf26db
***************
Karsten Hopp cf26db
*** 21,26 ****
Karsten Hopp cf26db
--- 21,30 ----
Karsten Hopp cf26db
  a
Karsten Hopp cf26db
  
Karsten Hopp cf26db
  
Karsten Hopp cf26db
+ 
Karsten Hopp cf26db
+ -24
Karsten Hopp cf26db
+ x-22
Karsten Hopp cf26db
+ 0
Karsten Hopp cf26db
  a122
Karsten Hopp cf26db
  a123
Karsten Hopp cf26db
  b123
Karsten Hopp cf26db
*** ../vim-7.3.028/src/version.c	2010-10-14 21:29:31.000000000 +0200
Karsten Hopp cf26db
--- src/version.c	2010-10-15 20:13:52.000000000 +0200
Karsten Hopp cf26db
***************
Karsten Hopp cf26db
*** 716,717 ****
Karsten Hopp cf26db
--- 716,719 ----
Karsten Hopp cf26db
  {   /* Add new patch number below this line */
Karsten Hopp cf26db
+ /**/
Karsten Hopp cf26db
+     29,
Karsten Hopp cf26db
  /**/
Karsten Hopp cf26db
Karsten Hopp cf26db
-- 
Karsten Hopp cf26db
       When danger reared its ugly head,
Karsten Hopp cf26db
       He bravely turned his tail and fled
Karsten Hopp cf26db
       Yes, Brave Sir Robin turned about
Karsten Hopp cf26db
       And gallantly he chickened out
Karsten Hopp cf26db
       Bravely taking to his feet
Karsten Hopp cf26db
       He beat a very brave retreat
Karsten Hopp cf26db
       Bravest of the brave Sir Robin
Karsten Hopp cf26db
       Petrified of being dead
Karsten Hopp cf26db
       Soiled his pants then brave Sir Robin
Karsten Hopp cf26db
       Turned away and fled.
Karsten Hopp cf26db
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp cf26db
Karsten Hopp cf26db
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp cf26db
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp cf26db
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp cf26db
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///