aboutsummaryrefslogtreecommitdiff
path: root/unix/boot/spp/rpp/rpprat/outch.r
blob: f7dfa99e734a252c356a9e321937aa9b0ec0b041 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
include  defs

# outch - put one character into output buffer

subroutine outch (c)

character c, splbuf(SZ_SPOOLBUF+1)
integer i, ip, op, index
include COMMON_BLOCKS
external index
string	break_chars " ),.+-*/("

	# Process a continuation card.  Try to break the card at a whitespace
	# division, operator, or punctuation mark.

	if (outp >= 72) {
	    if (index (break_chars, c) > 0)		# find break point
		ip = outp
	    else {
		for (ip=outp;  ip >= 1;  ip=ip-1) {
		    if (index (break_chars, outbuf(ip)) > 0)
			break
		}
	    }

	    if (ip != outp & (outp-ip) < SZ_SPOOLBUF) {
		op = 1
		for (i=ip+1;  i <= outp;  i=i+1) {	# save chars
		    splbuf(op) = outbuf(i)
		    op = op + 1
		}
		splbuf(op) = EOS
		outp = ip
	    } else
		splbuf(1) = EOS

	    call outdon
	    
	    for (op=1;  op < col;  op=op+1)
		outbuf(op) = BLANK
	    outbuf(6) = STAR
	    outp = col
	    for (ip=1;  splbuf(ip) != EOS;  ip=ip+1) {
		outp = outp + 1
		outbuf(outp) = splbuf(ip)
	    }
	}

	outp = outp + 1				# output character
	outbuf(outp) = c
end