aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/tsort/tsort.c
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1996-08-02 04:50:44 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1996-08-02 04:50:44 +0000
commit8566830b43f68f69f23f63c7de28372e5d30e361 (patch)
treee427e9ed61cf946d3661078ba3e2cea69726c63b /usr.bin/tsort/tsort.c
parent992eae34215b4f95513518bf75b6a0814813b49f (diff)
downloadsrc-8566830b43f68f69f23f63c7de28372e5d30e361.tar.gz
src-8566830b43f68f69f23f63c7de28372e5d30e361.zip
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.
Notes
Notes: svn path=/head/; revision=17389
Diffstat (limited to 'usr.bin/tsort/tsort.c')
-rw-r--r--usr.bin/tsort/tsort.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/usr.bin/tsort/tsort.c b/usr.bin/tsort/tsort.c
index 0ad452cbe86f..37ce8565afc1 100644
--- a/usr.bin/tsort/tsort.c
+++ b/usr.bin/tsort/tsort.c
@@ -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);
}