1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into plugins

This commit is contained in:
James Booth 2013-08-26 14:52:37 +01:00
commit fdae5432c8
15 changed files with 140 additions and 215 deletions

View File

@ -877,16 +877,16 @@ cmd_init(void)
commands_ac = autocomplete_new();
help_ac = autocomplete_new();
autocomplete_add(help_ac, strdup("commands"));
autocomplete_add(help_ac, strdup("basic"));
autocomplete_add(help_ac, strdup("chatting"));
autocomplete_add(help_ac, strdup("groupchat"));
autocomplete_add(help_ac, strdup("presence"));
autocomplete_add(help_ac, strdup("contacts"));
autocomplete_add(help_ac, strdup("service"));
autocomplete_add(help_ac, strdup("settings"));
autocomplete_add(help_ac, strdup("other"));
autocomplete_add(help_ac, strdup("navigation"));
autocomplete_add(help_ac, "commands");
autocomplete_add(help_ac, "basic");
autocomplete_add(help_ac, "chatting");
autocomplete_add(help_ac, "groupchat");
autocomplete_add(help_ac, "presence");
autocomplete_add(help_ac, "contacts");
autocomplete_add(help_ac, "service");
autocomplete_add(help_ac, "settings");
autocomplete_add(help_ac, "other");
autocomplete_add(help_ac, "navigation");
// load command defs into hash table
commands = g_hash_table_new(g_str_hash, g_str_equal);
@ -898,102 +898,102 @@ cmd_init(void)
g_hash_table_insert(commands, pcmd->cmd, pcmd);
// add to commands and help autocompleters
autocomplete_add(commands_ac, (gchar *)strdup(pcmd->cmd));
autocomplete_add(help_ac, (gchar *)strdup(pcmd->cmd+1));
autocomplete_add(commands_ac, pcmd->cmd);
autocomplete_add(help_ac, pcmd->cmd+1);
}
prefs_ac = autocomplete_new();
autocomplete_add(prefs_ac, strdup("ui"));
autocomplete_add(prefs_ac, strdup("desktop"));
autocomplete_add(prefs_ac, strdup("chat"));
autocomplete_add(prefs_ac, strdup("log"));
autocomplete_add(prefs_ac, strdup("conn"));
autocomplete_add(prefs_ac, strdup("presence"));
autocomplete_add(prefs_ac, "ui");
autocomplete_add(prefs_ac, "desktop");
autocomplete_add(prefs_ac, "chat");
autocomplete_add(prefs_ac, "log");
autocomplete_add(prefs_ac, "conn");
autocomplete_add(prefs_ac, "presence");
notify_ac = autocomplete_new();
autocomplete_add(notify_ac, strdup("message"));
autocomplete_add(notify_ac, strdup("typing"));
autocomplete_add(notify_ac, strdup("remind"));
autocomplete_add(notify_ac, strdup("invite"));
autocomplete_add(notify_ac, strdup("sub"));
autocomplete_add(notify_ac, "message");
autocomplete_add(notify_ac, "typing");
autocomplete_add(notify_ac, "remind");
autocomplete_add(notify_ac, "invite");
autocomplete_add(notify_ac, "sub");
sub_ac = autocomplete_new();
autocomplete_add(sub_ac, strdup("request"));
autocomplete_add(sub_ac, strdup("allow"));
autocomplete_add(sub_ac, strdup("deny"));
autocomplete_add(sub_ac, strdup("show"));
autocomplete_add(sub_ac, strdup("sent"));
autocomplete_add(sub_ac, strdup("received"));
autocomplete_add(sub_ac, "request");
autocomplete_add(sub_ac, "allow");
autocomplete_add(sub_ac, "deny");
autocomplete_add(sub_ac, "show");
autocomplete_add(sub_ac, "sent");
autocomplete_add(sub_ac, "received");
titlebar_ac = autocomplete_new();
autocomplete_add(titlebar_ac, strdup("version"));
autocomplete_add(titlebar_ac, "version");
log_ac = autocomplete_new();
autocomplete_add(log_ac, strdup("maxsize"));
autocomplete_add(log_ac, "maxsize");
autoaway_ac = autocomplete_new();
autocomplete_add(autoaway_ac, strdup("mode"));
autocomplete_add(autoaway_ac, strdup("time"));
autocomplete_add(autoaway_ac, strdup("message"));
autocomplete_add(autoaway_ac, strdup("check"));
autocomplete_add(autoaway_ac, "mode");
autocomplete_add(autoaway_ac, "time");
autocomplete_add(autoaway_ac, "message");
autocomplete_add(autoaway_ac, "check");
autoaway_mode_ac = autocomplete_new();
autocomplete_add(autoaway_mode_ac, strdup("away"));
autocomplete_add(autoaway_mode_ac, strdup("idle"));
autocomplete_add(autoaway_mode_ac, strdup("off"));
autocomplete_add(autoaway_mode_ac, "away");
autocomplete_add(autoaway_mode_ac, "idle");
autocomplete_add(autoaway_mode_ac, "off");
theme_ac = autocomplete_new();
autocomplete_add(theme_ac, strdup("list"));
autocomplete_add(theme_ac, strdup("set"));
autocomplete_add(theme_ac, "list");
autocomplete_add(theme_ac, "set");
disco_ac = autocomplete_new();
autocomplete_add(disco_ac, strdup("info"));
autocomplete_add(disco_ac, strdup("items"));
autocomplete_add(disco_ac, "info");
autocomplete_add(disco_ac, "items");
account_ac = autocomplete_new();
autocomplete_add(account_ac, strdup("list"));
autocomplete_add(account_ac, strdup("show"));
autocomplete_add(account_ac, strdup("add"));
autocomplete_add(account_ac, strdup("enable"));
autocomplete_add(account_ac, strdup("disable"));
autocomplete_add(account_ac, strdup("rename"));
autocomplete_add(account_ac, strdup("set"));
autocomplete_add(account_ac, "list");
autocomplete_add(account_ac, "show");
autocomplete_add(account_ac, "add");
autocomplete_add(account_ac, "enable");
autocomplete_add(account_ac, "disable");
autocomplete_add(account_ac, "rename");
autocomplete_add(account_ac, "set");
close_ac = autocomplete_new();
autocomplete_add(close_ac, strdup("read"));
autocomplete_add(close_ac, strdup("all"));
autocomplete_add(close_ac, "read");
autocomplete_add(close_ac, "all");
wins_ac = autocomplete_new();
autocomplete_add(wins_ac, strdup("prune"));
autocomplete_add(wins_ac, strdup("tidy"));
autocomplete_add(wins_ac, "prune");
autocomplete_add(wins_ac, "tidy");
roster_ac = autocomplete_new();
autocomplete_add(roster_ac, strdup("add"));
autocomplete_add(roster_ac, strdup("nick"));
autocomplete_add(roster_ac, strdup("remove"));
autocomplete_add(roster_ac, "add");
autocomplete_add(roster_ac, "nick");
autocomplete_add(roster_ac, "remove");
group_ac = autocomplete_new();
autocomplete_add(group_ac, strdup("show"));
autocomplete_add(group_ac, strdup("add"));
autocomplete_add(group_ac, strdup("remove"));
autocomplete_add(group_ac, "show");
autocomplete_add(group_ac, "add");
autocomplete_add(group_ac, "remove");
theme_load_ac = NULL;
who_ac = autocomplete_new();
autocomplete_add(who_ac, strdup("chat"));
autocomplete_add(who_ac, strdup("online"));
autocomplete_add(who_ac, strdup("away"));
autocomplete_add(who_ac, strdup("xa"));
autocomplete_add(who_ac, strdup("dnd"));
autocomplete_add(who_ac, strdup("offline"));
autocomplete_add(who_ac, strdup("available"));
autocomplete_add(who_ac, strdup("unavailable"));
autocomplete_add(who_ac, strdup("any"));
autocomplete_add(who_ac, "chat");
autocomplete_add(who_ac, "online");
autocomplete_add(who_ac, "away");
autocomplete_add(who_ac, "xa");
autocomplete_add(who_ac, "dnd");
autocomplete_add(who_ac, "offline");
autocomplete_add(who_ac, "available");
autocomplete_add(who_ac, "unavailable");
autocomplete_add(who_ac, "any");
bookmark_ac = autocomplete_new();
autocomplete_add(bookmark_ac, strdup("add"));
autocomplete_add(bookmark_ac, strdup("list"));
autocomplete_add(bookmark_ac, strdup("remove"));
autocomplete_add(bookmark_ac, "add");
autocomplete_add(bookmark_ac, "list");
autocomplete_add(bookmark_ac, "remove");
cmd_history_init();
}
@ -3820,7 +3820,7 @@ _theme_autocomplete(char *input, int *size)
theme_load_ac = autocomplete_new();
GSList *themes = theme_list();
while (themes != NULL) {
autocomplete_add(theme_load_ac, strdup(themes->data));
autocomplete_add(theme_load_ac, themes->data);
themes = g_slist_next(themes);
}
g_slist_free(themes);

