Patch 7.1.240
Problem:    When "gUe" turns a German sharp s into SS the operation stops
            before the end of the word.  Latin2 has the same sharp s but it's
            not changed to SS there.
Solution:   Make sure all the characters are operated upon.  Detect the sharp
            s in latin2.  Also fixes that changing case of a multi-byte
            character that changes the byte cound doesn't always work.
Files:      src/ops.c


*** ../vim-7.1.239/src/ops.c    Wed Jan 16 20:01:14 2008
--- src/ops.c   Tue Jan 22 16:00:07 2008
***************
*** 2184,2189 ****
--- 2184,2191 ----
  }
  #endif
  
+ static int swapchars __ARGS((int op_type, pos_T *pos, int length));
+ 
  /*
   * Handle the (non-standard vi) tilde operator.  Also for "gu", "gU" and "g?".
   */
***************
*** 2194,2202 ****
      pos_T             pos;
  #ifdef FEAT_VISUAL
      struct block_def  bd;
-     int                       todo;
  #endif
!     int                       did_change = 0;
  
      if (u_save((linenr_T)(oap->start.lnum - 1),
                                       (linenr_T)(oap->end.lnum + 1)) == FAIL)
--- 2196,2203 ----
      pos_T             pos;
  #ifdef FEAT_VISUAL
      struct block_def  bd;
  #endif
!     int                       did_change;
  
      if (u_save((linenr_T)(oap->start.lnum - 1),
                                       (linenr_T)(oap->end.lnum + 1)) == FAIL)
***************
*** 2210,2225 ****
        {
            block_prep(oap, &bd, pos.lnum, FALSE);
            pos.col = bd.textcol;
!           for (todo = bd.textlen; todo > 0; --todo)
!           {
! # ifdef FEAT_MBYTE
!               if (has_mbyte)
!                   todo -= (*mb_ptr2len)(ml_get_pos(&pos)) - 1;
! # endif
!               did_change |= swapchar(oap->op_type, &pos);
!               if (inc(&pos) == -1)        /* at end of file */
!                   break;
!           }
  # ifdef FEAT_NETBEANS_INTG
            if (usingNetbeans && did_change)
            {
--- 2211,2218 ----
        {
            block_prep(oap, &bd, pos.lnum, FALSE);
            pos.col = bd.textcol;
!           did_change = swapchars(oap->op_type, &pos, bd.textlen);
! 
  # ifdef FEAT_NETBEANS_INTG
            if (usingNetbeans && did_change)
            {
***************
*** 2249,2261 ****
        else if (!oap->inclusive)
            dec(&(oap->end));
  
!       while (ltoreq(pos, oap->end))
!       {
!           did_change |= swapchar(oap->op_type, &pos);
!           if (inc(&pos) == -1)    /* at end of file */
!               break;
!       }
! 
        if (did_change)
        {
            changed_lines(oap->start.lnum, oap->start.col, oap->end.lnum + 1,
--- 2242,2248 ----
        else if (!oap->inclusive)
            dec(&(oap->end));
  
!       did_change = swapchars(oap->op_type, &pos, oap->end.col - pos.col + 1);
        if (did_change)
        {
            changed_lines(oap->start.lnum, oap->start.col, oap->end.lnum + 1,
***************
*** 2309,2314 ****
--- 2296,2337 ----
  }
  
  /*
+  * Invoke swapchar() on "length" bytes at position "pos".
+  * "pos" is advanced to just after the changed characters.
+  * "length" is rounded up to include the whole last multi-byte character.
+  * Also works correctly when the number of bytes changes.
+  * Returns TRUE if some character was changed.
+  */
+     static int
+ swapchars(op_type, pos, length)
+     int               op_type;
+     pos_T     *pos;
+     int               length;
+ {
+     int todo;
+     int       did_change = 0;
+ 
+     for (todo = length; todo > 0; --todo)
+     {
+ # ifdef FEAT_MBYTE
+       int pos_col = pos->col;
+ 
+       if (has_mbyte)
+           /* we're counting bytes, not characters */
+           todo -= (*mb_ptr2len)(ml_get_pos(pos)) - 1;
+ # endif
+       did_change |= swapchar(op_type, pos);
+ # ifdef FEAT_MBYTE
+       /* Changing German sharp s to SS increases the column. */
+       todo += pos->col - pos_col;
+ # endif
+       if (inc(pos) == -1)    /* at end of file */
+           break;
+     }
+     return did_change;
+ }
+ 
+ /*
   * If op_type == OP_UPPER: make uppercase,
   * if op_type == OP_LOWER: make lowercase,
   * if op_type == OP_ROT13: do rot13 encoding,
***************
*** 2330,2336 ****
        return FALSE;
  
  #ifdef FEAT_MBYTE
!     if (op_type == OP_UPPER && enc_latin1like && c == 0xdf)
      {
        pos_T   sp = curwin->w_cursor;
  
--- 2353,2360 ----
        return FALSE;
  
  #ifdef FEAT_MBYTE
!     if (op_type == OP_UPPER && c == 0xdf
!                     && (enc_latin1like || STRCMP(p_enc, "iso-8859-2") == 0))
      {
        pos_T   sp = curwin->w_cursor;
  
*** ../vim-7.1.239/src/version.c        Tue Jan 22 12:44:03 2008
--- src/version.c       Tue Jan 22 15:36:36 2008
***************
*** 668,669 ****
--- 668,671 ----
  {   /* Add new patch number below this line */
+ /**/
+     240,
  /**/

-- 
ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot.
        King of all Britons, defeator of the Saxons, sovereign of all England!
   [Pause]
SOLDIER: Get away!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui