glibc/manual/tsort.awk
Paul Eggert 2b778ceb40 Update copyright dates with scripts/update-copyrights
I used these shell commands:

../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")

and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 6694 files FOO.
I then removed trailing white space from benchtests/bench-pthread-locks.c
and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this
diagnostic from Savannah:
remote: *** pre-commit check failed ...
remote: *** error: lines with trailing whitespace found
remote: error: hook declined to update refs/heads/master
2021-01-02 12:17:34 -08:00

47 lines
751 B
Awk

#!/usr/bin/awk -f
# Generate topologically sorted list of manual chapters.
# Copyright (C) 1998-2021 Free Software Foundation, Inc.
# Written by Ulrich Drepper <drepper@cygnus.com>, 1998.
BEGIN {
cnt = 0
dnt = 0
}
{
to[dnt] = $1
from[dnt] = $2
++dnt
all[cnt++] = $1
}
END {
do {
moved = 0
for (i = 0; i < dnt; ++i) {
for (j = 0; j < cnt; ++j) {
if (all[j] == from[i]) {
for (k = j + 1; k < cnt; ++k) {
if (all[k] == to[i]) {
break;
}
}
if (k < cnt) {
for (l = k - 1; l >= j; --l) {
all[l + 1] = all[l]
}
all[j] = to[i]
break;
}
}
}
if (j < cnt) {
moved = 1
break
}
}
} while (moved)
for (i = 0; i < cnt; ++i) {
print all[i];
}
}