View File

@ -225,32 +225,6 @@ prof_getline(FILE *stream)
return s;
}
int
octet_compare(unsigned char *str1, unsigned char *str2)
{
if ((strcmp((char *)str1, "") == 0) && (strcmp((char *)str2, "") == 0)) {
return 0;
}
if ((strcmp((char *)str1, "") == 0) && (strcmp((char *)str2, "") != 0)) {
return -1;
}
if ((strcmp((char *)str1, "") != 0) && (strcmp((char *)str2, "") == 0)) {
return 1;
}
if (str1[0] == str2[0]) {
return octet_compare(&str1[1], &str2[1]);
}
if (str1[0] < str2[0]) {
return -1;
}
return 1;
}
char *
release_get_latest()
{

View File

@ -79,7 +79,6 @@ char * str_replace(const char *string, const char *substr,
int str_contains(char str[], int size, char ch);
char* encode_xml(const char * const xml);
char * prof_getline(FILE *stream);
int octet_compare(unsigned char *str1, unsigned char *str2);
char* release_get_latest(void);
gboolean release_is_new(char *found_version);
gchar * xdg_get_config_home(void);

View File

@ -64,9 +64,9 @@ accounts_load(void)
gsize i;
for (i = 0; i < naccounts; i++) {
autocomplete_add(all_ac, strdup(account_names[i]));
autocomplete_add(all_ac, account_names[i]);
if (g_key_file_get_boolean(accounts, account_names[i], "enabled", NULL)) {
autocomplete_add(enabled_ac, strdup(account_names[i]));
autocomplete_add(enabled_ac, account_names[i]);
}
_fix_legacy_accounts(account_names[i]);
@ -138,8 +138,8 @@ accounts_add(const char *account_name, const char *altdomain)
g_key_file_set_integer(accounts, account_name, "priority.dnd", 0);
_save_accounts();
autocomplete_add(all_ac, strdup(account_name));
autocomplete_add(enabled_ac, strdup(account_name));
autocomplete_add(all_ac, account_name);
autocomplete_add(enabled_ac, account_name);
}
jid_destroy(jid);
@ -260,7 +260,7 @@ accounts_enable(const char * const name)
if (g_key_file_has_group(accounts, name)) {
g_key_file_set_boolean(accounts, name, "enabled", TRUE);
_save_accounts();
autocomplete_add(enabled_ac, strdup(name));
autocomplete_add(enabled_ac, name);
return TRUE;
} else {
return FALSE;
@ -273,7 +273,7 @@ accounts_disable(const char * const name)
if (g_key_file_has_group(accounts, name)) {
g_key_file_set_boolean(accounts, name, "enabled", FALSE);
_save_accounts();
autocomplete_remove(enabled_ac, strdup(name));
autocomplete_remove(enabled_ac, name);
return TRUE;
} else {
return FALSE;
@ -317,11 +317,11 @@ accounts_rename(const char * const account_name, const char * const new_name)
g_key_file_remove_group(accounts, account_name, NULL);
_save_accounts();
autocomplete_remove(all_ac, strdup(account_name));
autocomplete_add(all_ac, strdup(new_name));
autocomplete_remove(all_ac, account_name);
autocomplete_add(all_ac, new_name);
if (g_key_file_get_boolean(accounts, new_name, "enabled", NULL)) {
autocomplete_remove(enabled_ac, strdup(account_name));
autocomplete_add(enabled_ac, strdup(new_name));
autocomplete_remove(enabled_ac, account_name);
autocomplete_add(enabled_ac, new_name);
}
return TRUE;

View File

@ -77,8 +77,8 @@ prefs_load(void)
}
boolean_choice_ac = autocomplete_new();
autocomplete_add(boolean_choice_ac, strdup("on"));
autocomplete_add(boolean_choice_ac, strdup("off"));
autocomplete_add(boolean_choice_ac, "on");
autocomplete_add(boolean_choice_ac, "off");
}
void

View File

@ -57,7 +57,7 @@ muc_init(void)
void
muc_add_invite(char *room)
{
autocomplete_add(invite_ac, strdup(room));
autocomplete_add(invite_ac, room);
}
void
@ -298,7 +298,7 @@ muc_add_to_roster(const char * const room, const char * const nick,
if (old == NULL) {
updated = TRUE;
autocomplete_add(chat_room->nick_ac, strdup(nick));
autocomplete_add(chat_room->nick_ac, nick);
} else if ((g_strcmp0(p_contact_presence(old), show) != 0) ||
(g_strcmp0(p_contact_status(old), status) != 0)) {
updated = TRUE;

View File

@ -83,71 +83,39 @@ autocomplete_length(Autocomplete ac)
}
gboolean
autocomplete_add(Autocomplete ac, void *item)
autocomplete_add(Autocomplete ac, const char *item)
{
if (ac->items == NULL) {
ac->items = g_slist_append(ac->items, item);
return TRUE;
} else {
GSList *curr = ac->items;
char *item_cpy;
GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
while(curr) {
// insert
if (g_strcmp0(curr->data, item) > 0) {
ac->items = g_slist_insert_before(ac->items,
curr, item);
return TRUE;
// update
} else if (g_strcmp0(curr->data, item) == 0) {
// only update if data different
if (strcmp(curr->data, item) != 0) {
free(curr->data);
curr->data = item;
return TRUE;
} else {
return FALSE;
}
}
curr = g_slist_next(curr);
}
// hit end, append
ac->items = g_slist_append(ac->items, item);
return TRUE;
// if item already exists
if (curr != NULL) {
return FALSE;
}
item_cpy = strdup(item);
ac->items = g_slist_insert_sorted(ac->items, item_cpy, (GCompareFunc)strcmp);
return TRUE;
}
gboolean
autocomplete_remove(Autocomplete ac, const char * const item)
{
// reset last found if it points to the item to be removed
if (ac->last_found != NULL)
if (g_strcmp0(ac->last_found->data, item) == 0)
ac->last_found = NULL;
if (!ac->items) {
return FALSE;
} else {
GSList *curr = ac->items;
while(curr) {
if (g_strcmp0(curr->data, item) == 0) {
void *current_item = curr->data;
ac->items = g_slist_remove(ac->items, curr->data);
free(current_item);
return TRUE;
}
curr = g_slist_next(curr);
}
GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
if (!curr) {
return FALSE;
}
// reset last found if it points to the item to be removed
if (ac->last_found == curr) {
ac->last_found = NULL;
}
free(curr->data);
ac->items = g_slist_delete_link(ac->items, curr);
return TRUE;
}
GSList *

View File

@ -38,7 +38,7 @@ Autocomplete obj_autocomplete_new(PStrFunc str_func, PCopyFunc copy_func,
void autocomplete_clear(Autocomplete ac);
void autocomplete_reset(Autocomplete ac);
void autocomplete_free(Autocomplete ac);
gboolean autocomplete_add(Autocomplete ac, void *item);
gboolean autocomplete_add(Autocomplete ac, const char *item);
gboolean autocomplete_remove(Autocomplete ac, const char * const item);
GSList * autocomplete_get_list(Autocomplete ac);
gchar * autocomplete_complete(Autocomplete ac, gchar *search_str);

View File

@ -69,7 +69,7 @@ bookmark_add(const char *jid, const char *nick, gboolean autojoin)
/* this may be command for modifying */
autocomplete_remove(bookmark_ac, jid);
autocomplete_add(bookmark_ac, strdup(jid));
autocomplete_add(bookmark_ac, jid);
}
void
@ -174,7 +174,7 @@ _bookmark_handle_result(xmpp_conn_t * const conn,
autojoin_val = FALSE;
}
autocomplete_add(bookmark_ac, strdup(jid));
autocomplete_add(bookmark_ac, jid);
item = malloc(sizeof(*item));
item->jid = strdup(jid);
item->nick = name;

View File

@ -148,15 +148,15 @@ caps_create_sha1_str(xmpp_stanza_t * const query)
g_string_append(identity_str, name);
}
g_string_append(identity_str, "<");
identities = g_slist_insert_sorted(identities, g_strdup(identity_str->str), (GCompareFunc)octet_compare);
identities = g_slist_insert_sorted(identities, g_strdup(identity_str->str), (GCompareFunc)strcmp);
g_string_free(identity_str, TRUE);
} else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_FEATURE) == 0) {
feature_str = xmpp_stanza_get_attribute(child, "var");
features = g_slist_insert_sorted(features, g_strdup(feature_str), (GCompareFunc)octet_compare);
features = g_slist_insert_sorted(features, g_strdup(feature_str), (GCompareFunc)strcmp);
} else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_X) == 0) {
if (strcmp(xmpp_stanza_get_ns(child), STANZA_NS_DATA) == 0) {
form = stanza_create_form(child);
form_names = g_slist_insert_sorted(form_names, g_strdup(form->form_type), (GCompareFunc)octet_compare);
form_names = g_slist_insert_sorted(form_names, g_strdup(form->form_type), (GCompareFunc)strcmp);
g_hash_table_insert(forms, g_strdup(form->form_type), form);
}
}

