]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/htmlroff/t11.c
fix ref822 again: remove uniqarray(), fix case with many entries in 'n'.
[plan9front.git] / sys / src / cmd / htmlroff / t11.c
1 #include "a.h"
2
3 /*
4  * 11. Local Horizontal and Vertical Motions, and the Width Function.
5  */
6
7 int
8 e_0(void)
9 {
10         /* digit-width space */
11         return ' ';
12 }
13
14 int
15 dv(int d)
16 {
17         Rune sub[6];
18
19         d += getnr(L(".dv"));
20         nr(L(".dv"), d);
21
22         runestrcpy(sub, L("<sub>"));
23         sub[0] = Ult;
24         sub[4] = Ugt;
25         if(d < 0){
26                 sub[3] = 'p';
27                 ihtml(L(".dv"), sub);
28         }else if(d > 0)
29                 ihtml(L(".dv"), sub);
30         else
31                 ihtml(L(".dv"), nil);
32         return 0;
33 }
34
35 int
36 e_v(void)
37 {
38         dv(eval(getqarg()));
39         return 0;
40 }
41
42 int
43 e_u(void)
44 {
45         dv(eval(L("-0.5m")));
46         return 0;
47 }
48
49 int
50 e_d(void)
51 {
52         dv(eval(L("0.5m")));
53         return 0;
54 }
55
56 int
57 e_r(void)
58 {
59         dv(eval(L("-1m")));
60         return 0;
61 }
62
63 int
64 e_h(void)
65 {
66         getqarg();
67         return 0;
68 }
69
70 int
71 e_w(void)
72 {
73         Rune *a;
74         Rune buf[40];
75         
76         a = getqarg();
77         runesnprint(buf, sizeof buf, "%ld", runestrlen(a));
78         pushinputstring(buf);
79         nr(L("st"), 0);
80         nr(L("sb"), 0);
81         nr(L("ct"), 0);
82         return 0;
83 }
84
85 int
86 e_k(void)
87 {
88         getname();
89         warn("%Ck not available", backslash);
90         return 0;
91 }
92
93 void
94 t11init(void)
95 {
96         addesc('|', e_nop, 0);
97         addesc('^', e_nop, 0);
98         addesc('v', e_v, 0);
99         addesc('h', e_h, 0);
100         addesc('w', e_w, 0);
101         addesc('0', e_0, 0);
102         addesc('u', e_u, 0);
103         addesc('d', e_d, 0);
104         addesc('r', e_r, 0);
105         addesc('k', e_k, 0);
106 }
107