~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to cdt/dtview.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
9
*/
 
10
#include        "dthdr.h"
 
11
 
 
12
#ifdef DMALLOC
 
13
#include "dmalloc.h"
 
14
#endif
 
15
 
 
16
/*      Set a view path from dict to view.
 
17
**
 
18
**      Written by Kiem-Phong Vo (5/25/96)
 
19
*/
 
20
 
 
21
 
 
22
#if __STD_C
 
23
static Void_t* dtvsearch(Dt_t* dt, reg Void_t* obj, reg int type)
 
24
#else
 
25
static Void_t* dtvsearch(dt,obj,type)
 
26
Dt_t*           dt;
 
27
reg Void_t*     obj;
 
28
reg int         type;
 
29
#endif
 
30
{
 
31
        reg Dt_t        *d, *p;
 
32
        reg Void_t*     o;
 
33
        reg Dtdisc_t*   disc;
 
34
        reg Dtlink_t*   here;
 
35
 
 
36
        /* these operations only happen at the top level */
 
37
        if(type&(DT_INSERT|DT_DELETE|DT_CLEAR|DT_RENEW))
 
38
                return (*(dt->meth->searchf))(dt,obj,type);
 
39
 
 
40
        if(!obj && !(type&(DT_FIRST|DT_LAST)) )
 
41
                return NIL(Void_t*);
 
42
 
 
43
        if(type&(DT_MATCH|DT_SEARCH|DT_FIRST|DT_LAST))
 
44
        {       for(d = dt; d; d = d->view)
 
45
                {       if((o = (*(d->meth->searchf))(d,obj,type)) )
 
46
                        {       dt->walk = d;
 
47
                                return o;
 
48
                        }
 
49
                }
 
50
 
 
51
                dt->walk = NIL(Dt_t*);
 
52
                return NIL(Void_t*);
 
53
        }
 
54
 
 
55
        /* must be (DT_NEXT|DT_PREV) */
 
56
        if(!dt->walk || !(here = dt->walk->data->here) ||
 
57
           obj != OBJ(here,dt->walk->disc->link) )
 
58
        {       for(d = dt; d; d = d->view)
 
59
                {       if((o = (*(d->meth->searchf))(d,obj,DT_SEARCH)) )
 
60
                        {       dt->walk = d;
 
61
                                goto do_adj;
 
62
                        }
 
63
                }
 
64
 
 
65
                dt->walk = NIL(Dt_t*);
 
66
                return NIL(Void_t*);
 
67
        }
 
68
 
 
69
do_adj: for(d = dt->walk, o = (*(d->meth->searchf))(d,obj,type); ; )
 
70
        {       while(o)
 
71
                {       disc = d->disc;
 
72
                        here = (d->meth->type&(DT_SET|DT_BAG)) ?
 
73
                                        d->data->here : NIL(Dtlink_t*);
 
74
 
 
75
                        for(p = dt; ; p = p->view)
 
76
                        {       reg Dtdisc_t*   dc;
 
77
 
 
78
                                if(p == d) /* this object is uncovered */       
 
79
                                        return o;
 
80
 
 
81
                                /* see if it is covered */
 
82
                                if(here && (p->meth->type&(DT_SET|DT_BAG)) &&
 
83
                                   (disc == (dc = p->disc) ||
 
84
                                    (disc->key == dc->key && disc->size == dc->size &&
 
85
                                     disc->link == dc->link && disc->hashf == dc->hashf)))
 
86
                                {       if((*(p->meth->searchf))(p,here,DT_VSEARCH) )
 
87
                                                break;
 
88
                                }
 
89
                                else
 
90
                                {       if((*(p->meth->searchf))(p,o,DT_SEARCH) )
 
91
                                                break;
 
92
                                }
 
93
                        }
 
94
 
 
95
                        o = (*(d->meth->searchf))(d,o,type);
 
96
                }
 
97
 
 
98
                if(!(d = dt->walk = d->view) )
 
99
                        return NIL(Void_t*);
 
100
 
 
101
                if(type&DT_NEXT)
 
102
                        o = (*(d->meth->searchf))(d,NIL(Void_t*),DT_FIRST);
 
103
                else /* if(type&DT_PREV) */
 
104
                        o = (*(d->meth->searchf))(d,NIL(Void_t*),DT_LAST);
 
105
        }
 
106
}
 
107
 
 
108
#if __STD_C
 
109
Dt_t* dtview(reg Dt_t* dt, reg Dt_t* view)
 
110
#else
 
111
Dt_t* dtview(dt,view)
 
112
reg Dt_t*       dt;
 
113
reg Dt_t*       view;
 
114
#endif
 
115
{
 
116
        reg Dt_t*       d;
 
117
 
 
118
        UNFLATTEN(dt);
 
119
        if(view)
 
120
                UNFLATTEN(view);
 
121
 
 
122
        /* make sure there won't be a cycle */
 
123
        for(d = view; d; d = d->view)
 
124
                if(d == dt)
 
125
                        return NIL(Dt_t*);
 
126
 
 
127
        /* no more viewing lower dictionary */
 
128
        if((d = dt->view) )
 
129
                d->nview -= 1;
 
130
        dt->view = dt->walk = NIL(Dt_t*);
 
131
 
 
132
        if(!view)
 
133
        {       dt->searchf = dt->meth->searchf;
 
134
                return d;
 
135
        }
 
136
 
 
137
        /* ok */
 
138
        dt->view = view;
 
139
        dt->searchf = dtvsearch;
 
140
        view->nview += 1;
 
141
 
 
142
        return view;
 
143
}