add BLI_strcpy_rlen, replace strcat, which was used in misleading way.

This commit is contained in:
Campbell Barton 2013-06-16 08:29:02 +00:00
parent fcc4251c07
commit c9341334b1
3 changed files with 18 additions and 4 deletions

@ -72,6 +72,13 @@ __attribute__((nonnull))
#endif
;
size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src)
#ifdef __GNUC__
__attribute__((warn_unused_result))
__attribute__((nonnull))
#endif
;
char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix)
#ifdef __GNUC__
__attribute__((warn_unused_result))

@ -139,6 +139,13 @@ size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const
return srclen;
}
size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src)
{
size_t srclen = strlen(src);
memcpy(dst, src, srclen + 1);
return srclen;
}
/**
* Portable replacement for #vsnprintf
*/

@ -2371,13 +2371,13 @@ void ui_check_but(uiBut *but)
char *str = but->drawstr;
if (but->modifier_key & KM_SHIFT)
str = strcat(str, "Shift ");
str += BLI_strcpy_rlen(str, "Shift ");
if (but->modifier_key & KM_CTRL)
str = strcat(str, "Ctrl ");
str += BLI_strcpy_rlen(str, "Ctrl ");
if (but->modifier_key & KM_ALT)
str = strcat(str, "Alt ");
str += BLI_strcpy_rlen(str, "Alt ");
if (but->modifier_key & KM_OSKEY)
str = strcat(str, "Cmd ");
str += BLI_strcpy_rlen(str, "Cmd ");
(void)str; /* UNUSED */
}