rfcdiff-v1.43   rfcdiff 
skipping to change at line 105 skipping to change at line 105
# generating the diff, to produce a cleaner diff. # generating the diff, to produce a cleaner diff.
# #
# It is called as # It is called as
# #
# rfcdiff first-file second-file # rfcdiff first-file second-file
# #
# The latest version is available from # The latest version is available from
# http://tools.ietf.org/tools/rfcdiff/ # http://tools.ietf.org/tools/rfcdiff/
# #
export version="1.43" export version="1.44"
export progdate="" export progdate=""
export prelines="10" export prelines="10"
export basename=$(basename $0) export basename=$(basename $0)
export workdir="/tmp/$basename-$$" export workdir="/tmp/$basename-$$"
export pagecache1="$workdir/pagecache1" export pagecache1="$workdir/pagecache1"
export pagecache2="$workdir/pagecache2" export pagecache2="$workdir/pagecache2"
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Utility to find an executable # Utility to find an executable
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
skipping to change at line 133 skipping to change at line 133
fi fi
fi fi
done done
} }
AWK=$(lookfor gawk nawk awk) AWK=$(lookfor gawk nawk awk)
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Strip headers footers and formfeeds from infile to stdout # Strip headers footers and formfeeds from infile to stdout
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
stripbom() {
$AWK '
NR==1 { sub(/^\xef\xbb\xbf/,""); }
{ print ; }
' "$1"
}
# ----------------------------------------------------------------------
# Strip headers footers and formfeeds from infile to stdout
# ----------------------------------------------------------------------
strip() { strip() {
$AWK ' $AWK '
{ gsub(/\r/, ""); } { gsub(/\r/, ""); }
{ gsub(/[ \t]+$/, ""); } { gsub(/[ \t]+$/, ""); }
{ pagelength++; } { pagelength++; }
/\[?[Pp]age [0-9ivx]+\]?[ \t\f]*$/ { /\[?[Pp]age [0-9ivx]+\]?[ \t\f]*$/ {
match($0, /[Pp]age [0-9ivx]+/); match($0, /[Pp]age [0-9ivx]+/);
num = substr($0, RSTART+5, RLENGTH-5); num = substr($0, RSTART+5, RLENGTH-5);
print num, outline > ENVIRON["pagecache" ENVIRO N["which"]] print num, outline > ENVIRON["pagecache" ENVIRO N["which"]]
pagelength = 0; pagelength = 0;
skipping to change at line 307 skipping to change at line 317
if (file2 ~ /^draft-/) { nxt = sprintf("<a href=\"/rfcdiff?url1=%s\" style= \"color:#008; text-decoration:none;\">&gt;</a>", file2) } if (file2 ~ /^draft-/) { nxt = sprintf("<a href=\"/rfcdiff?url1=%s\" style= \"color:#008; text-decoration:none;\">&gt;</a>", file2) }
} }
printf "" \ printf "" \
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3. org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> \n" \ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3. org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> \n" \
"<!-- Generated by rfcdiff %s: rfcdiff %s --> \n" \ "<!-- Generated by rfcdiff %s: rfcdiff %s --> \n" \
"<!-- <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional\" > -->\n" \ "<!-- <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional\" > -->\n" \
"<!-- System: %s --> \n" \ "<!-- System: %s --> \n" \
"<!-- Using awk: %s: %s --> \n" \ "<!-- Using awk: %s: %s --> \n" \
"<!-- Using diff: %s: %s --> \n" \ "<!-- Using diff: %s: %s --> \n" \
"<!-- Using wdiff: %s: %s --> \n" \ "<!-- Using wdiff: %s: %s --> \n" \
"<html> \n" \ "<html xmlns=\"http://www.w3.org/1999/xhtml\"> \n" \
"<head> \n" \ "<head> \n" \
" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /> \n" \ " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /> \n" \
" <meta http-equiv=\"Content-Style-Type\" content=\"text/css\" /> \n" \ " <meta http-equiv=\"Content-Style-Type\" content=\"text/css\" /> \n" \
" <title>Diff: %s - %s</title> \n" \ " <title>Diff: %s - %s</title> \n" \
" <style type=\"text/css\"> \n" \ " <style type=\"text/css\"> \n" \
" body { margin: 0.4ex; margin-right: auto; } \n" \ " body { margin: 0.4ex; margin-right: auto; } \n" \
" tr { } \n" \ " tr { } \n" \
" td { white-space: pre; font-family: monospace; vertical-align: top; font -size: 0.86em;} \n" \ " td { white-space: pre; font-family: monospace; vertical-align: top; font -size: 0.86em;} \n" \
" th { font-size: 0.86em; } \n" \ " th { font-size: 0.86em; } \n" \
" .small { font-size: 0.6em; font-style: italic; font-family: Verdana, Helveti ca, sans-serif; } \n" \ " .small { font-size: 0.6em; font-style: italic; font-family: Verdana, Helveti ca, sans-serif; } \n" \
skipping to change at line 337 skipping to change at line 347
" .linebr { background-color: #AAA; } \n" \ " .linebr { background-color: #AAA; } \n" \
" .lineno { color: red; background-color: #FFF; font-size: 0.7em; text-align: r ight; padding: 0 2px; } \n" \ " .lineno { color: red; background-color: #FFF; font-size: 0.7em; text-align: r ight; padding: 0 2px; } \n" \
" .elipsis{ background-color: #AAA; } \n" \ " .elipsis{ background-color: #AAA; } \n" \
" .left .cont { background-color: #DDD; } \n" \ " .left .cont { background-color: #DDD; } \n" \
" .right .cont { background-color: #EEE; } \n" \ " .right .cont { background-color: #EEE; } \n" \
" .lblock .cont { background-color: #9D9; } \n" \ " .lblock .cont { background-color: #9D9; } \n" \
" .rblock .cont { background-color: #DD6; } \n" \ " .rblock .cont { background-color: #DD6; } \n" \
" .insert .cont { background-color: #0DD; } \n" \ " .insert .cont { background-color: #0DD; } \n" \
" .delete .cont { background-color: #8AD; } \n" \ " .delete .cont { background-color: #8AD; } \n" \
" .stats, .stats td, .stats th { background-color: #EEE; padding: 2px 0; } \n" \ " .stats, .stats td, .stats th { background-color: #EEE; padding: 2px 0; } \n" \
" span.hide { display: none; color: #aaa;}" \
" a:hover span { display: inline; }" \
" tr.change { background-color: gray; } \n" \
" tr.change a { text-decoration: none; color: black } \n" \
" </style> \n" \ " </style> \n" \
"</head> \n" \ "</head> \n" \
"<body > \n" \ "<body > \n" \
" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> \n" \ " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> \n" \
" <tr bgcolor=\"orange\"><th></th><th>%s&nbsp;%s&nbsp;</th><th> </th><th>&nbsp;%s &nbsp;%s</th><th></th></tr> \n" \ " <tr id=\"part-1\" bgcolor=\"orange\"><th></th><th>%s&nbsp;%s&nbsp;</th><th> </t h><th>&nbsp;%s&nbsp;%s</th><th></th></tr> \n" \
"", ENVIRON["version"], ENVIRON["cmdline"], ENVIRON["uname"], ENVIRON["awkbin"], E NVIRON["awkver"], ENVIRON["diffbin"], ENVIRON["diffver"], ENVIRON["wdiffbin"], ENV IRON["wdiffver"], file1, file2, prev, url1, url2, nxt; "", ENVIRON["version"], ENVIRON["cmdline"], ENVIRON["uname"], ENVIRON["awkbin"], E NVIRON["awkver"], ENVIRON["diffbin"], ENVIRON["diffver"], ENVIRON["wdiffbin"], ENV IRON["wdiffver"], file1, file2, prev, url1, url2, nxt;
} }
function worddiff(w1, w2) { function worddiff(w1, w2) {
prefixlen = 0; prefixlen = 0;
word1 = w1; word1 = w1;
do { do {
if (substr(w1,1,1) == substr(w2,1,1)) { if (substr(w1,1,1) == substr(w2,1,1)) {
w1 = substr(w1,2); w1 = substr(w1,2);
w2 = substr(w2,2); w2 = substr(w2,2);
skipping to change at line 442 skipping to change at line 456
close(cmd1); close(cmd1);
close(cmd2); close(cmd2);
} }
function flush() { function flush() {
if (difflines1 || difflines2) { if (difflines1 || difflines2) {
difftag++; difftag++;
multiline = (difflines1 > 1) || (difflines2 > 1); multiline = (difflines1 > 1) || (difflines2 > 1);
if (multiline && (wdiff != "")) chunkdiff(difftag); if (multiline && (wdiff != "")) chunkdiff(difftag);
printf " <tr><td><a name=\"diff%04d\" /></td></tr>\n", difftag; printf " <tr id=\"diff%04d\"><td></td></tr>\n", difftag;
for (l = 0; l < difflines1 || l < difflines2; l++) { for (l = 0; l < difflines1 || l < difflines2; l++) {
if (l in stack1) { if (l in stack1) {
line1 = stack1[l]; line1 = stack1[l];
delete stack1[l]; delete stack1[l];
linenum1++ linenum1++
if (line1 == "") if (line1 == "")
if (optwidth > 0) { if (optwidth > 0) {
line1 = substr(" ",0,optwidth); line1 = substr(" ",0,optwidth);
} else { } else {
line1 = " "; line1 = " ";
skipping to change at line 479 skipping to change at line 493
} }
if (!multiline || (wdiff == "")) { if (!multiline || (wdiff == "")) {
worddiff(line1, line2); worddiff(line1, line2);
line1 = fixesc(sprintf("%s<span class=\"delete\">%s</span>%s", wordpart [0], wordpart[1], wordpart[3])); line1 = fixesc(sprintf("%s<span class=\"delete\">%s</span>%s", wordpart [0], wordpart[1], wordpart[3]));
line2 = fixesc(sprintf("%s<span class=\"insert\">%s</span>%s", wordpart [0], wordpart[2], wordpart[3])); line2 = fixesc(sprintf("%s<span class=\"insert\">%s</span>%s", wordpart [0], wordpart[2], wordpart[3]));
# Clean up; remove empty spans # Clean up; remove empty spans
sub(/<span class="delete"><\/span>/,"", line1); sub(/<span class="delete"><\/span>/,"", line1);
sub(/<span class="insert"><\/span>/,"", line2); sub(/<span class="insert"><\/span>/,"", line2);
} }
left = sprintf("<td class=\"lineno\" valign=\"top\">%s</td><td class=\"lb left = sprintf("<td class=\"lineno\">%s</td><td class=\"lblock\">%s</td>"
lock\">%s</td>", numdisplay(1, linenum1), line1); , numdisplay(1, linenum1), line1);
right = sprintf("<td class=\"rblock\">%s</td><td class=\"lineno\" valign=\ right = sprintf("<td class=\"rblock\">%s</td><td class=\"lineno\">%s</td>"
"top\">%s</td>", line2, numdisplay(2, linenum2)); , line2, numdisplay(2, linenum2));
printf " <tr>%s<td> </td>%s</tr>\n", left, right; printf " <tr>%s<td> </td>%s</tr>\n", left, right;
} }
} }
} }
function getpage(which, line) { function getpage(which, line) {
line = line + ENVIRON["prelines"]; line = line + ENVIRON["prelines"];
page = "?"; page = "?";
for (p=1; p <= maxpage[which]; p++) { for (p=1; p <= maxpage[which]; p++) {
if (pageend[which,p] == 0) continue; if (pageend[which,p] == 0) continue;
skipping to change at line 548 skipping to change at line 562
} }
/^@@/ { /^@@/ {
linenum1 = 0 - $2; linenum1 = 0 - $2;
linenum2 = 0 + $4; linenum2 = 0 + $4;
diffnum ++; diffnum ++;
if (linenum1 > 1) { if (linenum1 > 1) {
printf " <tr><td class=\"lineno\"></td><td class=\"left\"></td>< td> </td><td class=\"right\"></td><td class=\"lineno\"></td></tr>\n"; printf " <tr><td class=\"lineno\"></td><td class=\"left\"></td>< td> </td><td class=\"right\"></td><td class=\"lineno\"></td></tr>\n";
page1 = getpage(1,linenum1); page1 = getpage(1,linenum1);
page2 = getpage(2,linenum2); page2 = getpage(2,linenum2);
difflabel = sprintf("part-%s", diffnum);
if (page1 == "?") { if (page1 == "?") {
posinfo1 = sprintf("<a name=\"part-l%s\" /><small>skipping to chan ge at</small><em> line %s</em>", diffnum, getpageline(1, linenum1, page1)); posinfo1 = sprintf("<small>skipping to change at</small><a href=\" #%s\"><em> line %s<span class=\"hide\"> &para;</span></em></a>", difflabel, getpag eline(1, linenum1, page1));
} else { } else {
posinfo1 = sprintf("<a name=\"part-l%s\" /><small>skipping to chan ge at</small><em> page %s, line %s</em>", diffnum, page1, getpageline(1, linenum1, page1)); posinfo1 = sprintf("<small>skipping to change at</small><a href=\" #%s\"><em> page %s, line %s<span class=\"hide\"> &para;</span></em></a>", difflabe l, page1, getpageline(1, linenum1, page1));
} }
if (page2 == "?") { if (page2 == "?") {
posinfo2 = sprintf("<a name=\"part-r%s\" /><small>skipping to chan ge at</small><em> line %s</em>", diffnum, getpageline(2, linenum2, page2)); posinfo2 = sprintf("<small>skipping to change at</small><a href=\" #%s\"><em> line %s<span class=\"hide\"> &para;</span></em></a>", difflabel, getpag eline(2, linenum2, page2));
} else { } else {
posinfo2 = sprintf("<a name=\"part-r%s\" /><small>skipping to chan ge at</small><em> page %s, line %s</em>", diffnum, page2, getpageline(2, linenum2, page2)); posinfo2 = sprintf("<small>skipping to change at</small><a href=\" #%s\"><em> page %s, line %s<span class=\"hide\"> &para;</span></em></a>", difflabe l, page2, getpageline(2, linenum2, page2));
} }
printf " <tr bgcolor=\"gray\" ><td></td><th>%s</th><th> </th><th >%s</th><td></td></tr>\n", posinfo1, posinfo2; printf " <tr id=\"%s\" class=\"change\" ><td></td><th>%s</th><th > </th><th>%s</th><td></td></tr>\n", difflabel, posinfo1, posinfo2;
} }
} }
/^---/ { next; } /^---/ { next; }
/^[+][+][+]/ { next; } /^[+][+][+]/ { next; }
/^[ ]/ { /^[ ]/ {
line = substr($0, 2); line = substr($0, 2);
line = maybebreakline(line); line = maybebreakline(line);
flush(); flush();
linenum1++; linenum1++;
linenum2++; linenum2++;
printf " <tr><td class=\"lineno\" valign=\"top\">%s</td><td class=\ printf " <tr><td class=\"lineno\">%s</td><td class=\"left\">%s</td>
"left\">%s</td><td> </td>", numdisplay(1, linenum1), line; <td> </td>", numdisplay(1, linenum1), line;
printf "<td class=\"right\">%s</td><td class=\"lineno\" valign=\"top\">% printf "<td class=\"right\">%s</td><td class=\"lineno\">%s</td></tr>\n",
s</td></tr>\n", line, numdisplay(2, linenum2); line, numdisplay(2, linenum2);
diffcount1 += difflines1 diffcount1 += difflines1
difflines1 = 0 difflines1 = 0
diffcount2 += difflines2 diffcount2 += difflines2
difflines2 = 0 difflines2 = 0
} }
/^-/ { /^-/ {
line = substr($0, 2); line = substr($0, 2);
line = maybebreakline(line); line = maybebreakline(line);
stack1[difflines1] = line; stack1[difflines1] = line;
skipping to change at line 599 skipping to change at line 615
line = maybebreakline(line); line = maybebreakline(line);
stack2[difflines2] = line; stack2[difflines2] = line;
difflines2++; difflines2++;
} }
END { END {
flush(); flush();
printf("\n" \ printf("\n" \
" <tr><td></td><td class=\"left\"></td><td> </td><td class=\"right\"></td><td> </td></tr>\n" \ " <tr><td></td><td class=\"left\"></td><td> </td><td class=\"right\"></td><td> </td></tr>\n" \
" <tr bgcolor=\"gray\"><th colspan=\"5\" align=\"center\"><a name=\"end\">&nbs p;%s. %s change blocks.&nbsp;</a>;</th></tr>\n" \ " <tr id=\"end\" bgcolor=\"gray\"><th colspan=\"5\" align=\"center\">&nbsp;%s. %s change blocks.&nbsp;</th></tr>\n" \
" <tr class=\"stats\"><td></td><th><i>%s lines changed or deleted</i></th><th> <i> </i></th><th><i>%s lines changed or added</i></th><td></td></tr>\n" \ " <tr class=\"stats\"><td></td><th><i>%s lines changed or deleted</i></th><th> <i> </i></th><th><i>%s lines changed or added</i></th><td></td></tr>\n" \
" <tr><td colspan=\"5\" align=\"center\" class=\"small\"><br/>This html diff w as produced by rfcdiff %s. The latest version is available from <a href=\"http://w ww.tools.ietf.org/tools/rfcdiff/\" >http://tools.ietf.org/tools/rfcdiff/</a> </td> </tr>\n" \ " <tr><td colspan=\"5\" align=\"center\" class=\"small\"><br/>This html diff w as produced by rfcdiff %s. The latest version is available from <a href=\"http://w ww.tools.ietf.org/tools/rfcdiff/\" >http://tools.ietf.org/tools/rfcdiff/</a> </td> </tr>\n" \
" </table>\n" \ " </table>\n" \
" </body>\n" \ " </body>\n" \
" </html>\n", diffnum?"End of changes":"No changes", difftag, diffcount1, diffco unt2, ENVIRON["version"]); " </html>\n", diffnum?"End of changes":"No changes", difftag, diffcount1, diffco unt2, ENVIRON["version"]);
} }
' "$1" ' "$1"
} }
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
skipping to change at line 876 skipping to change at line 892
cp "$1" $workdir/1/"$base1" cp "$1" $workdir/1/"$base1"
fi fi
if [ $dowgetarg2 -gt 0 ]; then if [ $dowgetarg2 -gt 0 ]; then
$wgetbin -nv "$2" -O $workdir/2/"$base2" $wgetbin -nv "$2" -O $workdir/2/"$base2"
else else
cp "$2" $workdir/2/"$base2" cp "$2" $workdir/2/"$base2"
fi fi
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Remove UTF-8 BOMs
# ----------------------------------------------------------------------
stripbom $workdir/1/"$base1" > $workdir/1/"$base1".nobom
mv -f $workdir/1/"$base1".nobom $workdir/1/"$base1"
stripbom $workdir/2/"$base2" > $workdir/2/"$base2".nobom
mv -f $workdir/2/"$base2".nobom $workdir/2/"$base2"
# ----------------------------------------------------------------------
# Maybe strip headers/footers from both files # Maybe strip headers/footers from both files
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if [ $optstrip -gt 0 ]; then if [ $optstrip -gt 0 ]; then
export which=1 export which=1
strip $workdir/1/"$base1" > $workdir/1/"$base1".stripped strip $workdir/1/"$base1" > $workdir/1/"$base1".stripped
mv -f $workdir/1/"$base1".stripped $workdir/1/"$base1" mv -f $workdir/1/"$base1".stripped $workdir/1/"$base1"
export which=2 export which=2
strip $workdir/2/"$base2" > $workdir/2/"$base2".stripped strip $workdir/2/"$base2" > $workdir/2/"$base2".stripped
mv -f $workdir/2/"$base2".stripped $workdir/2/"$base2" mv -f $workdir/2/"$base2".stripped $workdir/2/"$base2"
 End of changes. 16 change blocks. 
18 lines changed or deleted 43 lines changed or added

This html diff was produced by rfcdiff 1.44. The latest version is available from http://tools.ietf.org/tools/rfcdiff/