diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-06-16 12:29:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-06-16 12:29:02 +0400 |
commit | c9341334b17db0df98c9f01142fc954e77962823 (patch) | |
tree | 83cf6c74122d51d27d3af70a2f89de8361b8eb54 /source | |
parent | fcc4251c07c6bc4ca5a121d224d40d3655af9a03 (diff) |
add BLI_strcpy_rlen, replace strcat, which was used in misleading way.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_string.h | 7 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string.c | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 8 |
3 files changed, 18 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 770a4c0e3ab..c6f0bc49c9b 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -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)) diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index aba73936975..9d811aba503 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -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 */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index cb0784397ef..5a1ba8f31f0 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -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 */ } |