-.\" $NetBSD: tsort.1,v 1.5 1994/12/07 01:06:24 jtc Exp $
+.\" $NetBSD: tsort.1,v 1.6 1996/01/17 20:37:49 mycroft Exp $
.\"
.\" Copyright (c) 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.Sh SYNOPSIS
.Nm tsort
.Op Fl l
+.Op Fl q
.Op Ar file
.Sh DESCRIPTION
.Nm Tsort
.Pp
The options are as follows:
.Bl -tag -width Ds
-.It Fl l
+.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
-/* $NetBSD: tsort.c,v 1.10 1995/08/31 22:06:22 jtc Exp $ */
+/* $NetBSD: tsort.c,v 1.11 1996/01/17 20:37:53 mycroft Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
#if 0
static char sccsid[] = "@(#)tsort.c 8.3 (Berkeley) 5/4/95";
#endif
-static char rcsid[] = "$NetBSD: tsort.c,v 1.10 1995/08/31 22:06:22 jtc Exp $";
+static char rcsid[] = "$NetBSD: tsort.c,v 1.11 1996/01/17 20:37:53 mycroft Exp $";
#endif /* not lint */
#include <sys/types.h>
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));
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;
case 'l':
longest = 1;
break;
+ case 'q':
+ quiet = 1;
+ break;
case '?':
default:
usage();
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 (!quiet) {
+ warnx("cycle in data");
+ for (i = 0; i < cnt; i++)
+ warnx("%s",
+ longest_cycle[i]->n_name);
+ }
remove_node(n);
clear_cycle();
break;
void
usage()
{
- (void)fprintf(stderr, "usage: tsort [-l] [file]\n");
+ (void)fprintf(stderr, "usage: tsort [-lq] [file]\n");
exit(1);
}