View File

@ -247,7 +247,7 @@ _iq_handle_version_get(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
xmpp_send(conn, response);
g_free(version_str);
g_string_free(version_str, TRUE);
xmpp_stanza_release(name_txt);
xmpp_stanza_release(version_txt);
xmpp_stanza_release(name);

View File

@ -372,7 +372,7 @@ _subscribe_handler(xmpp_conn_t * const conn,
}
prof_handle_subscription(from_jid->barejid, PRESENCE_SUBSCRIBE);
autocomplete_add(sub_requests_ac, strdup(from_jid->barejid));
autocomplete_add(sub_requests_ac, from_jid->barejid);
jid_destroy(from_jid);

View File

@ -185,12 +185,12 @@ roster_add(const char * const barejid, const char * const name, GSList *groups,
// add groups
while (groups != NULL) {
autocomplete_add(groups_ac, strdup(groups->data));
autocomplete_add(groups_ac, groups->data);
groups = g_slist_next(groups);
}
g_hash_table_insert(contacts, strdup(barejid), contact);
autocomplete_add(barejid_ac, strdup(barejid));
autocomplete_add(barejid_ac, barejid);
_add_name_and_barejid(name, barejid);
if (!from_initial) {
@ -227,7 +227,7 @@ roster_update(const char * const barejid, const char * const name,
// add groups
while (groups != NULL) {
autocomplete_add(groups_ac, strdup(groups->data));
autocomplete_add(groups_ac, groups->data);
groups = g_slist_next(groups);
}
}
@ -249,7 +249,7 @@ roster_update_presence(const char * const barejid, Resource *resource,
}
p_contact_set_presence(contact, resource);
Jid *jid = jid_create_from_bare_and_resource(barejid, resource->name);
autocomplete_add(fulljid_ac, strdup(jid->fulljid));
autocomplete_add(fulljid_ac, jid->fulljid);
jid_destroy(jid);
return TRUE;
@ -649,10 +649,10 @@ static void
_add_name_and_barejid(const char * const name, const char * const barejid)
{
if (name != NULL) {
autocomplete_add(name_ac, strdup(name));
autocomplete_add(name_ac, name);
g_hash_table_insert(name_to_barejid, strdup(name), strdup(barejid));
} else {
autocomplete_add(name_ac, strdup(barejid));
autocomplete_add(name_ac, barejid);
g_hash_table_insert(name_to_barejid, strdup(barejid), strdup(barejid));
}
}

View File

@ -853,7 +853,7 @@ stanza_create_form(xmpp_stanza_t * const stanza)
while (value != NULL) {
char *text = xmpp_stanza_get_text(value);
if (text != NULL) {
field->values = g_slist_insert_sorted(field->values, strdup(text), (GCompareFunc)octet_compare);
field->values = g_slist_insert_sorted(field->values, strdup(text), (GCompareFunc)strcmp);
xmpp_free(ctx, text);
}
value = xmpp_stanza_get_next(value);
@ -997,5 +997,5 @@ stanza_get_presence_string_from_type(resource_presence_t presence_type)
static int
_field_compare(FormField *f1, FormField *f2)
{
return octet_compare((unsigned char *)f1->var, (unsigned char *)f2->var);
return strcmp(f1->var, f2->var);
}

View File

@ -39,9 +39,8 @@ static void get_after_create_returns_null(void)
static void add_one_and_complete(void)
{
char *item = strdup("Hello");
Autocomplete ac = autocomplete_new();
autocomplete_add(ac, item);
autocomplete_add(ac, "Hello");
char *result = autocomplete_complete(ac, "Hel");
assert_string_equals("Hello", result);
@ -51,11 +50,9 @@ static void add_one_and_complete(void)
static void add_two_and_complete_returns_first(void)
{
char *item1 = strdup("Hello");
char *item2 = strdup("Help");
Autocomplete ac = autocomplete_new();
autocomplete_add(ac, item1);
autocomplete_add(ac, item2);
autocomplete_add(ac, "Hello");
autocomplete_add(ac, "Help");
char *result = autocomplete_complete(ac, "Hel");
assert_string_equals("Hello", result);
@ -65,11 +62,9 @@ static void add_two_and_complete_returns_first(void)
static void add_two_and_complete_returns_second(void)
{
char *item1 = strdup("Hello");
char *item2 = strdup("Help");
Autocomplete ac = autocomplete_new();
autocomplete_add(ac, item1);
autocomplete_add(ac, item2);
autocomplete_add(ac, "Hello");
autocomplete_add(ac, "Help");
char *result1 = autocomplete_complete(ac, "Hel");
char *result2 = autocomplete_complete(ac, result1);
@ -80,11 +75,9 @@ static void add_two_and_complete_returns_second(void)
static void add_two_adds_two(void)
{
char *item1 = strdup("Hello");
char *item2 = strdup("Help");
Autocomplete ac = autocomplete_new();
autocomplete_add(ac, item1);
autocomplete_add(ac, item2);
autocomplete_add(ac, "Hello");
autocomplete_add(ac, "Help");
GSList *result = autocomplete_get_list(ac);
assert_int_equals(2, g_slist_length(result));
@ -94,11 +87,9 @@ static void add_two_adds_two(void)
static void add_two_same_adds_one(void)
{
char *item1 = strdup("Hello");
char *item2 = strdup("Hello");
Autocomplete ac = autocomplete_new();
autocomplete_add(ac, item1);
autocomplete_add(ac, item2);
autocomplete_add(ac, "Hello");
autocomplete_add(ac, "Hello");
GSList *result = autocomplete_get_list(ac);
assert_int_equals(1, g_slist_length(result));
@ -108,11 +99,9 @@ static void add_two_same_adds_one(void)
static void add_two_same_updates(void)
{
char *item1 = strdup("Hello");
char *item2 = strdup("Hello");
Autocomplete ac = autocomplete_new();
autocomplete_add(ac, item1);
autocomplete_add(ac, item2);
autocomplete_add(ac, "Hello");
autocomplete_add(ac, "Hello");
GSList *result = autocomplete_get_list(ac);
GSList *first = g_slist_nth(result, 0);
@ -126,9 +115,8 @@ static void add_two_same_updates(void)
static void add_one_returns_true(void)
{
char *item = strdup("Hello");
Autocomplete ac = autocomplete_new();
int result = autocomplete_add(ac, item);
int result = autocomplete_add(ac, "Hello");
assert_true(result);
@ -137,11 +125,9 @@ static void add_one_returns_true(void)
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);
int result1 = autocomplete_add(ac, "Hello");
int result2 = autocomplete_add(ac, "Hello there");
assert_true(result1);
assert_true(result2);
@ -151,11 +137,9 @@ static void add_two_different_returns_true(void)
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);
int result1 = autocomplete_add(ac, "Hello");
int result2 = autocomplete_add(ac, "Hello");
assert_true(result1);
assert_false(result2);