Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-08-26 13:37:51 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-08-26 13:41:02 +0300
commitda17692a3df059bf6810998c4abff74cb741292d (patch)
treedc5d030305672dc52a2f616236178e0a51f70d52
parent1434ac37674cca0a5fd2802966b53b52dab3ac58 (diff)
Cleanup: use BLI_UTF8_MAX define
-rw-r--r--source/blender/blenlib/intern/string_utf8.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index cc6a192f6ba..e35e2bcca3c 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -297,8 +297,8 @@ size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst,
const size_t maxncpy)
{
const size_t maxlen = maxncpy - 1;
- /* 6 is max utf8 length of an unicode char. */
- const int64_t maxlen_secured = (int64_t)maxlen - 6;
+ /* #BLI_UTF8_MAX is max utf8 length of an unicode char. */
+ const int64_t maxlen_secured = (int64_t)maxlen - BLI_UTF8_MAX;
size_t len = 0;
BLI_assert(maxncpy != 0);
@@ -314,9 +314,9 @@ size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst,
/* We have to be more careful for the last six bytes,
* to avoid buffer overflow in case utf8-encoded char would be too long for our dst buffer. */
while (*src) {
- char t[6];
+ char t[BLI_UTF8_MAX];
size_t l = BLI_str_utf8_from_unicode((uint)*src++, t);
- BLI_assert(l <= 6);
+ BLI_assert(l <= BLI_UTF8_MAX);
if (len + l > maxlen) {
break;
}
@@ -707,8 +707,8 @@ size_t BLI_str_utf32_as_utf8(char *__restrict dst,
const size_t maxncpy)
{
const size_t maxlen = maxncpy - 1;
- /* 6 is max utf8 length of an unicode char. */
- const int64_t maxlen_secured = (int64_t)maxlen - 6;
+ /* #BLI_UTF8_MAX is max utf8 length of an unicode char. */
+ const int64_t maxlen_secured = (int64_t)maxlen - BLI_UTF8_MAX;
size_t len = 0;
BLI_assert(maxncpy != 0);
@@ -724,9 +724,9 @@ size_t BLI_str_utf32_as_utf8(char *__restrict dst,
/* We have to be more careful for the last six bytes,
* to avoid buffer overflow in case utf8-encoded char would be too long for our dst buffer. */
while (*src) {
- char t[6];
+ char t[BLI_UTF8_MAX];
size_t l = BLI_str_utf8_from_unicode((uint)*src++, t);
- BLI_assert(l <= 6);
+ BLI_assert(l <= BLI_UTF8_MAX);
if (len + l > maxlen) {
break;
}