~ubuntu-branches/ubuntu/precise/graphviz/precise-security

« back to all changes in this revision

Viewing changes to cmd/tools/gvcolor.c

  • Committer: Bazaar Package Importer
  • Author(s): David Claughton
  • Date: 2010-03-24 22:45:18 UTC
  • mfrom: (1.2.7 upstream) (6.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100324224518-do441tthbqjaqjzd
Tags: 2.26.3-4
Add patch to fix segfault in circo. Backported from upstream snapshot
release.  Thanks to Francis Russell for his work on this.
(Closes: #575255)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: gvcolor.c,v 1.6 2008/01/09 20:50:35 erg Exp $ $Revision: 1.6 $ */
 
1
/* $Id: gvcolor.c,v 1.11 2010/01/08 21:28:39 erg Exp $ $Revision: 1.11 $ */
2
2
/* vim:set shiftwidth=4 ts=8: */
3
3
 
4
4
/**********************************************************
27
27
/* if NC changes, a bunch of scanf calls below are in trouble */
28
28
#define NC      3               /* size of HSB color vector */
29
29
 
30
 
#ifdef USE_CGRAPH
31
 
#include <cgraph.h>
 
30
#include "cgraph.h"
32
31
#include <stdlib.h>
33
32
typedef struct Agnodeinfo_t {
34
33
    Agrec_t h;
39
38
#define ND_relrank(n) (((Agnodeinfo_t*)((n)->base.data))->relrank)
40
39
#define ND_x(n) (((Agnodeinfo_t*)((n)->base.data))->x)
41
40
 
42
 
#else
43
 
typedef struct Agnodeinfo_t {
44
 
    double relrank;             /* coordinate of its rank, smaller means lower rank */
45
 
    double x[NC];               /* color vector */
46
 
} Agnodeinfo_t;
47
 
 
48
 
typedef struct Agedgeinfo_t {
49
 
    char for_ansi_C;
50
 
} Agedgeinfo_t;
51
 
typedef struct Agraphinfo_t {
52
 
    char for_ansi_C;
53
 
} Agraphinfo_t;
54
 
 
55
 
#define ND_relrank(n) (n)->u.relrank
56
 
#define ND_x(n) (n)->u.x
57
 
#define aghead(e) ((e)->head)
58
 
#define agtail(e) ((e)->tail)
59
 
 
60
 
#include <graph.h>
61
 
#endif
62
 
#include <ingraphs.h>
 
41
#include "ingraphs.h"
63
42
#include <stdio.h>
64
43
#ifdef HAVE_UNISTD_H
65
 
#include        <unistd.h>
 
44
#include <unistd.h>
66
45
#endif
67
46
 
68
47
#ifdef HAVE_GETOPT_H
117
96
{
118
97
    int c;
119
98
 
120
 
    while ((c = getopt(argc, argv, ":?")) != -1) {
 
99
    opterr = 0;
 
100
    while ((c = getopt(argc, argv, ":")) != -1) {
121
101
        switch (c) {
122
102
        case '?':
123
103
            if (optopt == '?')
144
124
    double x, y, maxrank = 0.0;
145
125
    double sum[NC], d, lowsat, highsat;
146
126
 
147
 
#ifdef USE_CGRAPH
148
127
    if (agattr(g, AGNODE, "pos", 0) == NULL) {
149
 
#else
150
 
    if (agfindattr(g->proto->n, "pos") == NULL) {
151
 
#endif
152
128
        fprintf(stderr,
153
129
                "graph must be run through 'dot' before 'gvcolor'\n");
154
130
        exit(1);
155
131
    }
156
 
#ifdef USE_CGRAPH
157
132
    aginit(g, AGNODE, "nodeinfo", sizeof(Agnodeinfo_t), TRUE);
158
133
    if (agattr(g, AGNODE, "style", 0) == NULL)
159
134
        agattr(g, AGNODE, "style", "filled");
160
 
#else
161
 
    if (agfindattr(g->proto->n, "style") == NULL)
162
 
        agnodeattr(g, "style", "filled");
163
 
#endif
164
135
    if ((p = agget(g, "Defcolor")))
165
136
        setcolor(p, Defcolor);
166
137
 
265
236
    }
266
237
}
267
238
 
268
 
#ifdef USE_CGRAPH
269
239
static Agraph_t *gread(FILE * fp)
270
240
{
271
241
    return agread(fp, (Agdisc_t *) 0);
272
242
}
273
 
#endif
274
243
 
275
244
int main(int argc, char **argv)
276
245
{
278
247
    ingraph_state ig;
279
248
 
280
249
    init(argc, argv);
281
 
#ifdef USE_CGRAPH
282
250
    newIngraph(&ig, Files, gread);
283
 
#else
284
 
    newIngraph(&ig, Files, agread);
285
 
    aginit();
286
 
#endif
287
251
 
288
252
    while ((g = nextGraph(&ig)) != 0) {
289
253
        color(g);