Mercurial > vim
comparison src/spell.c @ 34540:9e093c96dff6 v9.1.0172
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Commit: https://github.com/vim/vim/commit/94b7c3233ef534acc669b3083ed1fe59cf3a090b
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue Mar 12 21:50:32 2024 +0100
patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Problem: More code can use ml_get_buf_len() instead of STRLEN().
Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not
set ml_line_textlen in ml_replace_len() if "has_props" is set,
because "len_arg" also includes the size of text properties in
that case. (zeertzjq)
closes: #14183
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 12 Mar 2024 22:00:04 +0100 |
parents | 21f2838a4dd9 |
children | ffa6ed03a9f2 |
comparison
equal
deleted
inserted
replaced
34539:0dbb6f014f5e | 34540:9e093c96dff6 |
---|---|
1382 { | 1382 { |
1383 int empty_line; | 1383 int empty_line; |
1384 | 1384 |
1385 line = ml_get_buf(wp->w_buffer, lnum, FALSE); | 1385 line = ml_get_buf(wp->w_buffer, lnum, FALSE); |
1386 | 1386 |
1387 len = (int)STRLEN(line); | 1387 len = ml_get_buf_len(wp->w_buffer, lnum); |
1388 if (buflen < len + MAXWLEN + 2) | 1388 if (buflen < len + MAXWLEN + 2) |
1389 { | 1389 { |
1390 vim_free(buf); | 1390 vim_free(buf); |
1391 buflen = len + MAXWLEN + 2; | 1391 buflen = len + MAXWLEN + 2; |
1392 buf = alloc(buflen); | 1392 buf = alloc(buflen); |
2986 // when changing "etc" to "etc.". | 2986 // when changing "etc" to "etc.". |
2987 line = ml_get_curline(); | 2987 line = ml_get_curline(); |
2988 if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col, | 2988 if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col, |
2989 repl_to, repl_to_len) != 0) | 2989 repl_to, repl_to_len) != 0) |
2990 { | 2990 { |
2991 p = alloc(STRLEN(line) + addlen + 1); | 2991 p = alloc(ml_get_curline_len() + addlen + 1); |
2992 if (p == NULL) | 2992 if (p == NULL) |
2993 break; | 2993 break; |
2994 mch_memmove(p, line, curwin->w_cursor.col); | 2994 mch_memmove(p, line, curwin->w_cursor.col); |
2995 STRCPY(p + curwin->w_cursor.col, repl_to); | 2995 STRCPY(p + curwin->w_cursor.col, repl_to); |
2996 STRCAT(p, line + curwin->w_cursor.col + repl_from_len); | 2996 STRCAT(p, line + curwin->w_cursor.col + repl_from_len); |