From 0d3a2d063512216b20e55b59ef267dacd3640f24 Mon Sep 17 00:00:00 2001 From: deraadt Date: Mon, 29 Jan 1996 01:02:13 +0000 Subject: [PATCH] add -q option for silence; from mouse@collatz.mcrcim.mcgill.edu; netbsd pr#1204 --- usr.bin/tsort/tsort.1 | 9 +++++++-- usr.bin/tsort/tsort.c | 23 ++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/usr.bin/tsort/tsort.1 b/usr.bin/tsort/tsort.1 index cc01ace8789..9efe9b2a516 100644 --- a/usr.bin/tsort/tsort.1 +++ b/usr.bin/tsort/tsort.1 @@ -1,4 +1,4 @@ -.\" $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. @@ -45,6 +45,7 @@ .Sh SYNOPSIS .Nm tsort .Op Fl l +.Op Fl q .Op Ar file .Sh DESCRIPTION .Nm Tsort @@ -68,9 +69,13 @@ Cycles are reported on standard error. .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 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 @@ -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); } -- 2.20.1