-
Notifications
You must be signed in to change notification settings - Fork 0
/
changelog-to-rss
executable file
·88 lines (75 loc) · 1.85 KB
/
changelog-to-rss
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
78
79
80
81
82
83
84
85
86
87
#! /usr/bin/awk -f
# this converts entries in the CHANGELOG into RSS items
function printitem () {
if (itemdate == "") {
return;
}
gsub (/&/, "&", itemdesc);
gsub (/</, "<", itemdesc);
gsub (/>/, ">", itemdesc);
printf ("<item>\n");
printf ("<title>change by %s on %s</title>\n", itemauthor, itemdate);
printf ("<description>%s</description>\n", itemdesc);
printf ("</item>\n");
itemdate = "";
}
function printrsshead () {
printf ("<?xml version=\"1.0\"?>\n");
printf ("<!-- RSS generated by changelog-to-rss -->\n");
printf ("<rss version=\"2.0\">\n");
printf ("<channel>\n");
printf ("<title>NOCC changelog</title>\n");
printf ("<link>http://www.cs.kent.ac.uk/projects/ofa/nocc/</link>\n");
printf ("<description>NOCC changelog (a new occam-pi compiler)</description>\n");
printf ("<language>en-gb</language>\n");
printf ("<generator>changelog-to-rss</generator>\n");
printf ("<webMaster>[email protected]</webMaster>\n");
printf ("<ttl>240</ttl>\n");
}
function printrsstail () {
printf ("</channel>\n");
printf ("</rss>\n");
}
BEGIN {
lno = 0;
lastline = "";
itemdate = "";
itemauthor = "";
itemdesc = "";
printrsshead();
}
{
lno++;
if (lno > 1) {
if (substr ($0, 1, 1) == " ") {
# continuation of a previous item
str = $0;
sub (/^[\t ]*/, "", str)
#while (substr (str, 1, 1) == " ") {
# str = substr (str, 2);
#}
if (substr (lastline, length (lastline), 1) == "-") {
itemdesc = sprintf ("%s%s", itemdesc, str);
} else {
itemdesc = sprintf ("%s %s", itemdesc, str);
}
} else {
# a new item -- output the last
printitem();
itemdate = $1;
itemauthor = $2;
itemdesc = "";
i = 3;
nfields = split ($0, AR, /[ \t]/);
while (i <= nfields) {
itemdesc = sprintf ("%s %s", itemdesc, AR[i]);
i++;
}
}
lastline = $0;
}
}
END {
printitem();
printrsstail();
}