summaryrefslogtreecommitdiff
path: root/Build/source/texk/kpathsea/str-list.c
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-12-23 00:21:33 +0000
committerKarl Berry <karl@freefriends.org>2007-12-23 00:21:33 +0000
commitff35e824456a6c889424b2a56ea65d769f1e5e19 (patch)
treece06613e09682ec54cfe6e7f847b2f629843e790 /Build/source/texk/kpathsea/str-list.c
parentbef64609b4b323e9ee4f3ac67b3769d0c192f8ec (diff)
implement kpsewhich --all for normal searches
git-svn-id: svn://tug.org/texlive/trunk@5825 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea/str-list.c')
-rw-r--r--Build/source/texk/kpathsea/str-list.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/Build/source/texk/kpathsea/str-list.c b/Build/source/texk/kpathsea/str-list.c
index 66df7b791cc..8b4ab314dfe 100644
--- a/Build/source/texk/kpathsea/str-list.c
+++ b/Build/source/texk/kpathsea/str-list.c
@@ -118,3 +118,38 @@ str_list_free P1C(str_list_type *, l)
STR_LIST (*l) = NULL;
}
}
+
+
+
+/* Remove duplicate elements from L, freeing their space. Since our
+ lists are so short, we do a maximally inefficient bubble search. */
+
+void
+str_list_uniqify P1C(str_list_type *, l)
+{
+ unsigned e;
+ str_list_type ret = str_list_init ();
+
+ for (e = 0; e < STR_LIST_LENGTH (*l); e++) {
+ string elt1 = STR_LIST_ELT (*l, e);
+ unsigned f;
+ for (f = e + 1; f < STR_LIST_LENGTH (*l); f++) {
+ string elt2 = STR_LIST_ELT (*l, f);
+ /* I don't think our list should ever contain NULL's, but if
+ it does, let it stay and don't bother collapsing multiple
+ NULL's into one. */
+ if (FILESTRCASEEQ (elt1, elt2)) {
+ break;
+ }
+ }
+
+ if (f == STR_LIST_LENGTH (*l)) {
+ str_list_add (&ret, elt1); /* not found */
+ } else {
+ free (elt1); /* duplicate, forget this one */
+ }
+ }
+
+ /* Replace the passed list with what we constructed. */
+ *l = ret;
+}