* src/print_graph.c (print_actions): CPP out useless code.

* src/vcg.c (complain.h): Include it.
Unepitaize `return' invocations.
* src/vcg.c [NDEBUG] (main): Remove.
This commit is contained in:
Akim Demaille
2001-08-06 09:50:38 +00:00
parent 78348431f2
commit 3e3da79762
4 changed files with 249 additions and 301 deletions

View File

@@ -1,3 +1,10 @@
2001-08-06 Akim Demaille <akim@epita.fr>, Marc Autret <autret_@epita.fr>
* src/print_graph.c (print_actions): CPP out useless code.
* src/vcg.c (complain.h): Include it.
Unepitaize `return' invocations.
* src/vcg.c [NDEBUG] (main): Remove.
2001-08-06 Marc Autret <autret_@epita.fr>
Automaton VCG graph output.

View File

@@ -52,7 +52,7 @@ print_core (int state)
if (k == 0)
return;
obstack_sgrow(&graph_obstack, "\t\tlabel:\t\"");
obstack_sgrow (&graph_obstack, "\t\tlabel:\t\"");
for (i = 0; i < k; i++)
{
@@ -63,20 +63,20 @@ print_core (int state)
rule = -(*sp);
obstack_fgrow1(&graph_obstack, _("%d: "), rule);
obstack_fgrow1(&graph_obstack, " %s -> ", tags[rlhs[rule]]);
obstack_fgrow1 (&graph_obstack, _("%d: "), rule);
obstack_fgrow1 (&graph_obstack, " %s -> ", tags[rlhs[rule]]);
for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
obstack_fgrow1(&graph_obstack, "%s ", tags[*sp]);
obstack_fgrow1 (&graph_obstack, "%s ", tags[*sp]);
obstack_1grow(&graph_obstack, '.');
obstack_1grow (&graph_obstack, '.');
while (*sp > 0)
obstack_fgrow1(&graph_obstack, " %s", tags[*sp++]);
obstack_fgrow1 (&graph_obstack, " %s", tags[*sp++]);
obstack_sgrow(&graph_obstack, "\\n");
obstack_sgrow (&graph_obstack, "\\n");
}
obstack_sgrow(&graph_obstack, "\"\n");
obstack_sgrow (&graph_obstack, "\"\n");
}
static void
@@ -99,10 +99,12 @@ print_actions (int state, node_t *node)
if (!shiftp && !redp)
{
#if 0
if (final_state == state)
;//fprintf(f, " $default\taccept\n");
fprintf (f, " $default\taccept\n");
else
;//fprintf(f, " NO ACTIONS\n");
fprintf (f, " NO ACTIONS\n");
#endif
return;
}
@@ -193,11 +195,11 @@ print_state (int state)
new_node (&node);
open_node (&graph_obstack);
sprintf(name, "%d", state);
sprintf (name, "%d", state);
node.title = name;
output_node (&node, &graph_obstack);
print_core (state); /* node label */
print_core (state); /* node label */
close_node (&graph_obstack);
@@ -211,7 +213,7 @@ print_graph (void)
int i;
if (!graph_flag)
return ;
return;
new_graph (&graph);
/* graph.smanhattan_edges = yes;
@@ -233,8 +235,8 @@ print_graph (void)
output_graph (&graph, &graph_obstack);
for (i = 0; i < nstates; i++)
/* Output nodes & edges. */
print_state (i);
/* Output nodes & edges. */
print_state (i);
/* Close graph. */
close_graph (&graph, &graph_obstack);

View File

