aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-09-17 23:21:14 +0100
committerJames Booth <boothj5@gmail.com>2014-09-17 23:35:51 +0100
commit45ba6f1feded1c1ece03c85401b959adc8bbd93a (patch)
tree9699dea24314ca80aa3003a5e015683385f04a89 /src/tools
parentfa7b6f30000d536f45125f677a0fc820ad758e11 (diff)
downloadprofani-tty-45ba6f1feded1c1ece03c85401b959adc8bbd93a.tar.gz
Added autocompletion for form text-multi values
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/autocomplete.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index efff6ee0..842ec22a 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -115,19 +115,21 @@ autocomplete_add(Autocomplete ac, const char *item)
void
autocomplete_remove(Autocomplete ac, const char * const item)
{
- GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
+ if (ac != NULL) {
+ GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
- if (!curr) {
- return;
- }
+ if (!curr) {
+ return;
+ }
- // reset last found if it points to the item to be removed
- if (ac->last_found == curr) {
- ac->last_found = NULL;
- }
+ // 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);
+ free(curr->data);
+ ac->items = g_slist_delete_link(ac->items, curr);
+ }
return;
}