Bell 32V development
[unix-history] / usr / src / cmd / struct / 4.form.c
CommitLineData
6fd945b9
TL
1#include <stdio.h>
2#
3#include "def.h"
4#include "4.def.h"
5extern int linechars;
6extern int rdfree(), comfree(), labfree(), contfree();
7extern int rdstand(), comstand(), labstand(), contstand();
8extern int (*rline[])();
9extern int (*comment[])();
10extern int (*getlabel[])();
11extern int (*chkcont[])();
12null(c)
13char c;
14 {return;}
15
16
17
18comprint()
19 {
20 int c, blank, first,count;
21 blank = 1;
22 first = 1;
23 count = 0;
24 while ((c = (*comment[inputform])(0) ) || blankline() )
25 {
26 ++count;
27 if (c)
28 {
29 (*comment[inputform])(1); /* move head past comment signifier */
30 blank = blankline();
31 /* if (first && !blank)
32 OUTSTR("#\n");*/
33 prline("#");
34 first = 0;
35 }
36 else
37 (*rline[inputform])(null);
38 }
39 /* if (!blank)
40 OUTSTR("#\n"); */
41 return(count);
42 }
43
44
45
46prcode(linecount,tab)
47int linecount, tab;
48 {
49 int someout;
50 someout = FALSE;
51 while (linecount)
52 {
53 if ( (*comment[inputform])(0) )
54 {
55 linecount -= comprint();
56 someout = TRUE;
57 continue;
58 }
59 else if (blankline() )
60 (*rline[inputform])(null);
61 else if ((*chkcont[inputform])() )
62 {
63 TABOVER(tab);
64 prline("&");
65 someout = TRUE;
66 }
67 else
68 {if (someout) TABOVER(tab);
69 (*getlabel[inputform])(null);
70 prline("");
71 someout=TRUE;
72 }
73 --linecount;
74 }
75 }
76
77
78charout(c)
79char c;
80 {
81 putc(c,outfd);
82 }
83
84
85
86prline(str)
87char *str;
88 {
89 fprintf(outfd,"%s",str);
90 (*rline[inputform]) (charout);
91 putc('\n',outfd);
92 }
93
94
95input2()
96 {
97 static int c;
98 c = inchar();
99 if (c == '\n')
100 linechars = 0;
101 else
102 ++linechars;
103 return(c);
104 }
105
106
107unput2(c)
108int c;
109 {
110 unchar(c);
111 --linechars;
112 return(c);
113 }