]> granicus.if.org Git - vim/commitdiff
updated for version 7.1-240 v7.1.240
authorBram Moolenaar <Bram@vim.org>
Tue, 22 Jan 2008 15:02:31 +0000 (15:02 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 22 Jan 2008 15:02:31 +0000 (15:02 +0000)
src/ops.c
src/version.c

index b5b064b5914e5f043a8b5e6f10bafda12e230bec..1d5d3bfa7e81ae8142f6fe7a73bf7ab65f5d15ed 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -2184,6 +2184,8 @@ op_replace(oap, c)
 }
 #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,9 +2196,8 @@ op_tilde(oap)
     pos_T              pos;
 #ifdef FEAT_VISUAL
     struct block_def   bd;
-    int                        todo;
 #endif
-    int                        did_change = 0;
+    int                        did_change;
 
     if (u_save((linenr_T)(oap->start.lnum - 1),
                                       (linenr_T)(oap->end.lnum + 1)) == FAIL)
@@ -2210,16 +2211,8 @@ op_tilde(oap)
        {
            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;
-           }
+           did_change = swapchars(oap->op_type, &pos, bd.textlen);
+
 # ifdef FEAT_NETBEANS_INTG
            if (usingNetbeans && did_change)
            {
@@ -2249,13 +2242,7 @@ op_tilde(oap)
        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;
-       }
-
+       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,
@@ -2308,6 +2295,42 @@ op_tilde(oap)
     }
 }
 
+/*
+ * 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,
@@ -2330,7 +2353,8 @@ swapchar(op_type, pos)
        return FALSE;
 
 #ifdef FEAT_MBYTE
-    if (op_type == OP_UPPER && enc_latin1like && c == 0xdf)
+    if (op_type == OP_UPPER && c == 0xdf
+                     && (enc_latin1like || STRCMP(p_enc, "iso-8859-2") == 0))
     {
        pos_T   sp = curwin->w_cursor;
 
index 94967028777f54b9b18770aeb9160db7649e9ef0..505d3a55de5052b5c776753ef6cc1f073856d28f 100644 (file)
@@ -666,6 +666,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    240,
 /**/
     239,
 /**/