summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/grecs.hin2
-rw-r--r--src/list.c25
-rw-r--r--src/wordsplit.c2
-rw-r--r--src/wordsplit.h2
4 files changed, 29 insertions, 2 deletions
diff --git a/src/grecs.hin b/src/grecs.hin
index b82f45a..48e2937 100644
--- a/src/grecs.hin
+++ b/src/grecs.hin
@@ -409,6 +409,7 @@ void grecs_list_remove_entry(struct grecs_list *lp,
void grecs_list_clear(struct grecs_list *lp);
void grecs_list_free(struct grecs_list *lp);
void grecs_list_add(struct grecs_list *dst, struct grecs_list *src);
+int grecs_list_compare(struct grecs_list *a, struct grecs_list *b);
int grecs_vasprintf(char **pbuf, size_t *psize, const char *fmt, va_list ap);
int grecs_asprintf(char **pbuf, size_t *psize, const char *fmt, ...);
@@ -464,6 +465,7 @@ unsigned grecs_hash_string_ci(const char *name, unsigned long hashsize);
void grecs_value_free(struct grecs_value *val);
void grecs_value_free_content(struct grecs_value *val);
void grecs_node_free(struct grecs_node *node);
+int grecs_node_unlink(struct grecs_node *node);
int grecs_tree_free(struct grecs_node *node);
enum grecs_tree_recurse_op {
diff --git a/src/list.c b/src/list.c
index 2d57fe0..f6aa6ad 100644
--- a/src/list.c
+++ b/src/list.c
@@ -200,3 +200,28 @@ grecs_list_index(struct grecs_list *lp, size_t idx)
return ep ? ep->data : NULL;
}
+int
+grecs_list_compare(struct grecs_list *a, struct grecs_list *b)
+{
+ struct grecs_list_entry *ap, *bp;
+ int (*cmp)(const void *, const void *);
+
+ if (!a)
+ return !!b;
+ else if (!b)
+ return 1;
+
+ if (grecs_list_size(a) != grecs_list_size(b))
+ return 1;
+ if (a->cmp != b->cmp)
+ return 1;
+
+ cmp = a->cmp ? a->cmp : _ptrcmp;
+
+ for (ap = a->head, bp = b->head; ap; ap = ap->next, bp = bp->next)
+ if (cmp (ap->data, bp->data))
+ return 1;
+
+ return 0;
+}
+
diff --git a/src/wordsplit.c b/src/wordsplit.c
index 86d4f4b..1045ca8 100644
--- a/src/wordsplit.c
+++ b/src/wordsplit.c
@@ -2283,7 +2283,7 @@ wordsplit_free (struct wordsplit *ws)
}
void
-wordsplit_getwords (struct wordsplit *ws, int *wordc, char ***wordv)
+wordsplit_getwords (struct wordsplit *ws, size_t *wordc, char ***wordv)
{
char **p = realloc (ws->ws_wordv,
(ws->ws_wordc + 1) * sizeof (ws->ws_wordv[0]));
diff --git a/src/wordsplit.h b/src/wordsplit.h
index 53503a4..41b09e2 100644
--- a/src/wordsplit.h
+++ b/src/wordsplit.h
@@ -235,7 +235,7 @@ int wordsplit_len (const char *s, size_t len, wordsplit_t *ws, int flags);
void wordsplit_free (wordsplit_t *ws);
void wordsplit_free_words (wordsplit_t *ws);
void wordsplit_free_envbuf (wordsplit_t *ws);
-void wordsplit_getwords (wordsplit_t *ws, int *wordc, char ***wordv);
+void wordsplit_getwords (wordsplit_t *ws, size_t *wordc, char ***wordv);
int wordsplit_c_unquote_char (int c);
int wordsplit_c_quote_char (int c);

Return to:

Send suggestions and report system problems to the System administrator.