mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 12:28:18 +00:00
ext_cmdline: added cmdline level
add cchar_to_string
This commit is contained in:

committed by
Björn Linse

parent
ab85999eb7
commit
866dadaf75
@@ -667,6 +667,22 @@ tabpage_T *find_tab_by_handle(Tabpage tabpage, Error *err)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/// Allocates a String consisting of a single char. Does not support multibyte
|
||||
/// characters. The resulting string is also NUL-terminated, to facilitate
|
||||
/// interoperating with code using C strings.
|
||||
///
|
||||
/// @param char the char to convert
|
||||
/// @return the resulting String, if the input char was NUL, an
|
||||
/// empty String is returned
|
||||
String cchar_to_string(char c)
|
||||
{
|
||||
char buf[] = { c, NUL };
|
||||
return (String) {
|
||||
.data = xmemdupz(buf, 1),
|
||||
.size = (c != NUL) ? 1 : 0
|
||||
};
|
||||
}
|
||||
|
||||
/// Copies a C string into a String (binary safe string, characters + length).
|
||||
/// The resulting string is also NUL-terminated, to facilitate interoperating
|
||||
/// with code using C strings.
|
||||
|
Reference in New Issue
Block a user