# HG changeset patch # User vimboss # Date 1201014151 0 # Node ID 76985a406456362dbdb4e7e4bef67656b84de965 # Parent 50e0337c25cae29dd3e63b333d4bfb68cc9b3740 updated for version 7.1-240 diff --git a/src/ops.c b/src/ops.c --- 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; +#endif + 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 --- 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,