X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/4613f49b90c0c440910da55581f95183b9bb1272..ec5479ce351b0365549e9c7d570b0ee86a4a6589:/src/vcg.c diff --git a/src/vcg.c b/src/vcg.c index 88755b28..25fbb64e 100644 --- a/src/vcg.c +++ b/src/vcg.c @@ -1,6 +1,7 @@ /* VCG description handler for Bison. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -16,9 +17,10 @@ You should have received a copy of the GNU General Public License along with Bison; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ +#include #include "system.h" #include @@ -59,7 +61,7 @@ new_graph (graph *g) g->y = G_Y; g->folding = G_FOLDING; g->shrink = G_SHRINK; - g->expand = G_EXPAND; + g->stretch = G_STRETCH; g->textmode = G_TEXTMODE; g->shape = G_SHAPE; @@ -85,7 +87,6 @@ new_graph (graph *g) g->classname = G_CLASSNAME; /* No class name association. */ - g->layoutalgorithm = G_LAYOUTALGORITHM; g->layout_downfactor = G_LAYOUT_DOWNFACTOR; g->layout_upfactor = G_LAYOUT_UPFACTOR; g->layout_nearfactor = G_LAYOUT_NEARFACTOR; @@ -96,7 +97,6 @@ new_graph (graph *g) g->dirty_edge_labels = G_DIRTY_EDGE_LABELS; g->finetuning = G_FINETUNING; g->ignore_singles = G_IGNORE_SINGLES; - g->long_straight_phase = G_LONG_STRAIGHT_PHASE; g->priority_phase = G_PRIORITY_PHASE; g->manhattan_edges = G_MANHATTAN_EDGES; g->smanhattan_edges = G_SMANHATTAN_EDGES; @@ -150,7 +150,7 @@ new_node (node *n) n->height = N_HEIGHT; /* Also. */ n->shrink = N_SHRINK; - n->expand = N_EXPAND; + n->stretch = N_STRETCH; n->folding = N_FOLDING; /* No explicit default value. */ @@ -205,15 +205,16 @@ new_edge (edge *e) } /*----------------------------------------------. -| Get functions. | +| Get functions. | | Return string corresponding to an enum value. | `----------------------------------------------*/ static const char * -get_color_str (enum color c) +get_color_str (enum color color) { - switch (c) + switch (color) { + default: abort (); case white: return "white"; case blue: return "blue"; case red: return "red"; @@ -246,159 +247,136 @@ get_color_str (enum color c) case orange: return "orange"; case orchid: return "orchid"; case black: return "black"; - default: abort (); return NULL; } } static const char * -get_textmode_str (enum textmode t) +get_textmode_str (enum textmode textmode) { - switch (t) + switch (textmode) { + default: abort (); case centered: return "center"; case left_justify: return "left_justify"; case right_justify: return "right_justify"; - default: abort (); return NULL; } } static const char * -get_shape_str (enum shape s) +get_shape_str (enum shape shape) { - switch (s) + switch (shape) { + default: abort (); case box: return "box"; case rhomb: return "rhomb"; case ellipse: return "ellipse"; case triangle: return "triangle"; - default: abort (); return NULL; } } static const char * -get_layoutalgorithm_str (enum layoutalgorithm l) +get_decision_str (enum decision decision) { - switch (l) - { - case normal: return "normal"; - case maxdepth: return "maxdepth"; - case mindepth: return "mindepth"; - case maxdepthslow: return "maxdepthslow"; - case mindepthslow: return "mindepthslow"; - case maxdegree: return "maxdegree"; - case mindegree: return "mindegree"; - case maxindegree: return "maxindegree"; - case minindegree: return "minindegree"; - case maxoutdegree: return "maxoutdegree"; - case minoutdegree: return "minoutdegree"; - case minbackward: return "minbackward"; - case dfs: return "dfs"; - case tree: return "tree"; - default: abort (); return NULL; - } -} - -static const char * -get_decision_str (enum decision d) -{ - switch (d) + switch (decision) { + default: abort (); case no: return "no"; case yes: return "yes"; - default: abort (); return NULL; } } static const char * -get_orientation_str (enum orientation o) +get_orientation_str (enum orientation orientation) { - switch (o) + switch (orientation) { + default: abort (); case top_to_bottom: return "top_to_bottom"; case bottom_to_top: return "bottom_to_top"; case left_to_right: return "left_to_right"; case right_to_left: return "right_to_left"; - default: abort (); return NULL; } } static const char * -get_node_alignment_str (enum alignment a) +get_node_alignment_str (enum alignment alignment) { - switch (a) + switch (alignment) { + default: abort (); case center: return "center"; case top: return "top"; case bottom: return "bottom"; - default: abort (); return NULL; } } static const char * -get_arrow_mode_str (enum arrow_mode a) +get_arrow_mode_str (enum arrow_mode arrow_mode) { - switch (a) + switch (arrow_mode) { + default: abort (); case fixed: return "fixed"; case free_a: return "free"; - default: abort (); return NULL; } } static const char * -get_crossing_type_str (enum crossing_type c) +get_crossing_type_str (enum crossing_type crossing_type) { - switch (c) + switch (crossing_type) { + default: abort (); case bary: return "bary"; case median: return "median"; case barymedian: return "barymedian"; case medianbary: return "medianbary"; - default: abort (); return NULL; } } static const char * -get_view_str (enum view v) +get_view_str (enum view view) { - switch (v) + /* There is no way with vcg 1.30 to specify a normal view explicitly, + so it is an error here if view == normal_view. */ + switch (view) { - case normal_view: return "normal_view"; + default: abort (); case cfish: return "cfish"; case pfish: return "pfish"; case fcfish: return "fcfish"; case fpfish: return "fpfish"; - default: abort (); return NULL; } } static const char * -get_linestyle_str (enum linestyle l) +get_linestyle_str (enum linestyle linestyle) { - switch (l) + switch (linestyle) { + default: abort (); case continuous: return "continuous"; case dashed: return "dashed"; case dotted: return "dotted"; case invisible: return "invisible"; - default: abort (); return NULL; } } static const char * -get_arrowstyle_str (enum arrowstyle a) +get_arrowstyle_str (enum arrowstyle arrowstyle) { - switch (a) + switch (arrowstyle) { + default: abort (); case solid: return "solid"; case line: return "line"; case none: return "none"; - default: abort (); return NULL; } } /*------------------------------. -| Add functions. | +| Add functions. | | Edge and nodes into a graph. | `------------------------------*/ @@ -419,9 +397,7 @@ add_edge (graph *g, edge *e) void add_classname (graph *g, int val, const char *name) { - struct classname *classname; - - MALLOC (classname, 1); + struct classname *classname = xmalloc (sizeof *classname); classname->no = val; classname->name = name; classname->next = g->classname; @@ -431,9 +407,7 @@ add_classname (graph *g, int val, const char *name) void add_infoname (graph *g, int integer, const char *str) { - struct infoname *infoname; - - MALLOC (infoname, 1); + struct infoname *infoname = xmalloc (sizeof *infoname); infoname->integer = integer; infoname->chars = str; infoname->next = g->infoname; @@ -445,9 +419,7 @@ void add_colorentry (graph *g, int color_idx, int red_cp, int green_cp, int blue_cp) { - struct colorentry *ce; - - MALLOC (ce, 1); + struct colorentry *ce = xmalloc (sizeof *ce); ce->color_index = color_idx; ce->red_cp = red_cp; ce->green_cp = green_cp; @@ -566,8 +538,8 @@ output_node (node *n, FILE *fout) if (n->shrink != N_SHRINK) fprintf (fout, "\t\tshrink:\t%d\n", n->shrink); - if (n->expand != N_EXPAND) - fprintf (fout, "\t\texpand:\t%d\n", n->expand); + if (n->stretch != N_STRETCH) + fprintf (fout, "\t\tstretch:\t%d\n", n->stretch); if (n->folding != N_FOLDING) fprintf (fout, "\t\tfolding:\t%d\n", n->folding); @@ -614,8 +586,7 @@ output_edge (edge *e, FILE *fout) fprintf (fout, "\t\tlabel:\t%s\n", quote (e->label)); if (e->linestyle != E_LINESTYLE) - fprintf (fout, "\t\tlinestyle:\t%s\n", - quote (get_linestyle_str (e->linestyle))); + fprintf (fout, "\t\tlinestyle:\t%s\n", get_linestyle_str (e->linestyle)); if (e->thickness != E_THICKNESS) fprintf (fout, "\t\tthickness:\t%d\n", e->thickness); @@ -694,8 +665,8 @@ output_graph (graph *g, FILE *fout) if (g->shrink != G_SHRINK) fprintf (fout, "\tshrink:\t%d\n", g->shrink); - if (g->expand != G_EXPAND) - fprintf (fout, "\texpand:\t%d\n", g->expand); + if (g->stretch != G_STRETCH) + fprintf (fout, "\tstretch:\t%d\n", g->stretch); if (g->textmode != G_TEXTMODE) fprintf (fout, "\ttextmode:\t%s\n", @@ -768,10 +739,6 @@ output_graph (graph *g, FILE *fout) } } - if (g->layoutalgorithm != G_LAYOUTALGORITHM) - fprintf (fout, "\tlayoutalgorithm:\t%s\n", - get_layoutalgorithm_str (g->layoutalgorithm)); - if (g->layout_downfactor != G_LAYOUT_DOWNFACTOR) fprintf (fout, "\tlayout_downfactor:\t%d\n", g->layout_downfactor); if (g->layout_upfactor != G_LAYOUT_UPFACTOR) @@ -797,9 +764,6 @@ output_graph (graph *g, FILE *fout) if (g->ignore_singles != G_IGNORE_SINGLES) fprintf (fout, "\tignore_singles:\t%s\n", get_decision_str (g->ignore_singles)); - if (g->long_straight_phase != G_LONG_STRAIGHT_PHASE) - fprintf (fout, "\tlong_straight_phase:\t%s\n", - get_decision_str (g->long_straight_phase)); if (g->priority_phase != G_PRIORITY_PHASE) fprintf (fout, "\tpriority_phase:\t%s\n", get_decision_str (g->priority_phase)); @@ -846,7 +810,7 @@ output_graph (graph *g, FILE *fout) fprintf (fout, "\tcrossing_optimization:\t%s\n", get_decision_str (g->crossing_optimization)); - if (g->view != G_VIEW) + if (g->view != normal_view) fprintf (fout, "\tview:\t%s\n", get_view_str (g->view)); if (g->edges != G_EDGES)