Close PR#1455. In a couple of weeks, I'll change bsd.lib.mk to use
tsort -q as well - I don't feel like adding tsort as Yet Another Item to the bootstrap target.
This commit is contained in:
parent
ed8692f377
commit
6d6a5bd8e1
@ -44,6 +44,7 @@
|
||||
.Nm tsort
|
||||
.Op Fl d
|
||||
.Op Fl l
|
||||
.Op Fl q
|
||||
.Op Ar file
|
||||
.Sh DESCRIPTION
|
||||
.Nm Tsort
|
||||
@ -72,6 +73,10 @@ Turn on debugging.
|
||||
.It Fl l
|
||||
Search for and display the longest cycle.
|
||||
Can take a very long time.
|
||||
.It Fl q
|
||||
Do not display informational messages about cycles. This is primarily
|
||||
intended for building libraries, where optimal ordering is not critical,
|
||||
and cycles occur often.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr ar 1
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: tsort.c,v 1.3 1996/06/10 16:12:43 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -43,7 +43,7 @@ static char copyright[] =
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)tsort.c 8.2 (Berkeley) 3/30/94";
|
||||
static char sccsid[] = "@(#)tsort.c 8.3 (Berkeley) 5/4/95";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -63,7 +63,7 @@ static char sccsid[] = "@(#)tsort.c 8.2 (Berkeley) 3/30/94";
|
||||
* standard output in sorted order, one per line.
|
||||
*
|
||||
* usage:
|
||||
* tsort [-l] [inputfile]
|
||||
* tsort [-dlq] [inputfile]
|
||||
* If no input file is specified, standard input is read.
|
||||
*
|
||||
* Should be compatable with AT&T tsort HOWEVER the output is not identical
|
||||
@ -100,7 +100,7 @@ typedef struct _buf {
|
||||
|
||||
DB *db;
|
||||
NODE *graph, **cycle_buf, **longest_cycle;
|
||||
int debug, longest;
|
||||
int debug, longest, quiet;
|
||||
|
||||
void add_arc __P((char *, char *));
|
||||
int find_cycle __P((NODE *, NODE *, int, int));
|
||||
@ -121,7 +121,7 @@ main(argc, argv)
|
||||
int bsize, ch, nused;
|
||||
BUF bufs[2];
|
||||
|
||||
while ((ch = getopt(argc, argv, "dl")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "dlq")) != EOF)
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
debug = 1;
|
||||
@ -129,6 +129,9 @@ main(argc, argv)
|
||||
case 'l':
|
||||
longest = 1;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
@ -337,11 +340,13 @@ tsort()
|
||||
}
|
||||
for (n = graph; n != NULL; n = n->n_next)
|
||||
if (!(n->n_flags & NF_ACYCLIC))
|
||||
if (cnt = find_cycle(n, n, 0, 0)) {
|
||||
warnx("cycle in data");
|
||||
for (i = 0; i < cnt; i++)
|
||||
warnx("%s",
|
||||
longest_cycle[i]->n_name);
|
||||
if ((cnt = find_cycle(n, n, 0, 0))) {
|
||||
if (!quiet) {
|
||||
warnx("cycle in data");
|
||||
for (i = 0; i < cnt; i++)
|
||||
warnx("%s",
|
||||
longest_cycle[i]->n_name);
|
||||
}
|
||||
remove_node(n);
|
||||
clear_cycle();
|
||||
break;
|
||||
@ -426,6 +431,6 @@ find_cycle(from, to, longest_len, depth)
|
||||
void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr, "usage: tsort [-dl] [file]\n");
|
||||
(void)fprintf(stderr, "usage: tsort [-dlq] [file]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user