Skip to content

Commit b0bf66d

Browse files
committed
Add HTML output option to pgcvslog.
1 parent 865d26f commit b0bf66d

File tree

1 file changed

+70
-14
lines changed

1 file changed

+70
-14
lines changed

src/tools/pgcvslog

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,27 @@
1919
# find . -name CVS -type d -exec rm '{}/Entries.Static' \;
2020
#
2121

22+
if [ "X$1" == "X-h" ]
23+
then HTML="Y"
24+
shift
25+
else HTML="N"
26+
fi
27+
2228
cat "$@" |
2329

30+
# protect HTML input if in HTML mode
31+
if [ "$HTML" = "Y" ]
32+
then sed -e 's/\&/\&/g' \
33+
-e 's/</\&lt;/g' \
34+
-e 's/>/\&gt;/g' \
35+
-e 's/"/\&quot;/g'
36+
else cat
37+
fi |
38+
2439
# mark each line with a datetime and line number, for sorting and merging
2540
# We don't print anything from the -- or == line and the date:
2641

27-
awk '
42+
awk ' BEGIN {html="'"$HTML"'"; lineno = 0;}
2843
# store working directory
2944
$0 ~ /^Working file:/ {workingfile = "/" $3}
3045

@@ -33,27 +48,39 @@ awk '
3348
# print blank line to separate entries
3449
if (datetime != "")
3550
{
36-
printf ("%s| %10d|%s\n", datetime, NR, "");
37-
printf ("%s| %10d|%s\n", datetime, NR, "---");
51+
if (html != "Y")
52+
printf ("%s| %10d|%s\n", datetime, lineno++, "");
53+
printf ("%s| %10d|", datetime, lineno++);
54+
if (html != "Y")
55+
printf ("%s\n", "---");
56+
else printf ("<HR>\n");
3857
}
3958
datetime="";
4059
}
4160

4261
# if we have a saved datetime, print filename, date line, and committer
43-
datetime != "" {printf ("%s| %10d| %s\n", datetime, NR, $0);}
62+
datetime != "" {printf ("%s| %10d| %s\n", datetime, lineno++, $0);}
4463

45-
$1 == "date:" \
64+
$1 == "date:" \
4665
{
4766
# get entry date
4867
datetime=$2"-"$3
4968
if (workingfile != "")
5069
{
70+
printf ("%s| %10d|", datetime, lineno++);
71+
if (html != "Y")
72+
printf ("%s\n", workingfile);
73+
else printf ("<SMALL><FONT COLOR=\"red\">%s</FONT></SMALL>\n", workingfile);
74+
75+
# output name of committer
5176
# remove semicolon from committers name
77+
gsub("/", "-", $2);
78+
gsub(";", "", $3);
5279
gsub(";", "", $5);
53-
printf ("%s| %10d|%s\n", datetime, NR-2, workingfile);
54-
printf ("%s| %10d|%s\n", datetime, NR-1, $0);
55-
# output name of committer
56-
printf ("%s| %10d| %70s\n", datetime, NR+1, $5);
80+
printf ("%s| %10d|", datetime, lineno++);
81+
if (html != "Y")
82+
printf ("%78s\n", $5);
83+
else printf ("<DIV ALIGN=\"right\"><SMALL><FONT COLOR=\"teal\">%s</FONT> <FONT COLOR=\"green\">%s</FONT></SMALL></DIV>\n", $5, $2);
5784
}
5885
}
5986

@@ -64,12 +91,11 @@ sort | cut -d'|' -f3 | cat |
6491

6592
# collect duplicate narratives
6693

67-
awk ' BEGIN { slot = 0; oldslot=0; save_working = ""; }
94+
awk ' BEGIN { slot = 0; oldslot=0; save_working = ""; html="'"$HTML"'"}
6895
{
6996
# We have a filename, so we look at the previous
7097
# narrative to see if it is new narrative text.
71-
#
72-
if ($0 ~ /^\//)
98+
if ($0 ~ /^\// || $0 ~ />\//)
7399
{
74100
# If there are a different number of narrative
75101
# lines, they can not possibly be the same.
@@ -93,7 +119,13 @@ awk ' BEGIN { slot = 0; oldslot=0; save_working = ""; }
93119
{
94120
if (oldslot)
95121
for (i=1; i <= oldslot; i++)
122+
{
96123
print oldnarr[i];
124+
if (html == "Y" &&
125+
oldnarr[i] != "<HR>" &&
126+
oldnarr[i] !~ "^<DIV ")
127+
print "<BR>";
128+
}
97129

98130
# save the current narrative
99131
for (i=1; i <= slot; i++)
@@ -104,22 +136,46 @@ awk ' BEGIN { slot = 0; oldslot=0; save_working = ""; }
104136

105137
# dump out the previous filename
106138
print save_working;
139+
if (html == "Y")
140+
print "<BR>";
107141

108142
# store the current filename for later printing
109143
save_working = $0;
110144
}
145+
else
111146
# we have a narrative line
112-
else if ($1 != "date:")
113147
{
114148
# accumulate narrative
115149
narr[++slot] = $0;
116150
}
117151
}
118152
END {
119153
# dump out the last filename
154+
120155
print save_working;
156+
if (html == "Y")
157+
print "<BR>";
121158

122159
# dump out the last narrative
123160
for (i=1; i <= slot; i++)
161+
{
124162
print narr[i];
125-
}'
163+
if (html == "Y" &&
164+
oldnarr[i] != "<HR>" &&
165+
oldnarr[i] !~ "^<DIV ")
166+
print "<BR>";
167+
}
168+
}' |
169+
170+
# add HTML wrapper
171+
if [ "$HTML" = "Y" ]
172+
then echo "<HTML>"
173+
echo "<HEAD>"
174+
echo "<TITLE>CVS</TITLE>"
175+
echo "</HEAD>"
176+
echo "<BODY>"
177+
cat
178+
echo "</BODY>"
179+
echo "</HTML>"
180+
else cat
181+
fi

0 commit comments

Comments
 (0)