From: ellson Date: Wed, 5 Jan 2005 20:03:59 +0000 (+0000) Subject: validate -T before possibly hanging on stdin. X-Git-Tag: LAST_LIBGRAPH~32^2~8158 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bfebdff475f0d2eb4ffe6a448b09b7bac438a454;p=graphviz validate -T before possibly hanging on stdin. various fixes to configure --disable-gvrender --- diff --git a/cmd/tools/Makefile.am b/cmd/tools/Makefile.am index c5eee713e..b7e4f1410 100644 --- a/cmd/tools/Makefile.am +++ b/cmd/tools/Makefile.am @@ -90,6 +90,15 @@ gc_LDADD = \ gvpack_SOURCES = gvpack.c plugins.c +if DISABLE_GVRENDER +gvpack_LDADD = \ + $(top_builddir)/lib/ingraphs/libingraphs.la \ + $(top_builddir)/lib/neatogen/libneatogen.la \ + $(top_builddir)/lib/pack/libpack.la \ + $(top_builddir)/lib/common/libcommon.la \ + $(top_builddir)/lib/gvc/libgvc.la \ + $(top_builddir)/lib/pathplan/libpathplan.la +else gvpack_LDADD = \ $(top_builddir)/lib/ingraphs/libingraphs.la \ $(top_builddir)/lib/neatogen/libneatogen.la \ @@ -101,6 +110,7 @@ gvpack_LDADD = \ $(top_builddir)/plugin/gd/libgvplugin_gd.la \ $(top_builddir)/plugin/text/libgvplugin_text.la \ $(top_builddir)/plugin/layout/libgvplugin_layout.la @CAIRO_LIBS@ +endif dijkstra_SOURCES = dijkstra.c diff --git a/lib/common/emit.c b/lib/common/emit.c index 1872ef0c3..0034dd6e9 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1305,7 +1305,6 @@ static codegen_info_t cg[MAX_CODEGENS] = { {&MIF_CodeGen, "mif", MIF}, {&PIC_CodeGen, "pic", PIC_format}, -#ifdef GD_RENDER {&GD_CodeGen, "gd", GD}, #ifdef HAVE_LIBZ {&GD_CodeGen, "gd2", GD2}, @@ -1326,7 +1325,6 @@ static codegen_info_t cg[MAX_CODEGENS] = { {&GD_CodeGen, "xbm", XBM}, {&GD_CodeGen, "xpm", XBM}, #endif -#endif /* GD_RENDER */ #ifdef QUARTZ_RENDER {&QPDF_CodeGen, "pdf", QPDF}, diff --git a/lib/common/globals.h b/lib/common/globals.h index 3d1c9e05a..c14ce5914 100644 --- a/lib/common/globals.h +++ b/lib/common/globals.h @@ -64,14 +64,10 @@ extern "C" { external FILE *Output_file; external int Obj; - extern codegen_t FIG_CodeGen, HPGL_CodeGen, - MAP_CodeGen, MIF_CodeGen, - XDot_CodeGen, MP_CodeGen, PIC_CodeGen, PS_CodeGen, - DIA_CodeGen, SVG_CodeGen, VRML_CodeGen, VTX_CodeGen; - -#ifdef GD_RENDER - extern codegen_t GD_CodeGen, memGD_CodeGen; -#endif + extern codegen_t FIG_CodeGen, HPGL_CodeGen, MAP_CodeGen, + MIF_CodeGen, XDot_CodeGen, MP_CodeGen, PIC_CodeGen, + PS_CodeGen, DIA_CodeGen, SVG_CodeGen, VRML_CodeGen, + VTX_CodeGen, GD_CodeGen, memGD_CodeGen; #ifdef QUARTZ_RENDER extern codegen_t QPDF_CodeGen, QEPDF_CodeGen, QBM_CodeGen; #endif diff --git a/lib/common/input.c b/lib/common/input.c index 794e470ca..be82902a0 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -139,6 +139,11 @@ void dotneato_initialize(GVC_t * gvc, int argc, char **argv) /* establish Gvfilepath, if any */ Gvfilepath = getenv("GV_FILE_PATH"); + /* configure codegens */ + config_codegen_builtins(gvc); + gvplugin_builtins(gvc); + gvconfig(gvc, CONFIG); + aginit(); nfiles = 0; for (i = 1; i < argc; i++) @@ -181,8 +186,14 @@ void dotneato_initialize(GVC_t * gvc, int argc, char **argv) if (!val) { fprintf(stderr, "Missing argument for -T flag\n"); dotneato_usage(1); + exit(1); + } + v = gvrender_output_langname_job(gvc, val); + if (v == NO_SUPPORT) { + fprintf(stderr, "Renderer type: \"%s\" not recognized. Use one of:%s\n", + val, gvplugin_list(gvc, API_render, val)); + exit(1); } - gvrender_output_langname_job(gvc, val); break; case 'V': fprintf(stderr, "%s version %s (%s)\n", @@ -264,13 +275,10 @@ void dotneato_initialize(GVC_t * gvc, int argc, char **argv) /* if no -Txxx, then set default format */ if (!gvc->jobs || !gvc->jobs->output_langname) { - gvrender_output_langname_job(gvc, "dot"); + v = gvrender_output_langname_job(gvc, "dot"); + assert(v != NO_SUPPORT); } - config_codegen_builtins(gvc); - gvplugin_builtins(gvc); - gvconfig(gvc, CONFIG); - #if !defined(DISABLE_CODEGENS) && !defined(HAVE_GD_FREETYPE) Output_codegen = gvc->codegen; #endif @@ -328,7 +336,7 @@ void getdouble(graph_t * g, char *name, double *result) } } -FILE *next_input_file(void) +static FILE *next_input_file(void) { static int ctr = 0; FILE *rv = NULL; diff --git a/lib/common/renderprocs.h b/lib/common/renderprocs.h index 7259be7db..f62106180 100644 --- a/lib/common/renderprocs.h +++ b/lib/common/renderprocs.h @@ -145,7 +145,6 @@ extern "C" { extern point neato_closest(splines * spl, point p); extern bezier *new_spline(edge_t * e, int sz); extern queue *new_queue(int); - extern FILE *next_input_file(void); extern Agraph_t *next_input_graph(void); extern int node_in_CB(node_t *); extern int node_in_layer(Agraph_t *, node_t *); diff --git a/lib/common/utils.c b/lib/common/utils.c index 02679c998..b84419f72 100644 --- a/lib/common/utils.c +++ b/lib/common/utils.c @@ -1038,7 +1038,6 @@ point user_shape_size(node_t * n, char *shapefile) suffix = shapefile; else suffix++; -#ifdef GD_RENDER if (!strcasecmp(suffix, "wbmp") #ifdef HAVE_GD_GIF || !strcasecmp(suffix, "gif") @@ -1056,7 +1055,6 @@ point user_shape_size(node_t * n, char *shapefile) ) { rv = gd_user_shape_size(n, shapefile); } else -#endif #ifdef QUARTZ_RENDER if (Output_lang == QPDF || Output_lang == QEPDF || (Output_lang >= QBM_FIRST && Output_lang <= QBM_LAST)) @@ -1099,7 +1097,6 @@ point image_size(graph_t * g, char *shapefile) suffix = shapefile; else suffix++; -#ifdef GD_RENDER if (!strcasecmp(suffix, "wbmp") #ifdef HAVE_GD_GIF || !strcasecmp(suffix, "gif") @@ -1117,7 +1114,6 @@ point image_size(graph_t * g, char *shapefile) ) { rv = gd_image_size(g, shapefile); } else -#endif #ifdef QUARTZ_RENDER if (Output_lang == QPDF || Output_lang == QEPDF || (Output_lang >= QBM_FIRST && Output_lang <= QBM_LAST)) diff --git a/lib/gvc/gvjobs.c b/lib/gvc/gvjobs.c index 1915979a0..6b1f87a2f 100644 --- a/lib/gvc/gvjobs.c +++ b/lib/gvc/gvjobs.c @@ -67,7 +67,7 @@ void gvrender_output_filename_job(GVC_t * gvc, char *name) } /* -T switches */ -void gvrender_output_langname_job(GVC_t * gvc, char *name) +int gvrender_output_langname_job(GVC_t * gvc, char *name) { if (!gvc->jobs) { output_langname_job = gvc->job = gvc->jobs = @@ -84,6 +84,9 @@ void gvrender_output_langname_job(GVC_t * gvc, char *name) } } output_langname_job->output_langname = name; + + /* select it now to check that it exists */ + return (gvrender_select(gvc, name)); } #if 0 diff --git a/lib/gvc/gvrender.h b/lib/gvc/gvrender.h index f5587355f..7f27f1f1c 100644 --- a/lib/gvc/gvrender.h +++ b/lib/gvc/gvrender.h @@ -48,7 +48,7 @@ extern "C" { /* job */ extern void gvrender_output_filename_job(GVC_t * gvc, char *name); - extern void gvrender_output_langname_job(GVC_t * gvc, char *name); + extern int gvrender_output_langname_job(GVC_t * gvc, char *name); extern gvrender_job_t *gvrender_first_job(GVC_t * gvc); extern gvrender_job_t *gvrender_next_job(GVC_t * gvc); extern void gvrender_delete_jobs(GVC_t * gvc);