1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-06-30 19:46:46 +02:00

replace name_compare with lib function

This commit is contained in:
Jfreegman
2013-12-08 01:18:10 -05:00
parent b8b032e441
commit e834821348
4 changed files with 7 additions and 22 deletions

View File

@ -158,25 +158,10 @@ void alert_window(ToxWindow *self, int type, bool is_beep)
beep();
}
/* case-insensitive string compare function for use with qsort - same return logic as strcmp */
int name_compare(const void *nick1, const void *nick2)
/* case-insensitive string compare function for use with qsort */
int qsort_strcasecmp_hlpr(const void *nick1, const void *nick2)
{
char s[TOX_MAX_NAME_LENGTH];
char t[TOX_MAX_NAME_LENGTH];
strcpy(s, (const char *) nick1);
strcpy(t, (const char *) nick2);
int i;
for (i = 0; s[i] && t[i]; ++i) {
s[i] = tolower(s[i]);
t[i] = tolower(t[i]);
if (s[i] != t[i])
break;
}
return s[i] - t[i];
return strcasecmp((const char *) nick1, (const char *) nick2);
}
/* Returns true if nick is valid. A valid toxic nick: