mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
message: Refactor str2specialbuf
Does not alter its usages.
This commit is contained in:
parent
e9e1668ca6
commit
832c158a66
@ -1374,19 +1374,25 @@ const char *str2special(const char **const sp, const bool replace_spaces)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Convert string, replacing key codes with printables
|
||||||
* Translate a key sequence into special key names.
|
///
|
||||||
*/
|
/// @param[in] str String to convert.
|
||||||
void str2specialbuf(char_u *sp, char_u *buf, int len)
|
/// @param[out] buf Buffer to save results to.
|
||||||
|
/// @param[in] len Buffer length.
|
||||||
|
void str2specialbuf(const char *sp, char *buf, size_t len)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
char_u *s;
|
|
||||||
|
|
||||||
*buf = NUL;
|
|
||||||
while (*sp) {
|
while (*sp) {
|
||||||
s = str2special(&sp, FALSE);
|
const char *s = str2special(&sp, false);
|
||||||
if ((int)(STRLEN(s) + STRLEN(buf)) < len)
|
const size_t s_len = strlen(s);
|
||||||
STRCAT(buf, s);
|
if (s_len <= len) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
memcpy(buf, s, s_len);
|
||||||
|
buf += s_len;
|
||||||
|
len -= s_len;
|
||||||
}
|
}
|
||||||
|
*buf = NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user