diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-26 13:32:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-08-26 13:41:02 +0300 |
commit | 1434ac37674cca0a5fd2802966b53b52dab3ac58 (patch) | |
tree | 68c1329612bb1fceace770108bb4070d7dcfc924 /source/blender/blenlib/BLI_string_utf8.h | |
parent | c52db4c4cf526402bded49ae192fbb6e3191e687 (diff) |
Cleanup: add ATTR_WARN_UNUSED_RESULT to BLI_string_utf8.h
Diffstat (limited to 'source/blender/blenlib/BLI_string_utf8.h')
-rw-r--r-- | source/blender/blenlib/BLI_string_utf8.h | 83 |
1 files changed, 47 insertions, 36 deletions
diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h index b97c8748ca4..a9cb13a3277 100644 --- a/source/blender/blenlib/BLI_string_utf8.h +++ b/source/blender/blenlib/BLI_string_utf8.h @@ -28,77 +28,88 @@ extern "C" { #endif char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) - ATTR_NONNULL(); -size_t BLI_strncpy_utf8_rlen(char *__restrict dst, const char *__restrict src, size_t maxncpy) - ATTR_NONNULL(); -ptrdiff_t BLI_str_utf8_invalid_byte(const char *str, size_t length) ATTR_NONNULL(); -int BLI_str_utf8_invalid_strip(char *str, size_t length) ATTR_NONNULL(); + ATTR_NONNULL(1, 2); +size_t BLI_strncpy_utf8_rlen(char *__restrict dst, + const char *__restrict src, + size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2); +ptrdiff_t BLI_str_utf8_invalid_byte(const char *str, size_t length) ATTR_NONNULL(1); +int BLI_str_utf8_invalid_strip(char *str, size_t length) ATTR_NONNULL(1); /* warning, can return -1 on bad chars */ -int BLI_str_utf8_size(const char *p) ATTR_NONNULL(); -int BLI_str_utf8_size_safe(const char *p) ATTR_NONNULL(); +int BLI_str_utf8_size(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +int BLI_str_utf8_size_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /* copied from glib */ -unsigned int BLI_str_utf8_as_unicode(const char *p) ATTR_NONNULL(); +unsigned int BLI_str_utf8_as_unicode(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t p_len, - size_t *__restrict index) ATTR_NONNULL(1, 3); -unsigned int BLI_str_utf8_as_unicode_step_or_error(const char *__restrict p, - size_t p_len, - size_t *__restrict index) ATTR_NONNULL(1, 3); + size_t *__restrict index) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1, 3); +unsigned int BLI_str_utf8_as_unicode_step_or_error( + const char *__restrict p, size_t p_len, size_t *__restrict index) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1, 3); size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf); size_t BLI_str_utf8_as_utf32(char32_t *__restrict dst_w, const char *__restrict src_c, - const size_t maxncpy) ATTR_NONNULL(); + const size_t maxncpy) ATTR_NONNULL(1, 2); size_t BLI_str_utf32_as_utf8(char *__restrict dst, const char32_t *__restrict src, - const size_t maxncpy) ATTR_NONNULL(); -size_t BLI_str_utf32_as_utf8_len(const char32_t *src) ATTR_NONNULL(); + const size_t maxncpy) ATTR_NONNULL(1, 2); +size_t BLI_str_utf32_as_utf8_len(const char32_t *src) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); -char *BLI_str_find_prev_char_utf8(const char *str, const char *p) ATTR_NONNULL(); -char *BLI_str_find_next_char_utf8(const char *p, const char *end) ATTR_NONNULL(1); -char *BLI_str_prev_char_utf8(const char *p) ATTR_NONNULL(); +char *BLI_str_find_prev_char_utf8(const char *str, const char *p) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1, 2); +char *BLI_str_find_next_char_utf8(const char *p, const char *end) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1); +char *BLI_str_prev_char_utf8(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /* wchar_t functions, copied from blenders own font.c originally */ -size_t BLI_wstrlen_utf8(const wchar_t *src) ATTR_NONNULL(); -size_t BLI_strlen_utf8_ex(const char *strc, size_t *r_len_bytes) ATTR_NONNULL(); -size_t BLI_strlen_utf8(const char *strc) ATTR_NONNULL(); +size_t BLI_wstrlen_utf8(const wchar_t *src) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; +size_t BLI_strlen_utf8_ex(const char *strc, size_t *r_len_bytes) + ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT; +size_t BLI_strlen_utf8(const char *strc) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, size_t *r_len_bytes) - ATTR_NONNULL(); -size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen) ATTR_NONNULL(); + ATTR_NONNULL(1, 3); +size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen) + ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT; size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, - const size_t maxncpy) ATTR_NONNULL(); + const size_t maxncpy) ATTR_NONNULL(1, 2); size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst, const char *__restrict src, - const size_t maxncpy) ATTR_NONNULL(); + const size_t maxncpy) ATTR_NONNULL(1, 2); /* count columns that character/string occupies, based on wcwidth.c */ -int BLI_wcwidth(char32_t ucs); -int BLI_wcswidth(const char32_t *pwcs, size_t n) ATTR_NONNULL(); +int BLI_wcwidth(char32_t ucs) ATTR_WARN_UNUSED_RESULT; +int BLI_wcswidth(const char32_t *pwcs, size_t n) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); /* warning, can return -1 on bad chars */ -int BLI_str_utf8_char_width(const char *p) ATTR_NONNULL(); -int BLI_str_utf8_char_width_safe(const char *p) ATTR_NONNULL(); +int BLI_str_utf8_char_width(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); +int BLI_str_utf8_char_width_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1); size_t BLI_str_partition_utf8(const char *str, const unsigned int delim[], const char **sep, - const char **suf) ATTR_NONNULL(); + const char **suf) ATTR_NONNULL(1, 2, 3, 4); size_t BLI_str_rpartition_utf8(const char *str, const unsigned int delim[], const char **sep, - const char **suf) ATTR_NONNULL(); + const char **suf) ATTR_NONNULL(1, 2, 3, 4); size_t BLI_str_partition_ex_utf8(const char *str, const char *end, const unsigned int delim[], const char **sep, const char **suf, - const bool from_right) ATTR_NONNULL(1, 3, 4, 5); + const bool from_right) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1, 3, 4, 5); -int BLI_str_utf8_offset_to_index(const char *str, int offset); -int BLI_str_utf8_offset_from_index(const char *str, int index); -int BLI_str_utf8_offset_to_column(const char *str, int offset); -int BLI_str_utf8_offset_from_column(const char *str, int column); +int BLI_str_utf8_offset_to_index(const char *str, int offset) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1); +int BLI_str_utf8_offset_from_index(const char *str, int index) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1); +int BLI_str_utf8_offset_to_column(const char *str, int offset) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1); +int BLI_str_utf8_offset_from_column(const char *str, int column) ATTR_WARN_UNUSED_RESULT + ATTR_NONNULL(1); #define BLI_UTF8_MAX 6 /* mem */ #define BLI_UTF8_WIDTH_MAX 2 /* columns */ |