summaryrefslogtreecommitdiff
path: root/usr.bin/tsort/tsort.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-01-29 01:02:20 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-01-29 01:02:20 +0000
commit8b4b896105ace4f272080923b2b6b153f5739af4 (patch)
treea4cb65bbce510b4474098501dbfe4e8a28c496bb /usr.bin/tsort/tsort.c
parentdb55599afcb6d095a0e8dab2f531c0e7a13d1b4f (diff)
add -q option for silence; from mouse@collatz.mcrcim.mcgill.edu;
netbsd pr#1204
Diffstat (limited to 'usr.bin/tsort/tsort.c')
-rw-r--r--usr.bin/tsort/tsort.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/usr.bin/tsort/tsort.c b/usr.bin/tsort/tsort.c
index d43ba1f50da..106162dd24c 100644
--- a/usr.bin/tsort/tsort.c
+++ b/usr.bin/tsort/tsort.c
@@ -1,4 +1,4 @@
-/* $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
@@ -46,7 +46,7 @@ static char copyright[] =
#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>
@@ -103,7 +103,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));
@@ -124,7 +124,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;
@@ -132,6 +132,9 @@ main(argc, argv)
case 'l':
longest = 1;
break;
+ case 'q':
+ quiet = 1;
+ break;
case '?':
default:
usage();
@@ -341,10 +344,12 @@ 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 (!quiet) {
+ warnx("cycle in data");
+ for (i = 0; i < cnt; i++)
+ warnx("%s",
+ longest_cycle[i]->n_name);
+ }
remove_node(n);
clear_cycle();
break;
@@ -429,6 +434,6 @@ find_cycle(from, to, longest_len, depth)
void
usage()
{
- (void)fprintf(stderr, "usage: tsort [-l] [file]\n");
+ (void)fprintf(stderr, "usage: tsort [-lq] [file]\n");
exit(1);
}