degesch: clean up complete_nicknames()
Using new irc_server_strncmp() instead of fnmatch().
This commit is contained in:
parent
00a8b6616f
commit
a6782e5e60
22
degesch.c
22
degesch.c
@ -3656,6 +3656,16 @@ irc_server_strcmp (struct server *s, const char *a, const char *b)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
irc_server_strncmp (struct server *s, const char *a, const char *b, size_t n)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
while (n-- && (*a || *b))
|
||||||
|
if ((x = s->irc_tolower (*a++) - s->irc_tolower (*b++)))
|
||||||
|
return x;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
irc_cut_nickname (const char *prefix)
|
irc_cut_nickname (const char *prefix)
|
||||||
{
|
{
|
||||||
@ -6419,22 +6429,20 @@ static void
|
|||||||
complete_nicknames (struct app_context *ctx, struct completion *data,
|
complete_nicknames (struct app_context *ctx, struct completion *data,
|
||||||
const char *word, struct str_vector *output)
|
const char *word, struct str_vector *output)
|
||||||
{
|
{
|
||||||
if (ctx->current_buffer->type != BUFFER_CHANNEL)
|
struct buffer *buffer = ctx->current_buffer;
|
||||||
|
if (buffer->type != BUFFER_CHANNEL)
|
||||||
return;
|
return;
|
||||||
struct channel *channel = ctx->current_buffer->channel;
|
|
||||||
|
|
||||||
// XXX: this is a bit hackish and doesn't respect server case mapping
|
size_t word_len = strlen (word);
|
||||||
char *mask = xstrdup_printf ("%s*", word);
|
LIST_FOR_EACH (struct channel_user, iter, buffer->channel->users)
|
||||||
LIST_FOR_EACH (struct channel_user, iter, channel->users)
|
|
||||||
{
|
{
|
||||||
const char *nickname = iter->user->nickname;
|
const char *nickname = iter->user->nickname;
|
||||||
if (fnmatch (mask, nickname, 0))
|
if (irc_server_strncmp (buffer->server, word, nickname, word_len))
|
||||||
continue;
|
continue;
|
||||||
str_vector_add_owned (output, data->location == 0
|
str_vector_add_owned (output, data->location == 0
|
||||||
? xstrdup_printf ("%s:", nickname)
|
? xstrdup_printf ("%s:", nickname)
|
||||||
: xstrdup (nickname));
|
: xstrdup (nickname));
|
||||||
}
|
}
|
||||||
free (mask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char **
|
static char **
|
||||||
|
Loading…
Reference in New Issue
Block a user