summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/degesch.c b/degesch.c
index 23d5124..bb54c03 100644
--- a/degesch.c
+++ b/degesch.c
@@ -3656,6 +3656,16 @@ irc_server_strcmp (struct server *s, const char *a, const char *b)
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 *
irc_cut_nickname (const char *prefix)
{
@@ -6419,22 +6429,20 @@ static void
complete_nicknames (struct app_context *ctx, struct completion *data,
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;
- struct channel *channel = ctx->current_buffer->channel;
- // XXX: this is a bit hackish and doesn't respect server case mapping
- char *mask = xstrdup_printf ("%s*", word);
- LIST_FOR_EACH (struct channel_user, iter, channel->users)
+ size_t word_len = strlen (word);
+ LIST_FOR_EACH (struct channel_user, iter, buffer->channel->users)
{
const char *nickname = iter->user->nickname;
- if (fnmatch (mask, nickname, 0))
+ if (irc_server_strncmp (buffer->server, word, nickname, word_len))
continue;
str_vector_add_owned (output, data->location == 0
? xstrdup_printf ("%s:", nickname)
: xstrdup (nickname));
}
- free (mask);
}
static char **