From d056396f870e02494c7ac380b7ad2e0b2bfab186 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 10 Oct 2009 17:56:11 +0200 Subject: [PATCH] list_window: moved code to jump_match() Simplify the list_window_jump() function. --- src/list_window.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/list_window.c b/src/list_window.c index f3251d3..2a7db36 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -548,6 +548,23 @@ list_window_rfind(struct list_window *lw, return false; } +static bool +jump_match(const char *haystack, const char *needle) +{ +#ifdef NCMPC_MINI + bool jump_prefix_only = true; +#else + bool jump_prefix_only = options.jump_prefix_only; +#endif + + assert(haystack != NULL); + assert(needle != NULL); + + return jump_prefix_only + ? g_ascii_strncasecmp(haystack, needle, strlen(needle)) == 0 + : match_line(haystack, needle); +} + bool list_window_jump(struct list_window *lw, list_window_callback_fn_t callback, @@ -565,13 +582,8 @@ list_window_jump(struct list_window *lw, if (label[0] == '[') label++; -#ifndef NCMPC_MINI - if ((options.jump_prefix_only && g_ascii_strncasecmp(label, str, strlen(str)) == 0) || - (!options.jump_prefix_only && match_line(label, str))) -#else - if (g_ascii_strncasecmp(label, str, strlen(str)) == 0) -#endif - { + + if (jump_match(label, str)) { list_window_move_cursor(lw, i); return true; } -- 2.30.2