home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.4 / 7.4.411 < prev    next >
Encoding:
Internet Message Format  |  2014-08-22  |  3.3 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.411
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.4.411
  11. Problem:    "foo bar" sorts before "foo" with sort(). (John Little)
  12. Solution:   Avoid putting quotes around strings before comparing them.
  13. Files:        src/eval.c
  14.  
  15.  
  16. *** ../vim-7.4.410/src/eval.c    2014-08-06 14:52:05.043236174 +0200
  17. --- src/eval.c    2014-08-22 13:08:52.423905619 +0200
  18. ***************
  19. *** 17382,17397 ****
  20.       const void    *s2;
  21.   {
  22.       sortItem_T  *si1, *si2;
  23.       char_u    *p1, *p2;
  24. !     char_u    *tofree1, *tofree2;
  25.       int        res;
  26.       char_u    numbuf1[NUMBUFLEN];
  27.       char_u    numbuf2[NUMBUFLEN];
  28.   
  29.       si1 = (sortItem_T *)s1;
  30.       si2 = (sortItem_T *)s2;
  31. !     p1 = tv2string(&si1->item->li_tv, &tofree1, numbuf1, 0);
  32. !     p2 = tv2string(&si2->item->li_tv, &tofree2, numbuf2, 0);
  33.       if (p1 == NULL)
  34.       p1 = (char_u *)"";
  35.       if (p2 == NULL)
  36. --- 17382,17419 ----
  37.       const void    *s2;
  38.   {
  39.       sortItem_T  *si1, *si2;
  40. +     typval_T    *tv1, *tv2;
  41.       char_u    *p1, *p2;
  42. !     char_u    *tofree1 = NULL, *tofree2 = NULL;
  43.       int        res;
  44.       char_u    numbuf1[NUMBUFLEN];
  45.       char_u    numbuf2[NUMBUFLEN];
  46.   
  47.       si1 = (sortItem_T *)s1;
  48.       si2 = (sortItem_T *)s2;
  49. !     tv1 = &si1->item->li_tv;
  50. !     tv2 = &si2->item->li_tv;
  51. !     /* tv2string() puts quotes around a string and allocates memory.  Don't do
  52. !      * that for string variables. Use a single quote when comparing with a
  53. !      * non-string to do what the docs promise. */
  54. !     if (tv1->v_type == VAR_STRING)
  55. !     {
  56. !     if (tv2->v_type != VAR_STRING || item_compare_numeric)
  57. !         p1 = (char_u *)"'";
  58. !     else
  59. !         p1 = tv1->vval.v_string;
  60. !     }
  61. !     else
  62. !     p1 = tv2string(tv1, &tofree1, numbuf1, 0);
  63. !     if (tv2->v_type == VAR_STRING)
  64. !     {
  65. !     if (tv1->v_type != VAR_STRING || item_compare_numeric)
  66. !         p2 = (char_u *)"'";
  67. !     else
  68. !         p2 = tv2->vval.v_string;
  69. !     }
  70. !     else
  71. !     p2 = tv2string(tv2, &tofree2, numbuf2, 0);
  72.       if (p1 == NULL)
  73.       p1 = (char_u *)"";
  74.       if (p2 == NULL)
  75. ***************
  76. *** 17411,17418 ****
  77.       res = n1 == n2 ? 0 : n1 > n2 ? 1 : -1;
  78.       }
  79.   
  80. !     /* When the result would be zero, compare the pointers themselves.  Makes
  81. !      * the sort stable. */
  82.       if (res == 0 && !item_compare_keep_zero)
  83.       res = si1->idx > si2->idx ? 1 : -1;
  84.   
  85. --- 17433,17440 ----
  86.       res = n1 == n2 ? 0 : n1 > n2 ? 1 : -1;
  87.       }
  88.   
  89. !     /* When the result would be zero, compare the item indexes.  Makes the
  90. !      * sort stable. */
  91.       if (res == 0 && !item_compare_keep_zero)
  92.       res = si1->idx > si2->idx ? 1 : -1;
  93.   
  94. *** ../vim-7.4.410/src/version.c    2014-08-17 17:24:03.967017727 +0200
  95. --- src/version.c    2014-08-22 12:51:35.011943243 +0200
  96. ***************
  97. *** 743,744 ****
  98. --- 743,746 ----
  99.   {   /* Add new patch number below this line */
  100. + /**/
  101. +     411,
  102.   /**/
  103.  
  104. -- 
  105. I started out with nothing, and I still have most of it.
  106.                                 -- Michael Davis -- "Tonight Show"
  107.  
  108.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  109. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  110. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  111.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  112.