mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
refactor: Remove strncpy/STRNCPY. (#6008)
Closes #731 References #851 Note: This does not remove some intentional legacy usages of strncpy. - memcpy isn't equivalent because it doesn't check the string length of `src`, and doesn't zero-out the remainder of `dst`. - xstrlcpy isn't equivalent because it doesn't zero-out the remainder of `dst`. Some Vim logic depends on that (e.g. ex_append which calls vim_strnsave). Helped-by: Douglas Schneider <ds3@ualberta.ca> Helped-by: oni-link <knil.ino@gmail.com> Helped-by: James McCoy <jamessan@jamessan.com>
This commit is contained in:
@@ -1608,7 +1608,7 @@ static void foldAddMarker(linenr_T lnum, char_u *marker, size_t markerlen)
|
||||
STRLCPY(newline + line_len, marker, markerlen + 1);
|
||||
else {
|
||||
STRCPY(newline + line_len, cms);
|
||||
STRNCPY(newline + line_len + (p - cms), marker, markerlen);
|
||||
memcpy(newline + line_len + (p - cms), marker, markerlen);
|
||||
STRCPY(newline + line_len + (p - cms) + markerlen, p + 2);
|
||||
}
|
||||
|
||||
@@ -1673,7 +1673,8 @@ static void foldDelMarker(linenr_T lnum, char_u *marker, size_t markerlen)
|
||||
if (u_save(lnum - 1, lnum + 1) == OK) {
|
||||
/* Make new line: text-before-marker + text-after-marker */
|
||||
newline = xmalloc(STRLEN(line) - len + 1);
|
||||
STRNCPY(newline, line, p - line);
|
||||
assert(p >= line);
|
||||
memcpy(newline, line, (size_t)(p - line));
|
||||
STRCPY(newline + (p - line), p + len);
|
||||
ml_replace(lnum, newline, FALSE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user