From 1c9979107e1fd8095c087e84b0ca51795e997c43 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 28 Nov 2010 15:43:37 +0000 Subject: [PATCH] layout/redactgraph: specify graph name for neato, -t option --- layout/Makefile | 6 +++--- layout/redactgraph.c | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/layout/Makefile b/layout/Makefile index 6bde4b2..3b86ddf 100644 --- a/layout/Makefile +++ b/layout/Makefile @@ -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 diff --git a/layout/redactgraph.c b/layout/redactgraph.c index 32d5221..af1ef54 100644 --- a/layout/redactgraph.c +++ b/layout/redactgraph.c @@ -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 [...]\n" + "usage: .../redactgraph [] [...]\n" + "options:\n" + " -t 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)) { -- 2.30.2