diff options
-rw-r--r-- | source/blender/blenkernel/BKE_suggestions.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/suggestions.c | 20 |
2 files changed, 6 insertions, 16 deletions
diff --git a/source/blender/blenkernel/BKE_suggestions.h b/source/blender/blenkernel/BKE_suggestions.h index c36a2d61968..9d2aab063ab 100644 --- a/source/blender/blenkernel/BKE_suggestions.h +++ b/source/blender/blenkernel/BKE_suggestions.h @@ -54,8 +54,8 @@ struct Text; typedef struct SuggItem { struct SuggItem *prev, *next; - char *name; char type; + char name[0]; } SuggItem; typedef struct SuggList { diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c index d46fa591885..eb17e103671 100644 --- a/source/blender/blenkernel/intern/suggestions.c +++ b/source/blender/blenkernel/intern/suggestions.c @@ -35,6 +35,9 @@ #include <ctype.h> #include "MEM_guardedalloc.h" + +#include "BLI_string.h" + #include "DNA_text_types.h" #include "BKE_suggestions.h" @@ -47,18 +50,6 @@ static SuggList suggestions = {NULL, NULL, NULL, NULL, NULL}; static char *documentation = NULL; //static int doc_lines = 0; -/* TODO, replace with BLI_strncasecmp() */ -static int txttl_cmp(const char *first, const char *second, int len) -{ - int cmp, i; - for (cmp = 0, i = 0; i < len; i++) { - if ((cmp = toupper(first[i]) - toupper(second[i]))) { - break; - } - } - return cmp; -} - static void txttl_free_suggest(void) { SuggItem *item, *prev; @@ -124,7 +115,6 @@ void texttool_suggest_add(const char *name, char type) return; } - newitem->name = (char *) (newitem + 1); memcpy(newitem->name, name, len + 1); newitem->type = type; newitem->prev = newitem->next = NULL; @@ -136,7 +126,7 @@ void texttool_suggest_add(const char *name, char type) else { cmp = -1; for (item = suggestions.last; item; item = item->prev) { - cmp = txttl_cmp(name, item->name, len); + cmp = BLI_strncasecmp(name, item->name, len); /* Newitem comes after this item, insert here */ if (cmp >= 0) { @@ -177,7 +167,7 @@ void texttool_suggest_prefix(const char *prefix, const int prefix_len) first = last = NULL; for (match = suggestions.first; match; match = match->next) { - cmp = txttl_cmp(prefix, match->name, prefix_len); + cmp = BLI_strncasecmp(prefix, match->name, prefix_len); if (cmp == 0) { if (!first) { first = match; |