/[bison]/bison/src/vcg.c
ViewVC logotype

Diff of /bison/src/vcg.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5.2.6 by akim, Tue Sep 25 18:35:04 2001 UTC revision 1.5.2.7 by akim, Mon Nov 19 09:13:40 2001 UTC
# Line 21  Line 21 
21  #include "system.h"  #include "system.h"
22  #include "vcg.h"  #include "vcg.h"
23  #include "vcg_defaults.h"  #include "vcg_defaults.h"
24    #include "quotearg.h"
25    
26    /* Return an unambiguous printable representated, allocated in slot 0,
27       for NAME, suitable for C strings.  */
28    static char const *
29    quote (char const *name)
30    {
31      return quotearg_n_style (0, c_quoting_style, name);
32    }
33    
34    
35  /* Initialize a graph with the default values. */  /* Initialize a graph with the default values. */
36  void  void
# Line 429  void Line 439  void
439  add_classname (graph_t *g, int val, const char *name)  add_classname (graph_t *g, int val, const char *name)
440  {  {
441    struct classname_s *classname;    struct classname_s *classname;
442      
443    classname = XMALLOC (struct classname_s, 1);    classname = XMALLOC (struct classname_s, 1);
444    classname->no = val;    classname->no = val;
445    classname->name = name;    classname->name = name;
# Line 441  void Line 451  void
451  add_infoname (graph_t *g, int integer, const char *string)  add_infoname (graph_t *g, int integer, const char *string)
452  {  {
453    struct infoname_s *infoname;    struct infoname_s *infoname;
454      
455    infoname = XMALLOC (struct infoname_s, 1);    infoname = XMALLOC (struct infoname_s, 1);
456    infoname->integer = integer;    infoname->integer = integer;
457    infoname->string = string;    infoname->string = string;
# Line 451  add_infoname (graph_t *g, int integer, c Line 461  add_infoname (graph_t *g, int integer, c
461    
462  /* Build a colorentry struct and add it to the list.  */  /* Build a colorentry struct and add it to the list.  */
463  void  void
464  add_colorentry (graph_t *g, int color_idx, int red_cp,  add_colorentry (graph_t *g, int color_idx, int red_cp,
465                  int green_cp, int blue_cp)                  int green_cp, int blue_cp)
466  {  {
467    struct colorentry_s *ce;    struct colorentry_s *ce;
468      
469    ce = XMALLOC (struct colorentry_s, 1);    ce = XMALLOC (struct colorentry_s, 1);
470    ce->color_index = color_idx;    ce->color_index = color_idx;
471    ce->red_cp = red_cp;    ce->red_cp = red_cp;
# Line 556  void Line 566  void
566  output_node (node_t *node, FILE *fout)  output_node (node_t *node, FILE *fout)
567  {  {
568    if (node->title != N_TITLE)    if (node->title != N_TITLE)
569      fprintf (fout, "\t\ttitle:\t\"%s\"\n", node->title);      fprintf (fout, "\t\ttitle:\t%s\n", quote (node->title));
570    if (node->label != N_LABEL)    if (node->label != N_LABEL)
571      fprintf (fout, "\t\tlabel:\t\"%s\"\n", node->label);      fprintf (fout, "\t\tlabel:\t%s\n", quote (node->label));
572    
573    if ((node->locx != N_LOCX) && (node->locy != N_LOCY))    if ((node->locx != N_LOCX) && (node->locy != N_LOCY))
574      fprintf (fout, "\t\tloc { x: %d  y: %d }\t\n", node->locx, node->locy);      fprintf (fout, "\t\tloc { x: %d  y: %d }\t\n", node->locx, node->locy);
# Line 600  output_node (node_t *node, FILE *fout) Line 610  output_node (node_t *node, FILE *fout)
610      fprintf (fout, "\t\tbordercolor:\t%s\n",      fprintf (fout, "\t\tbordercolor:\t%s\n",
611               get_color_str (node->bordercolor));               get_color_str (node->bordercolor));
612    
613    if (node->infos[0])    {
614      fprintf (fout, "\t\tinfo1:\t\"%s\"\n", node->infos[0]);      int i;
615    if (node->infos[1])      for (i = 0; i < 3; ++i)
616      fprintf (fout, "\t\tinfo2:\t\"%s\"\n", node->infos[1]);        if (node->infos[i])
617    if (node->infos[2])          fprintf (fout, "\t\tinfo%d:\t%s\n",
618      fprintf (fout, "\t\tinfo3:\t\"%s\"\n", node->infos[2]);                   i, quote (node->infos[i]));
619      }
620  }  }
621    
622  void  void
# Line 614  output_edge (edge_t *edge, FILE *fout) Line 625  output_edge (edge_t *edge, FILE *fout)
625    /* FIXME: SOURCENAME and TARGETNAME are mandatory    /* FIXME: SOURCENAME and TARGETNAME are mandatory
626       so it has to be fatal not to give these informations.  */       so it has to be fatal not to give these informations.  */
627    if (edge->sourcename != E_SOURCENAME)    if (edge->sourcename != E_SOURCENAME)
628      fprintf (fout, "\t\tsourcename:\t\"%s\"\n", edge->sourcename);      fprintf (fout, "\t\tsourcename:\t%s\n", quote (edge->sourcename));
629    if (edge->targetname != E_TARGETNAME)    if (edge->targetname != E_TARGETNAME)
630      fprintf (fout, "\t\ttargetname:\t\"%s\"\n", edge->targetname);      fprintf (fout, "\t\ttargetname:\t%s\n", quote (edge->targetname));
631    
632    if (edge->label != E_LABEL)    if (edge->label != E_LABEL)
633      fprintf (fout, "\t\tlabel:\t\"%s\"\n", edge->label);      fprintf (fout, "\t\tlabel:\t%s\n", quote (edge->label));
634    
635    if (edge->linestyle != E_LINESTYLE)    if (edge->linestyle != E_LINESTYLE)
636      fprintf (fout, "\t\tlinestyle:\t\"%s\"\n",      fprintf (fout, "\t\tlinestyle:\t%s\n",
637               get_linestyle_str(edge->linestyle));               quote (get_linestyle_str(edge->linestyle)));
638    
639    if (edge->thickness != E_THICKNESS)    if (edge->thickness != E_THICKNESS)
640      fprintf (fout, "\t\tthickness:\t%d\n", edge->thickness);      fprintf (fout, "\t\tthickness:\t%d\n", edge->thickness);
# Line 666  void Line 677  void
677  output_graph (graph_t *graph, FILE *fout)  output_graph (graph_t *graph, FILE *fout)
678  {  {
679    if (graph->title)    if (graph->title)
680      fprintf (fout, "\ttitle:\t\"%s\"\n", graph->title);      fprintf (fout, "\ttitle:\t%s\n", quote (graph->title));
681    if (graph->label)    if (graph->label)
682      fprintf (fout, "\tlabel:\t\"%s\"\n", graph->label);      fprintf (fout, "\tlabel:\t%s\n", quote (graph->label));
683    
684    if (graph->infos[0])    {
685      fprintf (fout, "\tinfo1:\t\"%s\"\n", graph->infos[0]);      int i;
686    if (graph->infos[1])      for (i = 0; i < 3; ++i)
687      fprintf (fout, "\tinfo2:\t\"%s\"\n", graph->infos[1]);        if (graph->infos[i])
688    if (graph->infos[2])          fprintf (fout, "\tinfo%d:\t%s\n", i, quote (graph->infos[i]));
689      fprintf (fout, "\tinfo3:\t\"%s\"\n", graph->infos[2]);    }
690    
691    if (graph->color != G_COLOR)    if (graph->color != G_COLOR)
692      fprintf (fout, "\tcolor:\t%s\n", get_color_str (graph->color));      fprintf (fout, "\tcolor:\t%s\n", get_color_str (graph->color));
# Line 711  output_graph (graph_t *graph, FILE *fout Line 722  output_graph (graph_t *graph, FILE *fout
722    
723    if (graph->shape != G_SHAPE)    if (graph->shape != G_SHAPE)
724      fprintf (fout, "\tshape:\t%s\n", get_shape_str (graph->shape));      fprintf (fout, "\tshape:\t%s\n", get_shape_str (graph->shape));
725      
726    if (graph->vertical_order != G_VERTICAL_ORDER)    if (graph->vertical_order != G_VERTICAL_ORDER)
727      fprintf (fout, "\tvertical_order:\t%d\n", graph->vertical_order);        fprintf (fout, "\tvertical_order:\t%d\n", graph->vertical_order);
728    if (graph->horizontal_order != G_HORIZONTAL_ORDER)    if (graph->horizontal_order != G_HORIZONTAL_ORDER)
729      fprintf (fout, "\thorizontal_order:\t%d\n", graph->horizontal_order);        fprintf (fout, "\thorizontal_order:\t%d\n", graph->horizontal_order);
730    
731    if (graph->xmax != G_XMAX)    if (graph->xmax != G_XMAX)
732      fprintf (fout, "\txmax:\t%d\n", graph->xmax);      fprintf (fout, "\txmax:\t%d\n", graph->xmax);
# Line 743  output_graph (graph_t *graph, FILE *fout Line 754  output_graph (graph_t *graph, FILE *fout
754    
755    if (graph->hidden != G_HIDDEN)    if (graph->hidden != G_HIDDEN)
756      fprintf (fout, "\thidden:\t%d\n", graph->hidden);      fprintf (fout, "\thidden:\t%d\n", graph->hidden);
757      
758    /* FIXME: Unallocate struct list if required.      /* FIXME: Unallocate struct list if required.
759       Maybe with a little function.  */       Maybe with a little function.  */
760    if (graph->classname != G_CLASSNAME)    if (graph->classname != G_CLASSNAME)
761      {      {
# Line 765  output_graph (graph_t *graph, FILE *fout Line 776  output_graph (graph_t *graph, FILE *fout
776    if (graph->colorentry != G_COLORENTRY)    if (graph->colorentry != G_COLORENTRY)
777      {      {
778        struct colorentry_s *ite;        struct colorentry_s *ite;
779          
780        for (ite = graph->colorentry; ite; ite = ite->next)        for (ite = graph->colorentry; ite; ite = ite->next)
781          {                {
782            fprintf (fout, "\tcolorentry %d :\t%d %d %d\n",            fprintf (fout, "\tcolorentry %d :\t%d %d %d\n",
783                     ite->color_index,                     ite->color_index,
784                     ite->red_cp,                     ite->red_cp,
785                     ite->green_cp,                     ite->green_cp,
786                     ite->blue_cp);                     ite->blue_cp);
787          }              }
788      }      }
789    
790    if (graph->layoutalgorithm != G_LAYOUTALGORITHM)    if (graph->layoutalgorithm != G_LAYOUTALGORITHM)

Legend:
Removed from v.1.5.2.6  
changed lines
  Added in v.1.5.2.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26