refactor: replace char_u with char

Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
Dundar Göc
2022-08-26 23:11:25 +02:00
committed by dundargoc
parent 48ca1d4ce8
commit 49e893f296
49 changed files with 742 additions and 776 deletions

View File

@@ -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;
}