texlive[60918] Build/source/texk/kpathsea: str_list_uniqify: keep
commits+karl at tug.org
commits+karl at tug.org
Mon Nov 1 18:38:51 CET 2021
Revision: 60918
http://tug.org/svn/texlive?view=revision&revision=60918
Author: karl
Date: 2021-11-01 18:38:51 +0100 (Mon, 01 Nov 2021)
Log Message:
-----------
str_list_uniqify: keep ordering, so kpsewhich -a and kpsewhich are consistent
Modified Paths:
--------------
trunk/Build/source/texk/kpathsea/ChangeLog
trunk/Build/source/texk/kpathsea/str-list.c
Modified: trunk/Build/source/texk/kpathsea/ChangeLog
===================================================================
--- trunk/Build/source/texk/kpathsea/ChangeLog 2021-11-01 00:51:07 UTC (rev 60917)
+++ trunk/Build/source/texk/kpathsea/ChangeLog 2021-11-01 17:38:51 UTC (rev 60918)
@@ -1,3 +1,10 @@
+2021-11-01 Marcel Fabian Krueger <tex at 2krueger.de>
+
+ * str-list.c (str_list_uniqify): compare each input element
+ against the elements to be returned, to keep the ordering of the
+ result the same as the input. Then the first result in a list
+ from kpsewhich -a will be the same as the result of just kpsewhich.
+
2021-05-14 Karl Berry <karl at tug.org>
* texmf.cnf (TEXINPUTS.optex): new definition for new format.
Modified: trunk/Build/source/texk/kpathsea/str-list.c
===================================================================
--- trunk/Build/source/texk/kpathsea/str-list.c 2021-11-01 00:51:07 UTC (rev 60917)
+++ trunk/Build/source/texk/kpathsea/str-list.c 2021-11-01 17:38:51 UTC (rev 60918)
@@ -128,11 +128,17 @@
for (e = 0; e < STR_LIST_LENGTH (*l); e++) {
string elt1 = STR_LIST_ELT (*l, e);
+ /* printf ("outer l[%d]: %s\n", e, elt1); */
+
+ /* Compare against known-unique list ret; this keeps the elements in
+ the return list in the same order as the input list. */
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
+ for (f = 0; f < STR_LIST_LENGTH (ret); f++) {
+ string elt2 = STR_LIST_ELT (ret, f);
+ /* printf(" inner ret[%d]: %s\n", f, elt2); */
+
+ /* I don't think our lists should ever contain NULL's, but if
+ it does, let them stay and don't bother collapsing multiple
NULL's into one. */
if (FILESTRCASEEQ (elt1, elt2)) {
break;
@@ -139,9 +145,11 @@
}
}
- if (f == STR_LIST_LENGTH (*l)) {
+ if (f == STR_LIST_LENGTH (ret)) {
+ /* printf (" added new\n"); */
str_list_add (&ret, elt1); /* not found */
} else {
+ /* printf (" skipped duplicate\n"); */
free (elt1); /* duplicate, forget this one */
}
}
@@ -149,3 +157,31 @@
/* Replace the passed list with what we constructed. */
*l = ret;
}
+
+#ifdef TEST
+int
+main ()
+{
+ unsigned e;
+ str_list_type tst = str_list_init ();
+ str_list_add (&tst, xstrdup("a"));
+ str_list_add (&tst, xstrdup("a"));
+ str_list_add (&tst, xstrdup("b"));
+ str_list_add (&tst, xstrdup("a"));
+ str_list_uniqify (&tst);
+
+ for (e = 0; e < STR_LIST_LENGTH (tst); e++) {
+ printf ("ret[%d]: %s\n", e, STR_LIST_ELT(tst, e));
+ }
+
+ return 0;
+}
+
+#endif /* TEST */
+
+
+/*
+Local variables:
+standalone-compile-command: "gcc -g -I. -I.. -I$WK -DTEST -DMAKE_KPSE_DLL str-list.c $wk/.libs/libkpathsea.a"
+End:
+*/
More information about the tex-live-commits
mailing list.