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
52
53
54
55
56
57
58
59
60
61
62
63
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <chars.h>
include "lroff.h"
# RIGHT_JUSTIFY -- Right justify the text string argument in LINEBUF on the
# next input line, and write to the output.
procedure right_justify (in, out, linebuf, ip)
extern in(), out()
char linebuf[ARB]
int ip
pointer sp, rjbuf
int in(), input()
errchk salloc, breakline, input, rjline
include "lroff.com"
begin
call smark (sp)
call salloc (rjbuf, SZ_IBUF, TY_CHAR)
call breakline (out, NJ)
if (input (in, Memc[rjbuf]) != EOF)
call rjline (out, Memc[rjbuf], linebuf[ip])
call sfree (sp)
end
# RJLINE -- Right justify a text string on an unfilled input line and
# send it out.
procedure rjline (out, input_line, rjtext)
extern out()
char input_line[ARB] # unfilled input line
char rjtext[ARB] # string to be right justified on same line
int i, nblanks, len_rjtext, next_output_column
int textlen()
errchk outstr, outc, outline
include "lroff.com"
begin
# Breakline should already have been called by the time we get here.
# Output the input line at the left margin without filling.
call outstr (out, input_line)
# Determine the (printable) length of the rjtext string, and space
# over so that it comes out right justified. Always output at least
# one space. Exceed the right margin if necessary.
call getoutcol (next_output_column)
len_rjtext = textlen (rjtext)
nblanks = max (1, right_margin - (next_output_column + len_rjtext) + 1)
do i = 1, nblanks
call outc (out, BLANK)
call outline (out, rjtext)
end
|