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

« back to all changes in this revision

Viewing changes to lib/cgraph/write.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2008-11-05 09:54:54 UTC
  • mfrom: (1.2.6 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20081105095454-ly206extt9viqwia
Tags: 2.20.2-3ubuntu1
* Merge with Debian unstable; remaining Ubuntu changes:
  - Build against guile 1.8 instead of 1.6. (forwarded to Debian #493974)
  - Fix gs-common build dependency to ghostscript. (forwarded to 
    Debian #504569)
  - Update build dep libltdl3-dev to libltdl7-dev. (forwarded to
    Debian #504571)
* Build against lua 5.1 instead of 5.0. This drops this Debian delta and
  moves Ubuntu towards the newer lua version, which we need to do at some
  point anyway.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: write.c,v 1.4 2008/03/04 17:54:53 arif Exp $ $Revision: 1.4 $ */
 
1
/* $Id: write.c,v 1.8 2008/04/30 15:18:03 erg Exp $ $Revision: 1.8 $ */
2
2
/* vim:set shiftwidth=4 ts=8: */
3
3
 
4
4
/**********************************************************
21
21
#define EMPTY(s)                ((s == 0) || (s)[0] == '\0')
22
22
#define MAX(a,b)     ((a)>(b)?(a):(b))
23
23
 
24
 
#ifdef WIN32
25
 
extern int strcasecmp(const char *s1, const char *s2);
26
 
extern int strncasecmp(const char *s1, const char *s2, unsigned int n);
27
 
#endif
28
 
 
29
 
 
30
24
typedef void iochan_t;
31
25
 
32
26
static void ioput(Agraph_t * g, iochan_t * ofile, char *str)
46
40
        ioput(g, ofile, "\t");
47
41
}
48
42
 
 
43
#ifndef HAVE_STRCASECMP
 
44
 
 
45
#include <string.h>
 
46
 
 
47
static int strcasecmp(const char *s1, const char *s2)
 
48
{
 
49
    while ((*s1 != '\0')
 
50
           && (tolower(*(unsigned char *) s1) ==
 
51
               tolower(*(unsigned char *) s2))) {
 
52
        s1++;
 
53
        s2++;
 
54
    }
 
55
 
 
56
    return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
 
57
}
 
58
#endif
 
59
 
49
60
/* _agstrcanon:
50
61
 * Canonicalize ordinary strings. 
51
62
 * Assumes buf is large enough to hold output.
275
286
    ioput(g, ofile, "}\n");
276
287
}
277
288
 
278
 
static int localsize(Dict_t * d)
279
 
{
280
 
    int rv;
281
 
    Dict_t *view;
282
 
    view = dtview(d, NIL(Dict_t *));
283
 
    rv = dtsize(d);
284
 
    dtview(d, view);
285
 
    return rv;
286
 
}
287
 
 
288
289
static int irrelevant_subgraph(Agraph_t * g)
289
290
{
290
291
    int i, n;
291
 
    Agattr_t *sdata, *pdata;
 
292
    Agattr_t *sdata, *pdata, *rdata;
292
293
    Agdatadict_t *dd;
293
294
 
294
295
    char *name;
297
298
    if (name && name[0] != LOCALNAMEPREFIX)
298
299
        return FALSE;
299
300
    if ((sdata = agattrrec(g)) && (pdata = agattrrec(agparent(g)))) {
300
 
        n = dtsize(sdata->dict);
 
301
        rdata = agattrrec(agroot(g));
 
302
        n = dtsize(rdata->dict);
301
303
        for (i = 0; i < n; i++)
302
304
            if (sdata->str[i] && pdata->str[i]
303
305
                && strcmp(sdata->str[i], pdata->str[i]))
304
306
                return FALSE;
305
307
    }
306
308
    dd = agdatadict(g);
307
 
    if ((localsize(dd->dict.n) > 0) || (localsize(dd->dict.e) > 0))
 
309
    if ((dtsize(dd->dict.n) > 0) || (dtsize(dd->dict.e) > 0))
308
310
        return FALSE;
309
311
    return TRUE;
310
312
}