diff options
Diffstat (limited to 'src/sort.c')
-rw-r--r-- | src/sort.c | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* grecs - Gray's Extensible Configuration System | 1 | /* argot - Gray's Extensible Configuration System |
2 | Copyright (C) 2007-2016 Sergey Poznyakoff | 2 | Copyright (C) 2007-2016 Sergey Poznyakoff |
3 | 3 | ||
4 | Grecs is free software; you can redistribute it and/or modify it | 4 | Grecs is free software; you can redistribute it and/or modify it |
@@ -18,14 +18,14 @@ | |||
18 | # include <config.h> | 18 | # include <config.h> |
19 | #endif | 19 | #endif |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include "grecs.h" | 21 | #include "argot.h" |
22 | 22 | ||
23 | struct node_list { | 23 | struct node_list { |
24 | struct grecs_node *head, *tail; | 24 | struct argot_node *head, *tail; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | static void | 27 | static void |
28 | node_list_init(struct node_list *list, struct grecs_node *node) | 28 | node_list_init(struct node_list *list, struct argot_node *node) |
29 | { | 29 | { |
30 | if (node) { | 30 | if (node) { |
31 | list->head = node; | 31 | list->head = node; |
@@ -37,7 +37,7 @@ node_list_init(struct node_list *list, struct grecs_node *node) | |||
37 | } | 37 | } |
38 | 38 | ||
39 | static void | 39 | static void |
40 | node_list_add(struct node_list *list, struct grecs_node *node) | 40 | node_list_add(struct node_list *list, struct argot_node *node) |
41 | { | 41 | { |
42 | node->next = NULL; | 42 | node->next = NULL; |
43 | node->prev = list->tail; | 43 | node->prev = list->tail; |
@@ -63,10 +63,10 @@ node_list_join(struct node_list *a, struct node_list *b) | |||
63 | 63 | ||
64 | static void | 64 | static void |
65 | _qsort_nodelist(struct node_list *list, | 65 | _qsort_nodelist(struct node_list *list, |
66 | int (*compare)(struct grecs_node const *, | 66 | int (*compare)(struct argot_node const *, |
67 | struct grecs_node const *)) | 67 | struct argot_node const *)) |
68 | { | 68 | { |
69 | struct grecs_node *cur, *middle; | 69 | struct argot_node *cur, *middle; |
70 | struct node_list high_list, low_list; | 70 | struct node_list high_list, low_list; |
71 | int rc; | 71 | int rc; |
72 | 72 | ||
@@ -86,7 +86,7 @@ _qsort_nodelist(struct node_list *list, | |||
86 | node_list_init(&low_list, NULL); | 86 | node_list_init(&low_list, NULL); |
87 | node_list_init(&high_list, NULL); | 87 | node_list_init(&high_list, NULL); |
88 | for (cur = list->head; cur; ) { | 88 | for (cur = list->head; cur; ) { |
89 | struct grecs_node *next = cur->next; | 89 | struct argot_node *next = cur->next; |
90 | cur->next = NULL; | 90 | cur->next = NULL; |
91 | if (compare(middle, cur) < 0) | 91 | if (compare(middle, cur) < 0) |
92 | node_list_add(&high_list, cur); | 92 | node_list_add(&high_list, cur); |
@@ -109,10 +109,10 @@ _qsort_nodelist(struct node_list *list, | |||
109 | list->tail = low_list.tail; | 109 | list->tail = low_list.tail; |
110 | } | 110 | } |
111 | 111 | ||
112 | struct grecs_node * | 112 | struct argot_node * |
113 | grecs_nodelist_sort(struct grecs_node *node, | 113 | argot_nodelist_sort(struct argot_node *node, |
114 | int (*compare)(struct grecs_node const *, | 114 | int (*compare)(struct argot_node const *, |
115 | struct grecs_node const *)) | 115 | struct argot_node const *)) |
116 | { | 116 | { |
117 | struct node_list list; | 117 | struct node_list list; |
118 | node_list_init(&list, node); | 118 | node_list_init(&list, node); |
@@ -121,14 +121,14 @@ grecs_nodelist_sort(struct grecs_node *node, | |||
121 | } | 121 | } |
122 | 122 | ||
123 | void | 123 | void |
124 | grecs_tree_sort(struct grecs_node *node, | 124 | argot_tree_sort(struct argot_node *node, |
125 | int (*compare)(struct grecs_node const *, | 125 | int (*compare)(struct argot_node const *, |
126 | struct grecs_node const *)) | 126 | struct argot_node const *)) |
127 | { | 127 | { |
128 | if (node && node->down) { | 128 | if (node && node->down) { |
129 | node->down = grecs_nodelist_sort(node->down, compare); | 129 | node->down = argot_nodelist_sort(node->down, compare); |
130 | for (node = node->down; node; node = node->next) | 130 | for (node = node->down; node; node = node->next) |
131 | grecs_tree_sort(node, compare); | 131 | argot_tree_sort(node, compare); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||