diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-06-02 21:03:10 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-06-02 21:05:27 +0200 |
commit | a6782e5e60427d32ef8aecc5179c5b34fc5dcbb5 (patch) | |
tree | 87bf6f607eb8fc42b2dc04e8b92e82f7dceb4007 | |
parent | 00a8b6616f95e119e5d713cd875d0f411cb3ddfa (diff) | |
download | xK-a6782e5e60427d32ef8aecc5179c5b34fc5dcbb5.tar.gz xK-a6782e5e60427d32ef8aecc5179c5b34fc5dcbb5.tar.xz xK-a6782e5e60427d32ef8aecc5179c5b34fc5dcbb5.zip |
degesch: clean up complete_nicknames()
Using new irc_server_strncmp() instead of fnmatch().
-rw-r--r-- | degesch.c | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -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 ** |