forked from mit-pdos/xv6-book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
figures
executable file
·77 lines (66 loc) · 871 Bytes
/
figures
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
77
#!/bin/sh
# Insert figures into ditroff output.
./ditspaces "$@" |
awk '
BEGIN {
capture = 0
nlines = 0
nshift = 0
}
function flushpage()
{
for(i=0; i<nline; i++)
print line[i]
nline = 0
nshift = 0
capture = 0
}
function shiftlines(n)
{
for(i=nshift; i<nline; i++)
if(line[i] ~ /^V/)
line[i] = "V" (substr(line[i], 2)+n)
nshift=nline
}
/^p[0-9]/ {
flushpage()
top = 0
}
END {
flushpage()
}
/^[HV]/ {
capture = 1
}
!capture {
print
}
capture {
line[nline++] = $0
}
/x X top / {
top = $NF
}
/x X figure / {
print "x X ---- begin figure " top "----"
file=$(NF-1)
height=$NF
shiftlines(height)
trigger = 0
while(getline <file > 0) {
if(/^H/)
trigger = 1
if(!trigger)
continue
if(/^x X end/)
break
s = $0
if(/^V/) {
s = "V" (substr(s, 2)+top)
}
print s
}
top += height
print "x X ---- end figure ----"
}
'