diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-05-12 10:33:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-05-12 10:33:21 +0400 |
commit | 0d36225dd1e8ded87949d157fedb07f9d949cb30 (patch) | |
tree | 7ee65f80bc76e4d7d1e19c0ac352be957b8b69b1 /source/blender/blenlib/intern | |
parent | 7b707fff56209d8997a2d52dde6f38e67be56c31 (diff) |
quiet sign conversion warnings and reduce sign conversion for BLI_string, and BLF.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/string.c | 8 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string_cursor_utf8.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string_utf8.c | 34 |
3 files changed, 31 insertions, 15 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index ed11d122e93..aba73936975 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -43,6 +43,10 @@ #include "BLI_utildefines.h" +#ifdef __GNUC__ +# pragma GCC diagnostic error "-Wsign-conversion" +#endif + /** * Duplicates the first \a len bytes of cstring \a str * into a newly mallocN'd string and returns it. \a str @@ -146,7 +150,7 @@ size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restri BLI_assert(count > 0); BLI_assert(format != NULL); - n = vsnprintf(buffer, count, format, arg); + n = (size_t)vsnprintf(buffer, count, format, arg); if (n != -1 && n < count) { buffer[n] = '\0'; @@ -459,7 +463,7 @@ static int left_number_strcmp(const char *s1, const char *s2, int *tiebreaker) /* same number of digits, compare size of number */ if (numdigit > 0) { - int compare = strncmp(p1, p2, numdigit); + int compare = (int)strncmp(p1, p2, (size_t)numdigit); if (compare != 0) return compare; diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index 38e57cacfb4..a0d3be91607 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -36,6 +36,10 @@ #include "BLI_string_cursor_utf8.h" /* own include */ +#ifdef __GNUC__ +# pragma GCC diagnostic error "-Wsign-conversion" +#endif + typedef enum strCursorDelimType { STRCUR_DELIM_NONE, STRCUR_DELIM_ALPHANUMERIC, diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 0bb471ddb63..b8dca95ae33 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -41,6 +41,10 @@ #include "BLI_string_utf8.h" /* own include */ +#ifdef __GNUC__ +# pragma GCC diagnostic error "-Wsign-conversion" +#endif + /* from libswish3, originally called u8_isvalid(), * modified to return the index of the bad character (byte index not utf). * http://svn.swish-e.org/libswish3/trunk/src/libswish3/utf8.c r3044 - campbell */ @@ -143,7 +147,7 @@ int BLI_utf8_invalid_strip(char *str, int length) } else { /* strip, keep looking */ - memmove(str, str + 1, length); + memmove(str, str + 1, (size_t)length); tot++; } } @@ -221,7 +225,7 @@ size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict BLI_assert(maxncpy != 0); while (*src && len < maxncpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */ - len += BLI_str_utf8_from_unicode(*src++, dst + len); + len += BLI_str_utf8_from_unicode((unsigned int)*src++, dst + len); } dst[len] = '\0'; @@ -235,7 +239,7 @@ size_t BLI_wstrlen_utf8(const wchar_t *src) size_t len = 0; while (*src) { - len += BLI_str_utf8_from_unicode(*src++, NULL); + len += BLI_str_utf8_from_unicode((unsigned int)*src++, NULL); } return len; @@ -292,7 +296,7 @@ size_t BLI_strnlen_utf8(const char *start, const size_t maxlen) size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy) { - int len = 0; + size_t len = 0; if (dst_w == NULL || src_c == NULL) { return 0; @@ -443,7 +447,8 @@ int BLI_str_utf8_size_safe(const char *p) **/ unsigned int BLI_str_utf8_as_unicode(const char *p) { - int i, mask = 0, len; + int i, len; + unsigned int mask = 0; unsigned int result; const unsigned char c = (unsigned char) *p; @@ -458,7 +463,8 @@ unsigned int BLI_str_utf8_as_unicode(const char *p) /* variant that increments the length */ unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t *__restrict index) { - int i, mask = 0, len; + int i, len; + unsigned mask = 0; unsigned int result; const unsigned char c = (unsigned char) *p; @@ -466,13 +472,14 @@ unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t * if (UNLIKELY(len == -1)) return BLI_UTF8_ERR; UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR); - *index += len; + *index += (size_t)len; return result; } unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p, size_t *__restrict index) { - int i, mask = 0, len; + int i, len; + unsigned int mask = 0; unsigned int result; const unsigned char c = (unsigned char) *p; @@ -482,7 +489,7 @@ unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p, siz return c; } UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR); - *index += len; + *index += (size_t)len; return result; } @@ -490,7 +497,8 @@ unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p, siz * note, currently this also falls back to latin1 for text drawing. */ unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict index) { - int i, mask = 0, len; + int i, len; + unsigned int mask = 0; unsigned int result; unsigned char c; @@ -527,7 +535,7 @@ unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__re UTF8_GET (result, p, i, mask, len, '?'); #endif - *index += len; + *index += (size_t)len; return result; } @@ -547,8 +555,8 @@ size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf) { /* If this gets modified, also update the copy in g_string_insert_unichar() */ unsigned int len = 0; - int first; - int i; + unsigned int first; + unsigned int i; if (c < 0x80) { first = 0; |