2
This software may only be used by you under license from AT&T Corp.
3
("AT&T"). A copy of AT&T's Source Code Agreement is available at
4
AT&T's Internet website having the URL:
5
<http://www.research.att.com/sw/tools/graphviz/license/source.html>
6
If you received this software without first entering into a license
7
with AT&T, you have an infringing copy of this software and cannot use
8
it without violating AT&T's intellectual property rights.
12
/* Lefteris Koutsofios - AT&T Bell Laboratories */
21
typedef struct dnode_t {
27
typedef struct seennode_t {
31
static seennode_t *seenp;
32
static int seeni, seenn;
34
#define SEENSIZE sizeof (seennode_t)
36
static int indent, afternl;
38
static void update (dnode_t *);
39
static int cmp (const void *, const void *);
40
static seennode_t *findseen (dnode_t *);
41
static void add2seen (dnode_t *);
42
static void pr (char *);
45
seenp = Marrayalloc ((long) SEENINCR * SEENSIZE);
55
void Dtrace (Tobj to, int offset) {
62
if (Tgettype (to) != T_TABLE) {
63
pr ((s = Ssfull (NULL, to))), free (s);
71
for (i = 0; i < seeni; i++)
72
free (seenp[i].path), seenp[i].path = NULL;
75
static void update (dnode_t *pnode) {
77
dnode_t *list, *cnode;
83
n = ((Ttable_t *) pnode->vo)->n;
84
if (!(list = malloc (n * sizeof (dnode_t))))
85
panic (POS, "update", "list malloc failed");
86
for (cnode = &list[0], Tgetfirst (pnode->vo, &tkvi); tkvi.kvp;
87
cnode++, Tgetnext (&tkvi)) {
88
cnode->ko = tkvi.kvp->ko;
89
cnode->vo = tkvi.kvp->vo;
90
cnode->ttype = Tgettype (cnode->vo);
92
qsort ((char *) list, n, sizeof (dnode_t), cmp);
93
for (i = 0, cnode = &list[0]; i < n; i++, cnode++) {
94
cnode->path = Spath (pnode->path, cnode->ko);
95
seennode = findseen (cnode);
97
pr ((s = Sseen (cnode->ko, seennode->path))), free (s);
100
if (cnode->ttype == T_TABLE) {
101
pr ((s = Stfull (cnode->ko))), free (s);
105
pr ((s = Ssfull (cnode->ko, cnode->vo))), free (s);
113
static int cmp (const void *a, const void *b) {
114
Ttype_t atype, btype;
115
dnode_t *anode, *bnode;
118
anode = (dnode_t *) a, bnode = (dnode_t *) b;
119
atype = Tgettype (anode->ko), btype = Tgettype (bnode->ko);
121
return (atype - btype);
122
if (atype == T_STRING)
123
return Strcmp (Tgetstring (anode->ko), Tgetstring (bnode->ko));
124
if (atype == T_INTEGER)
125
d1 = Tgetinteger (anode->ko), d2 = Tgetinteger (bnode->ko);
126
else if (atype == T_REAL)
127
d1 = Tgetreal (anode->ko), d2 = Tgetreal (bnode->ko);
133
return 0; /* but this should never happen since keys are unique */
136
static seennode_t *findseen (dnode_t *cnode) {
139
for (i = 0; i < seeni; i++)
140
if (seenp[i].vo == cnode->vo)
145
static void add2seen (dnode_t *cnode) {
146
if (seeni >= seenn) {
147
seenp = Marraygrow (seenp, (long) (seenn + SEENINCR) * SEENSIZE);
150
seenp[seeni].vo = cnode->vo;
151
seenp[seeni++].path = cnode->path;
154
static void pr (char *s) {
158
for (s1 = s; *s1; s1++) {
160
for (i = 0; i < indent; i++)
166
putchar ((*s1)); /* HACK: to keep proto happy */