Mercurial > vim
comparison src/ex_getln.c @ 6733:5f6077b10738 v7.4.690
patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing
redraw when using CTRL-U. (Knil Ino)
Solution: Update pointers after calling ga_grow().
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 03 Apr 2015 17:11:45 +0200 |
parents | 6529590f6c43 |
children | 4ece46045a5a |
comparison
equal
deleted
inserted
replaced
6732:4ec5e61b31b3 | 6733:5f6077b10738 |
---|---|
2243 * Get the line, one character at a time. | 2243 * Get the line, one character at a time. |
2244 */ | 2244 */ |
2245 got_int = FALSE; | 2245 got_int = FALSE; |
2246 while (!got_int) | 2246 while (!got_int) |
2247 { | 2247 { |
2248 long sw; | |
2249 char_u *s; | |
2250 | |
2248 if (ga_grow(&line_ga, 40) == FAIL) | 2251 if (ga_grow(&line_ga, 40) == FAIL) |
2249 break; | 2252 break; |
2250 | 2253 |
2251 /* Get one character at a time. Don't use inchar(), it can't handle | 2254 /* Get one character at a time. Don't use inchar(), it can't handle |
2252 * special characters. */ | 2255 * special characters. */ |
2294 if (c1 == Ctrl_U) | 2297 if (c1 == Ctrl_U) |
2295 { | 2298 { |
2296 msg_col = startcol; | 2299 msg_col = startcol; |
2297 msg_clr_eos(); | 2300 msg_clr_eos(); |
2298 line_ga.ga_len = 0; | 2301 line_ga.ga_len = 0; |
2299 continue; | 2302 goto redraw; |
2300 } | 2303 } |
2301 | 2304 |
2302 if (c1 == Ctrl_T) | 2305 if (c1 == Ctrl_T) |
2303 { | 2306 { |
2304 long sw = get_sw_value(curbuf); | 2307 sw = get_sw_value(curbuf); |
2305 | |
2306 p = (char_u *)line_ga.ga_data; | 2308 p = (char_u *)line_ga.ga_data; |
2307 p[line_ga.ga_len] = NUL; | 2309 p[line_ga.ga_len] = NUL; |
2308 indent = get_indent_str(p, 8, FALSE); | 2310 indent = get_indent_str(p, 8, FALSE); |
2309 indent += sw - indent % sw; | 2311 indent += sw - indent % sw; |
2310 add_indent: | 2312 add_indent: |
2311 while (get_indent_str(p, 8, FALSE) < indent) | 2313 while (get_indent_str(p, 8, FALSE) < indent) |
2312 { | 2314 { |
2313 char_u *s = skipwhite(p); | 2315 ga_grow(&line_ga, 2); /* one more for the NUL */ |
2314 | 2316 p = (char_u *)line_ga.ga_data; |
2315 ga_grow(&line_ga, 1); | 2317 s = skipwhite(p); |
2316 mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1); | 2318 mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1); |
2317 *s = ' '; | 2319 *s = ' '; |
2318 ++line_ga.ga_len; | 2320 ++line_ga.ga_len; |
2319 } | 2321 } |
2320 redraw: | 2322 redraw: |
2359 } | 2361 } |
2360 else | 2362 else |
2361 { | 2363 { |
2362 p[line_ga.ga_len] = NUL; | 2364 p[line_ga.ga_len] = NUL; |
2363 indent = get_indent_str(p, 8, FALSE); | 2365 indent = get_indent_str(p, 8, FALSE); |
2364 --indent; | 2366 if (indent > 0) |
2365 indent -= indent % get_sw_value(curbuf); | 2367 { |
2368 --indent; | |
2369 indent -= indent % get_sw_value(curbuf); | |
2370 } | |
2366 } | 2371 } |
2367 while (get_indent_str(p, 8, FALSE) > indent) | 2372 while (get_indent_str(p, 8, FALSE) > indent) |
2368 { | 2373 { |
2369 char_u *s = skipwhite(p); | 2374 s = skipwhite(p); |
2370 | |
2371 mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1); | 2375 mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1); |
2372 --line_ga.ga_len; | 2376 --line_ga.ga_len; |
2373 } | 2377 } |
2374 goto add_indent; | 2378 goto add_indent; |
2375 } | 2379 } |