.
[glibc/history.git] / manual / tsort.awk
blob8e77ffe4b695f5bbdf475afe86ce6289853054d9
1 #! /usr/bin/awk -f
2 # Generate topologically sorted list of manual chapters.
3 # (C) Copyright 1998, 1999 Free Software Foundation, Inc.
4 # Written by Ulrich Drepper <drepper@cygnus.com>, 1998.
6 BEGIN {
7 cnt = 0
8 dnt = 0
11 to[dnt] = $1
12 from[dnt] = $2
13 ++dnt
14 all[cnt++] = $1
16 END {
17 do {
18 moved = 0
19 for (i = 0; i < dnt; ++i) {
20 for (j = 0; j < cnt; ++j) {
21 if (all[j] == from[i]) {
22 for (k = j + 1; k < cnt; ++k) {
23 if (all[k] == to[i]) {
24 break;
27 if (k < cnt) {
28 for (l = k - 1; l >= j; --l) {
29 all[l + 1] = all[l]
31 all[j] = to[i]
32 break;
36 if (j < cnt) {
37 moved = 1
38 break
41 } while (moved)
43 for (i = 0; i < cnt; ++i) {
44 print all[i];