]> granicus.if.org Git - graphviz/commitdiff
Check for -K first before trying command name for layout spec.
authorerg <devnull@localhost>
Mon, 1 Nov 2010 19:14:57 +0000 (19:14 +0000)
committererg <devnull@localhost>
Mon, 1 Nov 2010 19:14:57 +0000 (19:14 +0000)
This mainly allows apps to have any name and still call gvParseArgs as long as the
user provides -K. More trivially, it avoid the two calls to set up the layout engine.

lib/common/input.c

index 92941a64dc8e20ab78bbc3b969c9014f169e5f4d..bdec89916c5727b741a228d10326ef4ae5e5964e 100644 (file)
@@ -237,6 +237,7 @@ void dotneato_args_initialize(GVC_t * gvc, int argc, char **argv)
     int i, v, nfiles;
     unsigned char buf[SMALLBUF];
     agxbuf xb;
+    int Kflag = 0;
 
     /* establish if we are running in a CGI environment */
     HTTPServerEnVar = getenv("SERVER_NAME");
@@ -258,24 +259,6 @@ void dotneato_args_initialize(GVC_t * gvc, int argc, char **argv)
     if (gvc->common.config)
        exit (0);
 
-    layout = gvc->common.cmdname;
-    if (streq(layout, "dot_static")
-           || streq(layout, "dot_builtins")
-           || streq(layout, "lt-dot")
-           || streq(layout, "lt-dot_builtins")
-           || streq(layout, "")   /* when run as a process from Gvedit on Windows */
-       )
-        layout = "dot";
-    i = gvlayout_select(gvc, layout);
-    if (i == NO_SUPPORT) {
-       fprintf(stderr, "There is no layout engine support for \"%s\"\n", layout);
-        if (streq(layout, "dot"))
-           fprintf(stderr, "Perhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
-       else 
-           fprintf(stderr, "Use one of:%s\n", gvplugin_list(gvc, API_layout, ""));
-       exit(1);
-    }
-
     /* feed the globals */
     Verbose = gvc->common.verbose;
     CmdName = gvc->common.cmdname;
@@ -363,6 +346,7 @@ void dotneato_args_initialize(GVC_t * gvc, int argc, char **argv)
                    }
                    exit(1);
                 }
+               Kflag = 1;
                break;
            case 'P':
                P_graph = gvplugin_graph(gvc);
@@ -431,6 +415,27 @@ void dotneato_args_initialize(GVC_t * gvc, int argc, char **argv)
     }
     agxbfree (&xb);
 
+    /* if no -K, use cmd name to set layout type */
+    if (!Kflag) {
+       layout = gvc->common.cmdname;
+       if (streq(layout, "dot_static")
+           || streq(layout, "dot_builtins")
+           || streq(layout, "lt-dot")
+           || streq(layout, "lt-dot_builtins")
+           || streq(layout, "")   /* when run as a process from Gvedit on Windows */
+       )
+            layout = "dot";
+       i = gvlayout_select(gvc, layout);
+       if (i == NO_SUPPORT) {
+           fprintf(stderr, "There is no layout engine support for \"%s\"\n", layout);
+            if (streq(layout, "dot"))
+               fprintf(stderr, "Perhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
+           else 
+               fprintf(stderr, "Use one of:%s\n", gvplugin_list(gvc, API_layout, ""));
+           exit(1);
+       }
+    }
+
     /* if no -Txxx, then set default format */
     if (!gvc->jobs || !gvc->jobs->output_langname) {
        v = gvjobs_output_langname(gvc, "dot");