-
Notifications
You must be signed in to change notification settings - Fork 2
/
special_parser.awk
executable file
·90 lines (77 loc) · 2.44 KB
/
special_parser.awk
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
88
89
90
#!/usr/bin/awk -f
################################################################################
# special_parser.awk - parsing script for awkiawki
# $Id: special_parser.awk,v 1.5 2003/07/07 11:22:55 olt Exp $
################################################################################
# Copyright (c) 2002 Oliver Tonnhofer ([email protected])
# See the file `COPYING' for copyright notice.
################################################################################
BEGIN {
scriptname = ENVIRON["SCRIPT_NAME"]
if (special_changes)
print "<table>"
if (special_history) {
# use the power of awk to split the information of rlog
RS = "----------------------------\n"
FS = "\n"
print "<table>\n<tr><th>version</th><th>date</th><th>ip</th><th>comment</th>"
print "<th>view version</th><th>edit version</th><th>diff to current</th></tr>"
}
if (special_diff)
print "<pre>"
}
special_changes && $9 ~ /^[A-Z][a-z]+[A-Z][A-Za-z]*$/ {
filenr++
print "<tr><td>" generate_link($9) "</td><td>"$7" "$6" "$8"</td></tr>"
if (filenr == special_changes)
exit
}
special_index && /^[A-Z][a-z]+[A-Z][A-Za-z]*$/ {
print generate_link($0) "<br>"
}
special_search && /[A-Z][a-z]+[A-Z][A-Za-z]*$/ {
sub(/^.*[^\/]\//, "")
print generate_link($0) "<br>"
}
special_history && NR > 1 {
#pick revision number
match($1, /[1-9]\.[0-9]+/)
revision = substr($1, RSTART, RLENGTH)
#split the double-semicolon seperated information line
split($3, sp_array, ";;")
ip_address = sp_array[1]
date = sp_array[2]
comment = sp_array[3]
if (NR == 2)
revision = "current"
print "<tr align=center><td>"revision"</td><td>"date"</td><td>"ip_address"</td><td>"comment"</td>"
print "<td><a href=\""scriptname"/"special_history
if (NR > 2)
print "?revision="revision
print "\">view</a></td>"
print "<td><a href=\""scriptname"/?edit=true&"
if (NR >2)
print "revision="revision"&"
print "page="special_history"\">edit</a></td>"
if (NR >2)
print "<td><a href=\""scriptname"/?diff=true&page="special_history"&revision="revision"\">diff</a></td>"
print "</tr>"
}
special_diff && (NR >2) {
if (/^\+/)
print "<span class=\"new\">"$0"</span>"
else if (/^\-/)
print "<span class=\"old\">"$0"</span>"
else
print $0
}
END {
if (special_changes || special_history)
print "</table>"
if (special_diff)
print "</pre>"
}
function generate_link(string) {
sub(/[A-Z][a-z]+[A-Z][A-Za-z]*/, "<a href=\""scriptname"/&\">&</a>", string)
return(string)
}