#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# ident "%Z%%M% %I% %E% SMI"
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# Make a dynamic HTML page for the unified diffs between two (C) files.
#
$diffword = "wdiff";
$context = 10;
getopt('t:c:');
if ($#ARGV + 1 == 1) {
open DIFF, "<&STDIN";
} elsif ($#ARGV + 1 == 2) {
open DIFF, "diff -D $diffword $ARGV[0] $ARGV[1] | expand |";
} else {
print "Usage: $0 [-t title] [-c comment] file1 file2\n";
exit 2;
}
$comment = "";
if (defined $opt_c) {
}
$indiff = 0;
$line1 = 0;
$line2 = 0;
@pretext = (); # Speculative pretext buffer (code)
$elided_lines = 0;
print <<END;
<head>
</style>
</style>
if (dir == 'up') {
}
}
function handle_click(e) {
- e.clientY);
}
if (q != -1)
return (str);
}
function split() {
document.write('<frameset rows="50%,*">' +
'</frameset>');
document.close();
}
function closeframe() {
}
</script>
</head>
<tr>
</tr>
</table>
</script>
END
print "<pre><span class='subtracted'> --- $ARGV[0]
</span>";
sub begin_elided {
++$nelided;
# onclick handler assigned at bottom
print "<pre id='elided$nelided' class='elided' style='display: none'>";
$inelided = 1;
$elided_lines = 0;
}
sub end_elided {
print "</pre>\n";
print <<END;
<tr>
onclick='show_n_hide_dir("elided$nelided", "hb-elided$nelided", "down")'>
onclick='show_n_hide_dir("elided$nelided", "hb-elided$nelided", "up")'>
</tr>
</table>
END
$inelided = 0;
}
while (<DIFF>) {
chomp;
# Change detection
$previndiff = $indiff;
if (!$indiff) {
if (/^#ifdef $diffword$/) {
$indiff = 1;
} elsif (/^#ifndef $diffword$/) {
$indiff = -1;
}
} else {
if (/^#else \/\* $diffword \*\/$/) {
print "</span>";
printf "<span class='%s'>",
next;
} elsif (/^#endif \/\* (! )?$diffword \*\/$/) {
$indiff = 0;
print "</span>";
next;
}
}
if (!$previndiff && $indiff) {
# Beginning of a change: If we have an elided section open,
# end it. Print the pretext and continue.
if ($inelided) {
print "<pre>";
}
print @pretext;
@pretext = ();
$endfunc = 0;
printf "<span class='%s'>",
next;
}
# Line of code
# Quote for HTML
s/&/&/g;
s/</</g;
s/>/>/g;
# Format the line according to $indiff, and print it or put it into
# a buffer.
if ($indiff == -1) {
++$line1;
} elsif ($indiff == 0) {
++$line1;
++$line2;
if ($posttext > 0) {
print $str;
--$posttext;
} else {
if ($#pretext + 1 > $context) {
if (!$inelided) {
print "</pre>\n";
}
++$elided_lines;
print $str;
}
}
} elsif ($indiff == 1) {
++$line2;
}
}
print @pretext;
if ($inelided) {
$elided_lines += @pretext;
} else {
print " </pre>\n";
}
print "<pre id='linerefpre'><span id='lineref'>", 'X' x (4 + 1 + 4 + 2 + 80),
"</span></pre>\n";
print <<END;
<br />
e.onclick = handle_click;
}
'none', '');
if (s > 0)
function open_or_close_all(open) {
}
}
</script>
</body>
</html>
END