mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Removed unused boolean result from autocomplete add and remove
Conflicts: src/tools/autocomplete.c src/tools/autocomplete.h tests/test_autocomplete.c
This commit is contained in:
parent
0821b895b7
commit
7bc2e90d5f
@ -84,12 +84,12 @@ autocomplete_length(Autocomplete ac)
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
autocomplete_add(Autocomplete ac, void *item)
|
||||
{
|
||||
if (ac->items == NULL) {
|
||||
ac->items = g_slist_append(ac->items, item);
|
||||
return TRUE;
|
||||
return;
|
||||
} else {
|
||||
GSList *curr = ac->items;
|
||||
|
||||
@ -99,7 +99,7 @@ autocomplete_add(Autocomplete ac, void *item)
|
||||
if (g_strcmp0(curr->data, item) > 0) {
|
||||
ac->items = g_slist_insert_before(ac->items,
|
||||
curr, item);
|
||||
return TRUE;
|
||||
return;
|
||||
|
||||
// update
|
||||
} else if (g_strcmp0(curr->data, item) == 0) {
|
||||
@ -107,10 +107,8 @@ autocomplete_add(Autocomplete ac, void *item)
|
||||
if (strcmp(curr->data, item) != 0) {
|
||||
free(curr->data);
|
||||
curr->data = item;
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
curr = g_slist_next(curr);
|
||||
@ -119,11 +117,11 @@ autocomplete_add(Autocomplete ac, void *item)
|
||||
// hit end, append
|
||||
ac->items = g_slist_append(ac->items, item);
|
||||
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
void
|
||||
autocomplete_remove(Autocomplete ac, const char * const item)
|
||||
{
|
||||
// reset last found if it points to the item to be removed
|
||||
@ -132,7 +130,7 @@ autocomplete_remove(Autocomplete ac, const char * const item)
|
||||
ac->last_found = NULL;
|
||||
|
||||
if (!ac->items) {
|
||||
return FALSE;
|
||||
return;
|
||||
} else {
|
||||
GSList *curr = ac->items;
|
||||
|
||||
@ -142,13 +140,13 @@ autocomplete_remove(Autocomplete ac, const char * const item)
|
||||
ac->items = g_slist_remove(ac->items, curr->data);
|
||||
free(current_item);
|
||||
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ Autocomplete autocomplete_new(void);
|
||||
void autocomplete_clear(Autocomplete ac);
|
||||
void autocomplete_reset(Autocomplete ac);
|
||||
void autocomplete_free(Autocomplete ac);
|
||||
gboolean autocomplete_add(Autocomplete ac, void *item);
|
||||
gboolean autocomplete_remove(Autocomplete ac, const char * const item);
|
||||
void autocomplete_add(Autocomplete ac, void *item);
|
||||
void autocomplete_remove(Autocomplete ac, const char * const item);
|
||||
GSList * autocomplete_get_list(Autocomplete ac);
|
||||
gchar * autocomplete_complete(Autocomplete ac, gchar *search_str);
|
||||
gint autocomplete_length(Autocomplete ac);
|
||||
|
@ -124,45 +124,6 @@ static void add_two_same_updates(void)
|
||||
autocomplete_clear(ac);
|
||||
}
|
||||
|
||||
static void add_one_returns_true(void)
|
||||
{
|
||||
char *item = strdup("Hello");
|
||||
Autocomplete ac = autocomplete_new();
|
||||
int result = autocomplete_add(ac, item);
|
||||
|
||||
assert_true(result);
|
||||
|
||||
autocomplete_clear(ac);
|
||||
}
|
||||
|
||||
static void add_two_different_returns_true(void)
|
||||
{
|
||||
char *item1 = strdup("Hello");
|
||||
char *item2 = strdup("Hello there");
|
||||
Autocomplete ac = autocomplete_new();
|
||||
int result1 = autocomplete_add(ac, item1);
|
||||
int result2 = autocomplete_add(ac, item2);
|
||||
|
||||
assert_true(result1);
|
||||
assert_true(result2);
|
||||
|
||||
autocomplete_clear(ac);
|
||||
}
|
||||
|
||||
static void add_two_same_returns_false(void)
|
||||
{
|
||||
char *item1 = strdup("Hello");
|
||||
char *item2 = strdup("Hello");
|
||||
Autocomplete ac = autocomplete_new();
|
||||
int result1 = autocomplete_add(ac, item1);
|
||||
int result2 = autocomplete_add(ac, item2);
|
||||
|
||||
assert_true(result1);
|
||||
assert_false(result2);
|
||||
|
||||
autocomplete_clear(ac);
|
||||
}
|
||||
|
||||
void register_autocomplete_tests(void)
|
||||
{
|
||||
TEST_MODULE("autocomplete tests");
|
||||
@ -176,7 +137,4 @@ void register_autocomplete_tests(void)
|
||||
TEST(add_two_adds_two);
|
||||
TEST(add_two_same_adds_one);
|
||||
TEST(add_two_same_updates);
|
||||
TEST(add_one_returns_true);
|
||||
TEST(add_two_different_returns_true);
|
||||
TEST(add_two_same_returns_false);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user