Use BLI_strncasecmp for text suggestions
This commit is contained in:
parent
6f2aa50a72
commit
0d59acccd3
|
@ -54,8 +54,8 @@ struct Text;
|
|||
|
||||
typedef struct SuggItem {
|
||||
struct SuggItem *prev, *next;
|
||||
char *name;
|
||||
char type;
|
||||
char name[0];
|
||||
} SuggItem;
|
||||
|
||||
typedef struct SuggList {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue