blob: eb0db0324539026f3209b74bcf9a0e2d7cd56019 [file] [log] [blame]
Daniel Veillard418968b2004-05-16 00:15:10 +00001#!/bin/awk -f
Daniel Veillarda98357a2004-05-16 05:06:59 +00002function translate(str) {
3 while (sub(/&/, "#amp;", str) == 1);
4 while (sub(/#amp;/, "\\&", str) == 1); # fun isn't it ?
5 while (sub(/</, "\\&lt;", str) == 1);
6 while (sub(/>/, "\\&gt;", str) == 1);
7 sub(/[0-9][0-9][0-9][0-9][0-9]+/, "<bug number='&'/>", str)
8 return(str)
9}
Daniel Veillard418968b2004-05-16 00:15:10 +000010BEGIN {
11 nb_entry = 0
12 in_entry = 0
13 in_item = 0
Daniel Veillard93ebc212004-05-16 00:34:22 +000014 print "<?xml version='1.0' encoding='ISO-8859-1'?>"
Daniel Veillard418968b2004-05-16 00:15:10 +000015 print "<log>"
16 }
17END {
Daniel Veillarda98357a2004-05-16 05:06:59 +000018 if (in_item == 1) printf("%s</item>\n", translate(item))
Daniel Veillard418968b2004-05-16 00:15:10 +000019 if (in_entry == 1) print " </entry>"
20 print "</log>"
21 }
22/^[ \t]*$/ { next }
Daniel Veillard96134ca2004-05-16 01:08:06 +000023/^[A-Za-z0-9]/ {
Daniel Veillard418968b2004-05-16 00:15:10 +000024 match($0, "\(.*\) \([A-Z]+\) \([0-9][0-9][0-9][0-9]\) \(.*\) <\(.*\)>", loge)
Daniel Veillarda98357a2004-05-16 05:06:59 +000025 if (in_item == 1) printf("%s</item>\n", translate(item))
Daniel Veillard418968b2004-05-16 00:15:10 +000026 if (in_entry == 1) print " </entry>"
27 nb_entry = nb_entry + 1
28 if (nb_entry > 50) {
29 in_entry = 0
30 in_item = 0
31 exit
32 }
33 in_entry = 1
34 in_item = 0
35 printf(" <entry date='%s' timezone='%s' year='%s'\n who='%s' email='%s'>\n", loge[1], loge[2], loge[3], loge[4], loge[5])
36 }
37/^[ \t]*\*/ {
Daniel Veillarda98357a2004-05-16 05:06:59 +000038 if (in_item == 1) printf("%s</item>\n", translate(item))
Daniel Veillard418968b2004-05-16 00:15:10 +000039 in_item = 1
40 printf(" <item>")
41 match($0, "[ \t]*. *\(.*\)", loge)
42 item = loge[1]
43 }
44/^[ \t]*[a-zA-Z0-9\#]/ {
45 if (in_item == 1) {
46 match($0, "[ \t]*\(.*\)[ \t]*", loge)
47 item = sprintf("%s %s", item, loge[1])
48 }
49 }