BSD 4_4 release
[unix-history] / usr / src / usr.bin / struct / struct / 0.graph.c
/*-
* This module is believed to contain source code proprietary to AT&T.
* Use and redistribution is subject to the Berkeley Software License
* Agreement and your Software Agreement with AT&T (Western Electric).
*/
#ifndef lint
static char sccsid[] = "@(#)0.graph.c 8.1 (Berkeley) 6/6/93";
#endif /* not lint */
#include <stdio.h>
#include "def.h"
#define TABOVER(n) tabover(n,stderr)
prgraph()
{
VERT v;
int i;
if (progress) fprintf(stderr,"prgraph():\n");
for (v = 0; v < nodenum; ++v)
{
fprintf(stderr,"%d %s:",v, typename[NTYPE(v)]);
for (i = 0; i < ARCNUM(v); ++i)
{
printf("%d ",ARC(v,i));
ASSERT(UNDEFINED <= ARC(v,i) && ARC(v,i) < nodenum, prgraph);
}
printf("\n");
}
printf("\n\n");
}
prtree()
{
prtr(START,1);
}
prtr(v,tab) /* print tree in form of program indenting by tab */
VERT v;
int tab;
{
int i;
TABOVER(tab);
fprintf(stderr,"%d %s:",v,typename[NTYPE(v)]);
for (i = 0; i < ARCNUM(v); ++i)
fprintf(stderr," %d",ARC(v,i));
printf("\n");
for (i = 0; i < CHILDNUM(v); ++i)
{
TABOVER(tab+1);
fprintf(stderr,"{\n");
if (DEFINED(LCHILD(v,i)))
prtr(LCHILD(v,i),tab+1);
TABOVER(tab+1);
fprintf(stderr,"}\n");
}
if (DEFINED(RSIB(v)))
prtr(RSIB(v),tab);
}
tabover(n,fd) /* tab n times */
int n;
FILE *fd;
{
int i;
for (i = 0; i < n; ++i)
putc('\t',fd);
}