]>
Commit | Line | Data |
---|---|---|
baa3863f ER |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.1.240 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.1.240 | |
11 | Problem: When "gUe" turns a German sharp s into SS the operation stops | |
12 | before the end of the word. Latin2 has the same sharp s but it's | |
13 | not changed to SS there. | |
14 | Solution: Make sure all the characters are operated upon. Detect the sharp | |
15 | s in latin2. Also fixes that changing case of a multi-byte | |
16 | character that changes the byte cound doesn't always work. | |
17 | Files: src/ops.c | |
18 | ||
19 | ||
20 | *** ../vim-7.1.239/src/ops.c Wed Jan 16 20:01:14 2008 | |
21 | --- src/ops.c Tue Jan 22 16:00:07 2008 | |
22 | *************** | |
23 | *** 2184,2189 **** | |
24 | --- 2184,2191 ---- | |
25 | } | |
26 | #endif | |
27 | ||
28 | + static int swapchars __ARGS((int op_type, pos_T *pos, int length)); | |
29 | + | |
30 | /* | |
31 | * Handle the (non-standard vi) tilde operator. Also for "gu", "gU" and "g?". | |
32 | */ | |
33 | *************** | |
34 | *** 2194,2202 **** | |
35 | pos_T pos; | |
36 | #ifdef FEAT_VISUAL | |
37 | struct block_def bd; | |
38 | - int todo; | |
39 | #endif | |
40 | ! int did_change = 0; | |
41 | ||
42 | if (u_save((linenr_T)(oap->start.lnum - 1), | |
43 | (linenr_T)(oap->end.lnum + 1)) == FAIL) | |
44 | --- 2196,2203 ---- | |
45 | pos_T pos; | |
46 | #ifdef FEAT_VISUAL | |
47 | struct block_def bd; | |
48 | #endif | |
49 | ! int did_change; | |
50 | ||
51 | if (u_save((linenr_T)(oap->start.lnum - 1), | |
52 | (linenr_T)(oap->end.lnum + 1)) == FAIL) | |
53 | *************** | |
54 | *** 2210,2225 **** | |
55 | { | |
56 | block_prep(oap, &bd, pos.lnum, FALSE); | |
57 | pos.col = bd.textcol; | |
58 | ! for (todo = bd.textlen; todo > 0; --todo) | |
59 | ! { | |
60 | ! # ifdef FEAT_MBYTE | |
61 | ! if (has_mbyte) | |
62 | ! todo -= (*mb_ptr2len)(ml_get_pos(&pos)) - 1; | |
63 | ! # endif | |
64 | ! did_change |= swapchar(oap->op_type, &pos); | |
65 | ! if (inc(&pos) == -1) /* at end of file */ | |
66 | ! break; | |
67 | ! } | |
68 | # ifdef FEAT_NETBEANS_INTG | |
69 | if (usingNetbeans && did_change) | |
70 | { | |
71 | --- 2211,2218 ---- | |
72 | { | |
73 | block_prep(oap, &bd, pos.lnum, FALSE); | |
74 | pos.col = bd.textcol; | |
75 | ! did_change = swapchars(oap->op_type, &pos, bd.textlen); | |
76 | ! | |
77 | # ifdef FEAT_NETBEANS_INTG | |
78 | if (usingNetbeans && did_change) | |
79 | { | |
80 | *************** | |
81 | *** 2249,2261 **** | |
82 | else if (!oap->inclusive) | |
83 | dec(&(oap->end)); | |
84 | ||
85 | ! while (ltoreq(pos, oap->end)) | |
86 | ! { | |
87 | ! did_change |= swapchar(oap->op_type, &pos); | |
88 | ! if (inc(&pos) == -1) /* at end of file */ | |
89 | ! break; | |
90 | ! } | |
91 | ! | |
92 | if (did_change) | |
93 | { | |
94 | changed_lines(oap->start.lnum, oap->start.col, oap->end.lnum + 1, | |
95 | --- 2242,2248 ---- | |
96 | else if (!oap->inclusive) | |
97 | dec(&(oap->end)); | |
98 | ||
99 | ! did_change = swapchars(oap->op_type, &pos, oap->end.col - pos.col + 1); | |
100 | if (did_change) | |
101 | { | |
102 | changed_lines(oap->start.lnum, oap->start.col, oap->end.lnum + 1, | |
103 | *************** | |
104 | *** 2309,2314 **** | |
105 | --- 2296,2337 ---- | |
106 | } | |
107 | ||
108 | /* | |
109 | + * Invoke swapchar() on "length" bytes at position "pos". | |
110 | + * "pos" is advanced to just after the changed characters. | |
111 | + * "length" is rounded up to include the whole last multi-byte character. | |
112 | + * Also works correctly when the number of bytes changes. | |
113 | + * Returns TRUE if some character was changed. | |
114 | + */ | |
115 | + static int | |
116 | + swapchars(op_type, pos, length) | |
117 | + int op_type; | |
118 | + pos_T *pos; | |
119 | + int length; | |
120 | + { | |
121 | + int todo; | |
122 | + int did_change = 0; | |
123 | + | |
124 | + for (todo = length; todo > 0; --todo) | |
125 | + { | |
126 | + # ifdef FEAT_MBYTE | |
127 | + int pos_col = pos->col; | |
128 | + | |
129 | + if (has_mbyte) | |
130 | + /* we're counting bytes, not characters */ | |
131 | + todo -= (*mb_ptr2len)(ml_get_pos(pos)) - 1; | |
132 | + # endif | |
133 | + did_change |= swapchar(op_type, pos); | |
134 | + # ifdef FEAT_MBYTE | |
135 | + /* Changing German sharp s to SS increases the column. */ | |
136 | + todo += pos->col - pos_col; | |
137 | + # endif | |
138 | + if (inc(pos) == -1) /* at end of file */ | |
139 | + break; | |
140 | + } | |
141 | + return did_change; | |
142 | + } | |
143 | + | |
144 | + /* | |
145 | * If op_type == OP_UPPER: make uppercase, | |
146 | * if op_type == OP_LOWER: make lowercase, | |
147 | * if op_type == OP_ROT13: do rot13 encoding, | |
148 | *************** | |
149 | *** 2330,2336 **** | |
150 | return FALSE; | |
151 | ||
152 | #ifdef FEAT_MBYTE | |
153 | ! if (op_type == OP_UPPER && enc_latin1like && c == 0xdf) | |
154 | { | |
155 | pos_T sp = curwin->w_cursor; | |
156 | ||
157 | --- 2353,2360 ---- | |
158 | return FALSE; | |
159 | ||
160 | #ifdef FEAT_MBYTE | |
161 | ! if (op_type == OP_UPPER && c == 0xdf | |
162 | ! && (enc_latin1like || STRCMP(p_enc, "iso-8859-2") == 0)) | |
163 | { | |
164 | pos_T sp = curwin->w_cursor; | |
165 | ||
166 | *** ../vim-7.1.239/src/version.c Tue Jan 22 12:44:03 2008 | |
167 | --- src/version.c Tue Jan 22 15:36:36 2008 | |
168 | *************** | |
169 | *** 668,669 **** | |
170 | --- 668,671 ---- | |
171 | { /* Add new patch number below this line */ | |
172 | + /**/ | |
173 | + 240, | |
174 | /**/ | |
175 | ||
176 | -- | |
177 | ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot. | |
178 | King of all Britons, defeator of the Saxons, sovereign of all England! | |
179 | [Pause] | |
180 | SOLDIER: Get away! | |
181 | "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD | |
182 | ||
183 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
184 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
185 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
186 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |