chiark / gitweb /
layout/redactgraph: specify graph name for neato, -t option
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 28 Nov 2010 15:43:37 +0000 (15:43 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 28 Nov 2010 15:43:37 +0000 (15:43 +0000)
layout/Makefile
layout/redactgraph.c

index 6bde4b2054f1b4619e07ba2f8a194c1f64e4d038..3b86ddf37bdc26326348256132b7a3439f8ecbc0 100644 (file)
@@ -97,13 +97,13 @@ LARGE_PS_FACTOR=3
                ./psenlarge ${LARGE_PS_FACTOR} $< $o
 
 %.raw.neato:   %.redactgraph
-               ./$< consistency printforneato $o
+               ./$< -t$@ consistency printforneato $o
 
 %.redacted.neato: %.redactgraph
-               ./$< $(REDACT) consistency printforneato $o
+               ./$< -t$@ $(REDACT) consistency printforneato $o
 
 %.summary.neato: %.redactgraph
-               ./$< $(REDACT) consistency printforneatosumm $o
+               ./$< -t$@ $(REDACT) consistency printforneatosumm $o
 
 %.redacted.forsafety: %.redactgraph
                ./$< $(REDACT) consistency printforforsafety $o
index 32d5221fb46f663590c833b5f7e275f360b272ce..af1ef54b18c4a6fdd6fd74388d3f92ce45e38b12 100644 (file)
@@ -44,6 +44,8 @@
 #define MMALLOC(sz) mmalloc(sz,__FILE__,__LINE__)
 #define MREALLOC(p,sz) mrealloc(p,sz,__FILE__,__LINE__)
 
+static const char *title= "L";
+
 static void *mmalloccheck(void *p, const char *op, size_t sz,
                          const char *file, int line) {
   if (p) return p;
@@ -677,7 +679,7 @@ static void printforneato(void) {
   Edge *edge;
   int side;
   
-  output("digraph L {\n");
+  output("digraph \"%s\" {\n", title);
 
   FOR_ALL_NODES(node) {
     output("  n%sO [label=\"%s\"];\n"
@@ -704,7 +706,7 @@ static void printforneatosumm(void) {
   Edge *edge;
   int side;
   
-  output("digraph L {\n");
+  output("digraph \"%s\" {\n", title);
 
   FOR_ALL_NODES(node) {
     output("  n%s [shape=circle, style=filled, color=grey,"
@@ -945,7 +947,9 @@ static void usage(void) {
   const OpInfo *oi;
   
   fprintf(stderr,
-         "usage: .../redactgraph <operation> [<operation>...]\n"
+         "usage: .../redactgraph [<options>] <operation> [<operation>...]\n"
+         "options:\n"
+         " -t<title>   title for neato (must have no metachars for \"...\")\n"
          "operations:\n");
   for (oi=opinfos; oi->name; oi++) {
     fprintf(stderr," %s\n",oi->name);
@@ -958,6 +962,14 @@ int main(int argc, const char *const *argv) {
   const OpInfo *oi;
   const char *arg;
 
+  while ((arg= argv[1]) && arg[0]=='-') {
+    if (!strcmp(arg,"-")) break;
+    ++argv;
+    if (!strcmp(arg,"--")) break;
+    if (arg[1]=='t') { title= arg+2; }
+    else { usage(); }
+  }
+
   if (!argv[0] || !argv[1]) usage();
 
   while ((arg= *++argv)) {