summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2008-01-22 15:02:31 +0000
committerBram Moolenaar <Bram@vim.org>2008-01-22 15:02:31 +0000
commitb44df0af832b4f8817386d56c7b919445c407a81 (patch)
tree4bce662dbf580a85b7a76d9c6ecb7d226dd2dbb8 /src
parent9a31f881f2acb239263aafaac705059fc753b330 (diff)
updated for version 7.1-240v7.1.240
Diffstat (limited to 'src')
-rw-r--r--src/ops.c64
-rw-r--r--src/version.c2
2 files changed, 46 insertions, 20 deletions
diff --git a/src/ops.c b/src/ops.c
index b5b064b591..1d5d3bfa7e 100644
--- 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,
@@ -2309,6 +2296,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,
* if op_type == OP_ROT13: do rot13 encoding,
@@ -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;
diff --git a/src/version.c b/src/version.c
index 9496702877..505d3a55de 100644
--- a/src/version.c
+++ b/src/version.c
@@ -667,6 +667,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 240,
+/**/
239,
/**/
238,