summaryrefslogtreecommitdiff
path: root/src/librc/librc-stringlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/librc/librc-stringlist.c')
-rw-r--r--src/librc/librc-stringlist.c56
1 files changed, 32 insertions, 24 deletions
diff --git a/src/librc/librc-stringlist.c b/src/librc/librc-stringlist.c
index 90e2af8..7a8f30a 100644
--- a/src/librc/librc-stringlist.c
+++ b/src/librc/librc-stringlist.c
@@ -1,7 +1,7 @@
/*
- librc-strlist.h
- String list functions to make using queue(3) a little easier.
- */
+ librc-strlist.h
+ String list functions to make using queue(3) a little easier.
+*/
/*
* Copyright 2007-2008 Roy Marples <roy@marples.name>
@@ -31,7 +31,8 @@
#include "librc.h"
-RC_STRINGLIST *rc_stringlist_new(void)
+RC_STRINGLIST *
+rc_stringlist_new(void)
{
RC_STRINGLIST *l = xmalloc(sizeof(*l));
TAILQ_INIT(l);
@@ -39,7 +40,8 @@ RC_STRINGLIST *rc_stringlist_new(void)
}
librc_hidden_def(rc_stringlist_new)
-RC_STRING *rc_stringlist_add (RC_STRINGLIST *list, const char *value)
+RC_STRING *
+rc_stringlist_add (RC_STRINGLIST *list, const char *value)
{
RC_STRING *s = xmalloc(sizeof(*s));
@@ -49,51 +51,55 @@ RC_STRING *rc_stringlist_add (RC_STRINGLIST *list, const char *value)
}
librc_hidden_def(rc_stringlist_add)
-RC_STRING *rc_stringlist_addu (RC_STRINGLIST *list, const char *value)
+RC_STRING *
+rc_stringlist_addu (RC_STRINGLIST *list, const char *value)
{
RC_STRING *s;
TAILQ_FOREACH(s, list, entries)
- if (strcmp(s->value, value) == 0) {
- errno = EEXIST;
- return NULL;
- }
+ if (strcmp(s->value, value) == 0) {
+ errno = EEXIST;
+ return NULL;
+ }
return rc_stringlist_add(list, value);
}
librc_hidden_def(rc_stringlist_addu)
-bool rc_stringlist_delete(RC_STRINGLIST *list, const char *value)
+bool
+rc_stringlist_delete(RC_STRINGLIST *list, const char *value)
{
RC_STRING *s;
TAILQ_FOREACH(s, list, entries)
- if (strcmp(s->value, value) == 0) {
- TAILQ_REMOVE(list, s, entries);
- free (s->value);
- free (s);
- return true;
- }
+ if (strcmp(s->value, value) == 0) {
+ TAILQ_REMOVE(list, s, entries);
+ free (s->value);
+ free (s);
+ return true;
+ }
errno = EEXIST;
return false;
}
librc_hidden_def(rc_stringlist_delete)
-RC_STRING *rc_stringlist_find(RC_STRINGLIST *list, const char *value)
+RC_STRING *
+rc_stringlist_find(RC_STRINGLIST *list, const char *value)
{
RC_STRING *s;
if (list) {
TAILQ_FOREACH(s, list, entries)
- if (strcmp(s->value, value) == 0)
- return s;
+ if (strcmp(s->value, value) == 0)
+ return s;
}
return NULL;
}
librc_hidden_def(rc_stringlist_find)
-RC_STRINGLIST *rc_stringlist_split(const char *value, const char *sep)
+RC_STRINGLIST *
+rc_stringlist_split(const char *value, const char *sep)
{
RC_STRINGLIST *list = rc_stringlist_new();
char *d = xstrdup(value);
@@ -107,7 +113,8 @@ RC_STRINGLIST *rc_stringlist_split(const char *value, const char *sep)
}
librc_hidden_def(rc_stringlist_split)
-void rc_stringlist_sort(RC_STRINGLIST **list)
+void
+rc_stringlist_sort(RC_STRINGLIST **list)
{
RC_STRINGLIST *l = *list;
RC_STRINGLIST *new = rc_stringlist_new();
@@ -119,7 +126,7 @@ void rc_stringlist_sort(RC_STRINGLIST **list)
TAILQ_FOREACH_SAFE(s, l, entries, sn) {
TAILQ_REMOVE(l, s, entries);
last = NULL;
- TAILQ_FOREACH (n, new, entries) {
+ TAILQ_FOREACH(n, new, entries) {
if (strcmp (s->value, n->value) < 0)
break;
last = n;
@@ -136,7 +143,8 @@ void rc_stringlist_sort(RC_STRINGLIST **list)
}
librc_hidden_def(rc_stringlist_sort)
-void rc_stringlist_free(RC_STRINGLIST *list)
+void
+rc_stringlist_free(RC_STRINGLIST *list)
{
RC_STRING *s1;
RC_STRING *s2;