Daniel Veillard | 418968b | 2004-05-16 00:15:10 +0000 | [diff] [blame] | 1 | #!/bin/awk -f |
Daniel Veillard | a98357a | 2004-05-16 05:06:59 +0000 | [diff] [blame] | 2 | function translate(str) { |
| 3 | while (sub(/&/, "#amp;", str) == 1); |
| 4 | while (sub(/#amp;/, "\\&", str) == 1); # fun isn't it ? |
| 5 | while (sub(/</, "\\<", str) == 1); |
| 6 | while (sub(/>/, "\\>", str) == 1); |
| 7 | sub(/[0-9][0-9][0-9][0-9][0-9]+/, "<bug number='&'/>", str) |
| 8 | return(str) |
| 9 | } |
Daniel Veillard | 418968b | 2004-05-16 00:15:10 +0000 | [diff] [blame] | 10 | BEGIN { |
| 11 | nb_entry = 0 |
| 12 | in_entry = 0 |
| 13 | in_item = 0 |
Daniel Veillard | 93ebc21 | 2004-05-16 00:34:22 +0000 | [diff] [blame] | 14 | print "<?xml version='1.0' encoding='ISO-8859-1'?>" |
Daniel Veillard | 418968b | 2004-05-16 00:15:10 +0000 | [diff] [blame] | 15 | print "<log>" |
| 16 | } |
| 17 | END { |
Daniel Veillard | a98357a | 2004-05-16 05:06:59 +0000 | [diff] [blame] | 18 | if (in_item == 1) printf("%s</item>\n", translate(item)) |
Daniel Veillard | 418968b | 2004-05-16 00:15:10 +0000 | [diff] [blame] | 19 | if (in_entry == 1) print " </entry>" |
| 20 | print "</log>" |
| 21 | } |
| 22 | /^[ \t]*$/ { next } |
Daniel Veillard | 96134ca | 2004-05-16 01:08:06 +0000 | [diff] [blame] | 23 | /^[A-Za-z0-9]/ { |
Daniel Veillard | 418968b | 2004-05-16 00:15:10 +0000 | [diff] [blame] | 24 | match($0, "\(.*\) \([A-Z]+\) \([0-9][0-9][0-9][0-9]\) \(.*\) <\(.*\)>", loge) |
Daniel Veillard | a98357a | 2004-05-16 05:06:59 +0000 | [diff] [blame] | 25 | if (in_item == 1) printf("%s</item>\n", translate(item)) |
Daniel Veillard | 418968b | 2004-05-16 00:15:10 +0000 | [diff] [blame] | 26 | 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 Veillard | a98357a | 2004-05-16 05:06:59 +0000 | [diff] [blame] | 38 | if (in_item == 1) printf("%s</item>\n", translate(item)) |
Daniel Veillard | 418968b | 2004-05-16 00:15:10 +0000 | [diff] [blame] | 39 | 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 | } |