From 9804e69fec4d7a50c62510d1213a20a8c6145af2 Mon Sep 17 00:00:00 2001 From: erg Date: Tue, 12 Dec 2006 21:15:07 +0000 Subject: [PATCH] Alter nop to just check DOT syntax. --- cmd/tools/nop.1 | 19 +++++++++++++++++++ cmd/tools/nop.c | 21 +++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/cmd/tools/nop.1 b/cmd/tools/nop.1 index 76477f796..0230f600a 100644 --- a/cmd/tools/nop.1 +++ b/cmd/tools/nop.1 @@ -3,6 +3,9 @@ nop \- pretty-print graph file .SH SYNOPSIS .B nop +[ +.B \-p? +] [ .I files ] @@ -12,5 +15,21 @@ reads a stream of graphs and prints each in pretty-printed (canonical) format on stdout. If no .I files are given, it reads from stdin. +.SH OPTIONS +The following options are supported: +.TP +.B \-p +Produce no output - just check the input for valid DOT. +.TP +.B \-? +Print usage information. +.LP +By default, +.I gc +returns the number of nodes and edges. +.SH "EXIT STATUS" +If any errors occurred while processing any input, such as a file +not found or a file containing illegal DOT, a non-zero exit value +is returned. Otherwhilse, zero is returned. .SH "SEE ALSO" wc(1), acyclic(1), gvpr(1), gvcolor(1), ccomps(1), sccmap(1), tred(1), libgraph(3) diff --git a/cmd/tools/nop.c b/cmd/tools/nop.c index 82e50f005..185a4a51f 100644 --- a/cmd/tools/nop.c +++ b/cmd/tools/nop.c @@ -18,7 +18,10 @@ #include "config.h" #endif -#include +typedef char Agnodeinfo_t; +typedef char Agedgeinfo_t; +typedef char Agraphinfo_t; +#include #include #include #include @@ -33,8 +36,10 @@ #endif char **Files; +int chkOnly; -static char *useString = "Usage: nop [-?] \n\ +static char *useString = "Usage: nop [-p?] \n\ + -p - check for valid DOT\n\ -? - print usage\n\ If no files are specified, stdin is used\n"; @@ -48,8 +53,11 @@ static void init(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, ":")) != -1) { + while ((c = getopt(argc, argv, ":p")) != -1) { switch (c) { + case 'p': + chkOnly = 1; + break; case '?': if (optopt == '?') usage(0); @@ -68,7 +76,7 @@ static void init(int argc, char *argv[]) static Agraph_t *gread(FILE * fp) { - return agread(fp, (Agdisc_t *) 0); + return agread(fp); } int main(int argc, char **argv) @@ -77,12 +85,13 @@ int main(int argc, char **argv) ingraph_state ig; init(argc, argv); + aginit (); newIngraph(&ig, Files, gread); while ((g = nextGraph(&ig)) != 0) { - agwrite(g, stdout); + if (!chkOnly) agwrite(g, stdout); agclose(g); } - exit(0); + return(ig.errors | agerrors()); } -- 2.50.0