diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-01-18 09:22:51 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-01-18 09:22:51 +0000 |
commit | d0d7d3824e562ac4033a0960257682c744c7bc61 (patch) | |
tree | 0b8e0a995d5042fe205357ff9c35ef1f91ad4d85 /manual | |
parent | 37ce12d14c4d55fef2ca8c939f111bae05ac4eb8 (diff) | |
download | glibc-d0d7d3824e562ac4033a0960257682c744c7bc61.tar.gz glibc-d0d7d3824e562ac4033a0960257682c744c7bc61.tar.xz glibc-d0d7d3824e562ac4033a0960257682c744c7bc61.zip |
Limited tsort replacement.
Diffstat (limited to 'manual')
-rw-r--r-- | manual/tsort.awk | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/manual/tsort.awk b/manual/tsort.awk new file mode 100644 index 0000000000..8e77ffe4b6 --- /dev/null +++ b/manual/tsort.awk @@ -0,0 +1,46 @@ +#! /usr/bin/awk -f +# Generate topologically sorted list of manual chapters. +# (C) Copyright 1998, 1999 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]; + } +} |