API: nvim_get_commands(): always return keys

- Always return all keys, with at least NIL value.
- Require `opts` param to be {"builtin":false}
- Validate `opts` param
This commit is contained in:
Justin M. Keyes
2018-05-10 23:37:56 +02:00
parent 25b6304840
commit 9fa7727ce0
5 changed files with 134 additions and 100 deletions

View File

@@ -685,7 +685,7 @@ tabpage_T *find_tab_by_handle(Tabpage tabpage, Error *err)
String cchar_to_string(char c)
{
char buf[] = { c, NUL };
return (String) {
return (String){
.data = xmemdupz(buf, 1),
.size = (c != NUL) ? 1 : 0
};
@@ -701,13 +701,13 @@ String cchar_to_string(char c)
String cstr_to_string(const char *str)
{
if (str == NULL) {
return (String) STRING_INIT;
return (String)STRING_INIT;
}
size_t len = strlen(str);
return (String) {
.data = xmemdupz(str, len),
.size = len
return (String){
.data = xmemdupz(str, len),
.size = len,
};
}
@@ -722,7 +722,7 @@ String cstr_to_string(const char *str)
String cbuf_to_string(const char *buf, size_t size)
FUNC_ATTR_NONNULL_ALL
{
return (String) {
return (String){
.data = xmemdupz(buf, size),
.size = size
};
@@ -737,9 +737,9 @@ String cbuf_to_string(const char *buf, size_t size)
String cstr_as_string(char *str) FUNC_ATTR_PURE
{
if (str == NULL) {
return (String) STRING_INIT;
return (String)STRING_INIT;
}
return (String) { .data = str, .size = strlen(str) };
return (String){ .data = str, .size = strlen(str) };
}
/// Converts from type Object to a VimL value.