]> granicus.if.org Git - graphviz/commitdiff
Alter nop to just check DOT syntax.
authorerg <devnull@localhost>
Tue, 12 Dec 2006 21:15:07 +0000 (21:15 +0000)
committererg <devnull@localhost>
Tue, 12 Dec 2006 21:15:07 +0000 (21:15 +0000)
cmd/tools/nop.1
cmd/tools/nop.c

index 76477f7961664a32e5c24ded9b8351d2e239c1fb..0230f600ab994e16c7f0b21729d230175376aeaf 100644 (file)
@@ -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)
index 82e50f0059a707474a17a93d29cc5d6c18a97dc6..185a4a51fa5c6700cfa4759f8887eb58ebffd6da 100644 (file)
 #include "config.h"
 #endif
 
-#include <agraph.h>
+typedef char Agnodeinfo_t;
+typedef char Agedgeinfo_t;
+typedef char Agraphinfo_t;
+#include <graph.h>
 #include <ingraphs.h>
 #include <stdio.h>
 #include <stdlib.h>
 #endif
 
 char **Files;
+int chkOnly;
 
-static char *useString = "Usage: nop [-?] <files>\n\
+static char *useString = "Usage: nop [-p?] <files>\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());
 }