date and time created 83/02/11 15:43:53 by rrh
authorRobert R. Henry <rrh@ucbvax.Berkeley.EDU>
Sat, 12 Feb 1983 07:43:53 +0000 (23:43 -0800)
committerRobert R. Henry <rrh@ucbvax.Berkeley.EDU>
Sat, 12 Feb 1983 07:43:53 +0000 (23:43 -0800)
SCCS-vsn: usr.bin/struct/struct/0.graph.c 4.1

usr/src/usr.bin/struct/struct/0.graph.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/struct/struct/0.graph.c b/usr/src/usr.bin/struct/struct/0.graph.c
new file mode 100644 (file)
index 0000000..de9584e
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef lint
+static char sccsid[] = "@(#)0.graph.c  4.1     (Berkeley)      %G%";
+#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);
+       }