mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 13:58:18 +00:00
refactor: replace char_u with char
Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
@@ -59,15 +59,6 @@ char_u *vim_strsave(const char_u *string)
|
||||
/// Copy up to `len` bytes of `string` into newly allocated memory and
|
||||
/// terminate with a NUL. The allocated memory always has size `len + 1`, even
|
||||
/// when `string` is shorter.
|
||||
char_u *vim_strnsave(const char_u *string, size_t len)
|
||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
// strncpy is intentional: some parts of Vim use `string` shorter than `len`
|
||||
// and expect the remainder to be zeroed out.
|
||||
return (char_u *)strncpy(xmallocz(len), (char *)string, len);
|
||||
}
|
||||
|
||||
/// A clone of vim_strnsave() that uses char* instead of char_u*
|
||||
char *xstrnsave(const char *string, size_t len)
|
||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
@@ -318,15 +309,13 @@ char_u *vim_strsave_up(const char_u *string)
|
||||
return p1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Like vim_strnsave(), but make all characters uppercase.
|
||||
* This uses ASCII lower-to-upper case translation, language independent.
|
||||
*/
|
||||
char_u *vim_strnsave_up(const char_u *string, size_t len)
|
||||
/// Like xstrnsave(), but make all characters uppercase.
|
||||
/// This uses ASCII lower-to-upper case translation, language independent.
|
||||
char *vim_strnsave_up(const char *string, size_t len)
|
||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
char_u *p1 = vim_strnsave(string, len);
|
||||
vim_strup(p1);
|
||||
char *p1 = xstrnsave(string, len);
|
||||
vim_strup((char_u *)p1);
|
||||
return p1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user