diff options
-rw-r--r-- | src/grecs.hin | 2 | ||||
-rw-r--r-- | src/list.c | 25 | ||||
-rw-r--r-- | src/wordsplit.c | 2 | ||||
-rw-r--r-- | src/wordsplit.h | 2 |
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 @@ -411,2 +411,3 @@ 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); @@ -466,2 +467,3 @@ 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); @@ -202 +202,26 @@ grecs_list_index(struct grecs_list *lp, size_t idx) +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 @@ -2285,3 +2285,3 @@ 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) { diff --git a/src/wordsplit.h b/src/wordsplit.h index 53503a4..41b09e2 100644 --- a/src/wordsplit.h +++ b/src/wordsplit.h @@ -237,3 +237,3 @@ 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); |