aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/htmlroff/t6.c
blob: 3090cd262d3c60af6decb4e83f8bc9fc3d289926 (plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "a.h"

/*
 * Section 6 - line length and indenting.
 */

/* set line length */
void
ll(int v)
{
	if(v == 0)
		v = getnr(L(".l0"));
	nr(L(".l0"), getnr(L(".l")));
	nr(L(".l"), v);
}
void
r_ll(int argc, Rune **argv)
{
	if(argc < 2)
		ll(0);
	else if(argv[1][0] == '+')
		ll(getnr(L(".l"))+evalscale(argv[1]+1, 'v'));
	else if(argv[1][0] == '-')
		ll(getnr(L(".l"))-evalscale(argv[1]+1, 'v'));
	else
		ll(evalscale(argv[1], 'm'));
	if(argc > 2)
		warn("extra arguments to .ll");
}

void
in(int v)
{
	nr(L(".i0"), getnr(L(".i")));
	nr(L(".i"), v);
	nr(L(".ti"), 0);
	/* XXX */
}
void
r_in(int argc, Rune **argv)
{
	br();
	if(argc < 2)
		in(getnr(L(".i0")));
	else if(argv[1][0] == '+')
		in(getnr(L(".i"))+evalscale(argv[1]+1, 'm'));
	else if(argv[1][0] == '-')
		in(getnr(L(".i"))-evalscale(argv[1]+1, 'm'));
	else
		in(evalscale(argv[1], 'm'));
	if(argc > 3)
		warn("extra arguments to .in");
}

void
ti(int v)
{
	nr(L(".ti"), v);
}
void
r_ti(int argc, Rune **argv)
{
	USED(argc);
	br();
	ti(evalscale(argv[1], 'm'));
}

void
t6init(void)
{
	addreq(L("ll"), r_ll, -1);
	addreq(L("in"), r_in, -1);
	addreq(L("ti"), r_ti, 1);

	nr(L(".l"), eval(L("6.5i")));
}