Browse Source

Merge pull request #506 from Francesco149/nuklear-string-returns-zero-fix

Fix nk_str_{append,insert}_str_utf8 always returning 0
dumblob 2 years ago
parent
commit
3a0aafb9cc
3 changed files with 7 additions and 9 deletions
  1. 4 5
      nuklear.h
  2. 1 0
      src/CHANGELOG
  3. 2 4
      src/nuklear_string.c

+ 4 - 5
nuklear.h

@@ -8439,7 +8439,6 @@ nk_str_append_text_utf8(struct nk_str *str, const char *text, int len)
 NK_API int
 NK_API int
 nk_str_append_str_utf8(struct nk_str *str, const char *text)
 nk_str_append_str_utf8(struct nk_str *str, const char *text)
 {
 {
-    int runes = 0;
     int byte_len = 0;
     int byte_len = 0;
     int num_runes = 0;
     int num_runes = 0;
     int glyph_len = 0;
     int glyph_len = 0;
@@ -8453,7 +8452,7 @@ nk_str_append_str_utf8(struct nk_str *str, const char *text)
         num_runes++;
         num_runes++;
     }
     }
     nk_str_append_text_char(str, text, byte_len);
     nk_str_append_text_char(str, text, byte_len);
-    return runes;
+    return num_runes;
 }
 }
 NK_API int
 NK_API int
 nk_str_append_text_runes(struct nk_str *str, const nk_rune *text, int len)
 nk_str_append_text_runes(struct nk_str *str, const nk_rune *text, int len)
@@ -8568,7 +8567,6 @@ nk_str_insert_text_utf8(struct nk_str *str, int pos, const char *text, int len)
 NK_API int
 NK_API int
 nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text)
 nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text)
 {
 {
-    int runes = 0;
     int byte_len = 0;
     int byte_len = 0;
     int num_runes = 0;
     int num_runes = 0;
     int glyph_len = 0;
     int glyph_len = 0;
@@ -8582,7 +8580,7 @@ nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text)
         num_runes++;
         num_runes++;
     }
     }
     nk_str_insert_at_rune(str, pos, text, byte_len);
     nk_str_insert_at_rune(str, pos, text, byte_len);
-    return runes;
+    return num_runes;
 }
 }
 NK_API int
 NK_API int
 nk_str_insert_text_runes(struct nk_str *str, int pos, const nk_rune *runes, int len)
 nk_str_insert_text_runes(struct nk_str *str, int pos, const nk_rune *runes, int len)
@@ -29656,7 +29654,8 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
 ///   - [y]: Minor version with non-breaking API and library changes
 ///   - [y]: Minor version with non-breaking API and library changes
 ///   - [z]: Patch version with no direct changes to the API
 ///   - [z]: Patch version with no direct changes to the API
 ///
 ///
-/// - 2022/08/28 (4.10.3) - Renamed the `null` texture variable to `tex_null`
+/// - 2022/10/24 (4.10.4) - Fix nk_str_{append,insert}_str_utf8 always returning 0
+/// - 2022/09/03 (4.10.3) - Renamed the `null` texture variable to `tex_null`
 /// - 2022/08/01 (4.10.2) - Fix Apple Silicon with incorrect NK_SITE_TYPE and NK_POINTER_TYPE
 /// - 2022/08/01 (4.10.2) - Fix Apple Silicon with incorrect NK_SITE_TYPE and NK_POINTER_TYPE
 /// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than
 /// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than
 ///                         nk_edit_xxx limit
 ///                         nk_edit_xxx limit

+ 1 - 0
src/CHANGELOG

@@ -7,6 +7,7 @@
 ///   - [y]: Minor version with non-breaking API and library changes
 ///   - [y]: Minor version with non-breaking API and library changes
 ///   - [z]: Patch version with no direct changes to the API
 ///   - [z]: Patch version with no direct changes to the API
 ///
 ///
+/// - 2022/10/24 (4.10.4) - Fix nk_str_{append,insert}_str_utf8 always returning 0
 /// - 2022/09/03 (4.10.3) - Renamed the `null` texture variable to `tex_null`
 /// - 2022/09/03 (4.10.3) - Renamed the `null` texture variable to `tex_null`
 /// - 2022/08/01 (4.10.2) - Fix Apple Silicon with incorrect NK_SITE_TYPE and NK_POINTER_TYPE
 /// - 2022/08/01 (4.10.2) - Fix Apple Silicon with incorrect NK_SITE_TYPE and NK_POINTER_TYPE
 /// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than
 /// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than

+ 2 - 4
src/nuklear_string.c

@@ -64,7 +64,6 @@ nk_str_append_text_utf8(struct nk_str *str, const char *text, int len)
 NK_API int
 NK_API int
 nk_str_append_str_utf8(struct nk_str *str, const char *text)
 nk_str_append_str_utf8(struct nk_str *str, const char *text)
 {
 {
-    int runes = 0;
     int byte_len = 0;
     int byte_len = 0;
     int num_runes = 0;
     int num_runes = 0;
     int glyph_len = 0;
     int glyph_len = 0;
@@ -78,7 +77,7 @@ nk_str_append_str_utf8(struct nk_str *str, const char *text)
         num_runes++;
         num_runes++;
     }
     }
     nk_str_append_text_char(str, text, byte_len);
     nk_str_append_text_char(str, text, byte_len);
-    return runes;
+    return num_runes;
 }
 }
 NK_API int
 NK_API int
 nk_str_append_text_runes(struct nk_str *str, const nk_rune *text, int len)
 nk_str_append_text_runes(struct nk_str *str, const nk_rune *text, int len)
@@ -193,7 +192,6 @@ nk_str_insert_text_utf8(struct nk_str *str, int pos, const char *text, int len)
 NK_API int
 NK_API int
 nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text)
 nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text)
 {
 {
-    int runes = 0;
     int byte_len = 0;
     int byte_len = 0;
     int num_runes = 0;
     int num_runes = 0;
     int glyph_len = 0;
     int glyph_len = 0;
@@ -207,7 +205,7 @@ nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text)
         num_runes++;
         num_runes++;
     }
     }
     nk_str_insert_at_rune(str, pos, text, byte_len);
     nk_str_insert_at_rune(str, pos, text, byte_len);
-    return runes;
+    return num_runes;
 }
 }
 NK_API int
 NK_API int
 nk_str_insert_text_runes(struct nk_str *str, int pos, const nk_rune *runes, int len)
 nk_str_insert_text_runes(struct nk_str *str, int pos, const nk_rune *runes, int len)