@@ -882,16 +882,11 @@ static void
parse_header_extension_decl (void)
{
char buff[32];
int len;
if (header_extension)
complain (_("multiple %%header_extension declarations"));
fscanf (finput, "%s", buff);
printf("-> %s\n", buff);
len = strlen (buff);
buff[len] = '\0';
src_extension = XMALLOC (char, len + 1);
stpcpy (header_extension, buff);
header_extension = xstrdup (buff);
}
/*------------------------------------------.
@@ -902,16 +897,11 @@ static void
parse_source_extension_decl (void)
{
char buff[32];
int len;
if (src_extension)
complain (_("multiple %%source_extension declarations"));
fscanf (finput, "%s", buff);
printf("-> %s\n", buff);
len = strlen (buff);
buff[len] = '\0';
src_extension = XMALLOC (char, len + 1);
stpcpy (src_extension, buff);
src_extension = xstrdup (buff);
}
/*----------------------------------------------------------------.

237
src/vcg.c
View File

@@ -22,6 +22,7 @@
#include "vcg.h"
#include "vcg_defaults.h"
#include "xalloc.h"
#include "complain.h"
/* Initialize a graph with the default values. */
void
@@ -197,41 +198,41 @@ get_color_str (enum color_e c)
{
switch (c)
{
case white: return ("white");
case blue: return ("blue");
case red: return ("red");
case green: return ("green");
case yellow: return ("yellow");
case magenta: return ("magenta");
case cyan: return ("cyan");
case darkgrey: return ("darkgrey");
case darkblue: return ("darkblue");
case darkred: return ("darkred");
case darkgreen: return ("darkgreen");
case darkyellow: return ("darkyellow");
case darkmagenta: return ("darkmagenta");
case darkcyan: return ("darkcyan");
case gold: return ("gold");
case lightgrey: return ("lightgrey");
case lightblue: return ("lightblue");
case lightred: return ("lightred");
case lightgreen: return ("lightgreen");
case lightyellow: return ("lightyellow");
case lightmagenta: return ("lightmagenta");
case lightcyan: return ("lightcyan");
case lilac: return ("lilac");
case turquoise: return ("turquoise");
case aquamarine: return ("aquamarine");
case khaki: return ("khaki");
case purple: return ("purple");
case yellowgreen: return ("yellowgreen");
case pink: return ("pink");
case orange: return ("orange");
case orchid: return ("orchid");
case black: return ("black");
case white: return "white";
case blue: return "blue";
case red: return "red";
case green: return "green";
case yellow: return "yellow";
case magenta: return "magenta";
case cyan: return "cyan";
case darkgrey: return "darkgrey";
case darkblue: return "darkblue";
case darkred: return "darkred";
case darkgreen: return "darkgreen";
case darkyellow: return "darkyellow";
case darkmagenta: return "darkmagenta";
case darkcyan: return "darkcyan";
case gold: return "gold";
case lightgrey: return "lightgrey";
case lightblue: return "lightblue";
case lightred: return "lightred";
case lightgreen: return "lightgreen";
case lightyellow: return "lightyellow";
case lightmagenta: return "lightmagenta";
case lightcyan: return "lightcyan";
case lilac: return "lilac";
case turquoise: return "turquoise";
case aquamarine: return "aquamarine";
case khaki: return "khaki";
case purple: return "purple";
case yellowgreen: return "yellowgreen";
case pink: return "pink";
case orange: return "orange";
case orchid: return "orchid";
case black: return "black";
default:
complain (_("vcg graph: no such a color."));
return (get_color_str(G_COLOR));
return get_color_str(G_COLOR);
}
return NULL;
}
@@ -241,12 +242,12 @@ get_textmode_str (enum textmode_e t)
{
switch (t)
{
case centered: return ("center");
case left_justify: return ("left_justify");
case right_justify: return ("right_justify");
case centered: return "center";
case left_justify: return "left_justify";
case right_justify: return "right_justify";
default:
complain (_("vcg graph: no such a text mode.."));
return (get_textmode_str(G_TEXTMODE));
return get_textmode_str(G_TEXTMODE);
}
return NULL;
}
@@ -256,13 +257,13 @@ get_shape_str (enum shape_e s)
{
switch (s)
{
case box: return ("box");
case rhomb: return ("rhomb");
case ellipse: return ("ellipse");
case triangle: return ("triangle");
case box: return "box";
case rhomb: return "rhomb";
case ellipse: return "ellipse";
case triangle: return "triangle";
default:
complain (_("vcg graph: no such a shape.."));
return (get_shape_str(G_SHAPE));
return get_shape_str(G_SHAPE);
}
return NULL;
}
@@ -272,22 +273,22 @@ get_layoutalgorithm_str (enum layoutalgorithm_e l)
{
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");
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:
return ("normal");
return "normal";
}
return NULL;
}
@@ -297,11 +298,11 @@ get_decision_str (enum decision_e d, enum decision_e defaults)
{
switch (d)
{
case no: return ("no");
case yes: return ("yes");
case no: return "no";
case yes: return "yes";
default:
complain (_("vcg graph: no such a decision.."));
return (get_decision_str(defaults, 0));
return get_decision_str(defaults, 0);
}
return NULL;
}
@@ -311,13 +312,13 @@ get_orientation_str (enum orientation_e o)
{
switch (o)
{
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");
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:
complain (_("vcg graph: no such an orientation.."));
return (get_orientation_str(G_ORIENTATION));
return get_orientation_str(G_ORIENTATION);
}
return NULL;
}
@@ -327,12 +328,12 @@ get_node_alignement_str (enum alignement_e a)
{
switch (a)
{
case center: return ("center");
case top: return ("top");
case bottom: return ("bottom");
case center: return "center";
case top: return "top";
case bottom: return "bottom";
default:
complain (_("vcg graph: no such an alignement.."));
return (get_node_alignement_str(G_NODE_ALIGNEMENT));
return get_node_alignement_str(G_NODE_ALIGNEMENT);
}
return NULL;
}
@@ -342,11 +343,11 @@ get_arrow_mode_str (enum arrow_mode_e a)
{
switch (a)
{
case fixed: return ("fixed");
case free_a: return ("free");
case fixed: return "fixed";
case free_a: return "free";
default:
complain (_("vcg graph: no such an arrow mode.."));
return (get_arrow_mode_str(G_ARROW_MODE));
return get_arrow_mode_str(G_ARROW_MODE);
}
return NULL;
}
@@ -356,13 +357,13 @@ get_crossing_type_str (enum crossing_type_e c)
{
switch (c)
{
case bary: return ("bary");
case median: return ("median");
case barymedian: return ("barymedian");
case medianbary: return ("medianbary");
case bary: return "bary";
case median: return "median";
case barymedian: return "barymedian";
case medianbary: return "medianbary";
default:
complain (_("vcg graph: no such a crossing_type.."));
return (get_crossing_type_str(G_CROSSING_WEIGHT));
return get_crossing_type_str(G_CROSSING_WEIGHT);
}
return NULL;
}
@@ -372,14 +373,14 @@ get_view_str (enum view_e v)
{
switch (v)
{
case normal_view: return ("normal_view");
case cfish: return ("cfish");
case pfish: return ("pfish");
case fcfish: return ("fcfish");
case fpfish: return ("fpfish");
case normal_view: return "normal_view";
case cfish: return "cfish";
case pfish: return "pfish";
case fcfish: return "fcfish";
case fpfish: return "fpfish";
default:
complain (_("vcg graph: no such a view.."));
return (get_view_str(G_VIEW));
return get_view_str(G_VIEW);
}
return NULL;
}
@@ -389,13 +390,13 @@ get_linestyle_str (enum linestyle_e l)
{
switch (l)
{
case continuous: return ("continuous");
case dashed: return ("dashed");
case dotted: return ("dotted");
case invisible: return ("invisible");
case continuous: return "continuous";
case dashed: return "dashed";
case dotted: return "dotted";
case invisible: return "invisible";
default:
complain (_("vcg graph: no such a linestyle.."));
return (get_linestyle_str(E_LINESTYLE));
return get_linestyle_str(E_LINESTYLE);
}
return NULL;
}
@@ -405,12 +406,12 @@ get_arrowstyle_str (enum arrowstyle_e a)
{
switch (a)
{
case solid: return ("solid");
case line: return ("line");
case none: return ("none");
case solid: return "solid";
case line: return "line";
case none: return "none";
default:
complain (_("vcg graph: no such an arrowstyle.."));
return (get_arrowstyle_str(E_ARROWSTYLE));
return get_arrowstyle_str(E_ARROWSTYLE);
}
return NULL;
}
@@ -832,55 +833,3 @@ output_graph (graph_t *graph, struct obstack *os)
if (graph->smax != G_SMAX)
obstack_fgrow1 (os, "\tsmax:\t%d\n", graph->smax);
}
#ifdef NDEBUG
int main ()
{
graph_t graph;
node_t *node;
edge_t *edge;
struct obstack graph_obstack;
obstack_init (&graph_obstack);
new_graph(&graph);
graph.title = "graph_title";
graph.label = "graph_label";
graph.color = yellow;
graph.textcolor = green;
graph.width = 5;
graph.x = 12;
graph.y = 17;
graph.textmode = right_justify;
open_graph (&graph, stdout);
node = XMALLOC (node_t, 1);
new_node (node);
node->title = "A";
node->locx = 12;
node->locy = 71;
add_node (&graph, node);
node = XMALLOC (node_t, 1);
new_node (node);
node->title = "B";
add_node (&graph, node);
edge = XMALLOC (edge_t, 1);
new_edge (edge);
edge->sourcename = "B";
edge->targetname = "A";
add_edge (&graph, edge);
output_graph(&graph, stdout);
close_graph (&graph, stdout);
obstack_save (&graph_obstack, "essai.vcg");
return (0);
}
#endif /* not DEBUG */