72 }
73 div.summary table th {
74 text-align: right;
75 vertical-align: top;
76 white-space: nowrap;
77 }
78 span.lineschanged {
79 font-size: 0.7em;
80 }
81 span.oldmarker {
82 color: red;
83 font-size: large;
84 font-weight: bold;
85 }
86 span.newmarker {
87 color: green;
88 font-size: large;
89 font-weight: bold;
90 }
91 span.removed {
92 color: brown;
93 }
94 span.changed {
95 color: blue;
96 }
97 span.new {
98 color: blue;
99 font-weight: bold;
100 }
101 a.print { font-size: x-small; }
102
103 </style>
104
105 <style type="text/css" media="print">
106 pre { font-size: 0.8em; font-family: courier, monospace; }
107 span.removed { color: #444; font-style: italic }
108 span.changed { font-weight: bold; }
109 span.new { font-weight: bold; }
110 span.newmarker { font-size: 1.2em; font-weight: bold; }
111 span.oldmarker { font-size: 1.2em; font-weight: bold; }
112 a.print {display: none}
160 sac2url()
161 {
162 if [[ -z $Oflag ]]; then
163 sed -e 's|\([A-Z]\{1,2\}ARC\)[ /]\([0-9]\{4\}\)/\([0-9]\{3\}\)|<a href=\"'$SACURL'\1/\2/\3\">\1 \2/\3</a>|g'
164 else
165 sed -e 's|\([A-Z]\{1,2\}ARC\)[ /]\([0-9]\{4\}\)/\([0-9]\{3\}\)|<a href=\"'$SACURL'/\2/\3\">\1 \2/\3</a>|g'
166 fi
167 }
168
169 #
170 # strip_unchanged <infile> | output_cmd
171 #
172 # Removes chunks of sdiff documents that have not changed. This makes it
173 # easier for a code reviewer to find the bits that have changed.
174 #
175 # Deleted lines of text are replaced by a horizontal rule. Some
176 # identical lines are retained before and after the changed lines to
177 # provide some context. The number of these lines is controlled by the
178 # variable C in the $AWK script below.
179 #
180 # The script detects changed lines as any line that has a "<span class="
181 # string embedded (unchanged lines have no particular class and are not
182 # part of a <span>). Blank lines (without a sequence number) are also
183 # detected since they flag lines that have been inserted or deleted.
184 #
185 strip_unchanged()
186 {
187 $AWK '
188 BEGIN { C = c = 20 }
189 NF == 0 || /span class=/ {
190 if (c > C) {
191 c -= C
192 inx = 0
193 if (c > C) {
194 print "\n</pre><hr></hr><pre>"
195 inx = c % C
196 c = C
197 }
198
199 for (i = 0; i < c; i++)
200 print ln[(inx + i) % C]
201 }
202 c = 0;
203 print
204 next
205 }
206 { if (c >= C) {
207 ln[c % C] = $0
208 c++;
209 next;
275 #
276 # Blank lines are inserted in each file to keep unchanged lines in sync
277 # (side-by-side). This format is familiar to users of sdiff(1) or
278 # Teamware's filemerge tool.
279 #
280 sdiff_to_html()
281 {
282 diff -b $1 $2 > /tmp/$$.diffs
283
284 TNAME=$3
285 TPATH=$4
286 COMMENT=$5
287
288 #
289 # Now we have the diffs, generate the HTML for the old file.
290 #
291 $AWK '
292 BEGIN {
293 printf "function sp(n) {for (i=0;i<n;i++)printf \"\\n\"}\n"
294 printf "function removed() "
295 printf "{printf \"<span class=\\\"removed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
296 printf "function changed() "
297 printf "{printf \"<span class=\\\"changed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
298 printf "function bl() {printf \"%%4d %%s\\n\", NR, $0}\n"
299 }
300 /^</ {next}
301 /^>/ {next}
302 /^---/ {next}
303
304 {
305 split($1, a, /[cad]/) ;
306 if (index($1, "a")) {
307 if (a[1] == 0) {
308 n = split(a[2], r, /,/);
309 if (n == 1)
310 printf "BEGIN\t\t{sp(1)}\n"
311 else
312 printf "BEGIN\t\t{sp(%d)}\n",\
313 (r[2] - r[1]) + 1
314 next
315 }
316
317 printf "NR==%s\t\t{", a[1]
357 if (n > 1) printf "if (NR==%d)", final
358 printf "sp(%d);", d2 - d1
359 }
360 }
361 printf "next}\n" ;
362
363 next
364 }
365 }
366
367 END { printf "{printf \"%%4d %%s\\n\", NR, $0 }\n" }
368 ' /tmp/$$.diffs > /tmp/$$.file1
369
370 #
371 # Now generate the HTML for the new file
372 #
373 $AWK '
374 BEGIN {
375 printf "function sp(n) {for (i=0;i<n;i++)printf \"\\n\"}\n"
376 printf "function new() "
377 printf "{printf \"<span class=\\\"new\\\">%%4d %%s</span>\\n\", NR, $0}\n"
378 printf "function changed() "
379 printf "{printf \"<span class=\\\"changed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
380 printf "function bl() {printf \"%%4d %%s\\n\", NR, $0}\n"
381 }
382
383 /^</ {next}
384 /^>/ {next}
385 /^---/ {next}
386
387 {
388 split($1, a, /[cad]/) ;
389 if (index($1, "d")) {
390 if (a[2] == 0) {
391 n = split(a[1], r, /,/);
392 if (n == 1)
393 printf "BEGIN\t\t{sp(1)}\n"
394 else
395 printf "BEGIN\t\t{sp(%d)}\n",\
396 (r[2] - r[1]) + 1
397 next
398 }
399
492 #
493 # $WDIR/DIR/$TNAME.lhs.html
494 # $WDIR/DIR/$TNAME.rhs.html
495 # $WDIR/DIR/$TNAME.frames.html
496 #
497 # NOTE: We rely on standard usage of $WDIR and $DIR.
498 #
499 function framed_sdiff
500 {
501 typeset TNAME=$1
502 typeset TPATH=$2
503 typeset lhsfile=$3
504 typeset rhsfile=$4
505 typeset comments=$5
506 typeset RTOP
507
508 # Enable html files to access WDIR via a relative path.
509 RTOP=$(relative_dir $TPATH $WDIR)
510
511 # Make the rhs/lhs files and output the frameset file.
512 print "$HTML<head>$STDHEAD" > $WDIR/$DIR/$TNAME.lhs.html
513
514 cat >> $WDIR/$DIR/$TNAME.lhs.html <<-EOF
515 <script type="text/javascript" src="$RTOP/ancnav.js"></script>
516 </head>
517 <body id="SUNWwebrev" onkeypress="keypress(event);">
518 <a name="0"></a>
519 <pre>$comments</pre><hr></hr>
520 EOF
521
522 cp $WDIR/$DIR/$TNAME.lhs.html $WDIR/$DIR/$TNAME.rhs.html
523
524 insert_anchors $lhsfile >> $WDIR/$DIR/$TNAME.lhs.html
525 insert_anchors $rhsfile >> $WDIR/$DIR/$TNAME.rhs.html
526
527 close='</body></html>'
528
529 print $close >> $WDIR/$DIR/$TNAME.lhs.html
530 print $close >> $WDIR/$DIR/$TNAME.rhs.html
531
532 print "$FRAMEHTML<head>$STDHEAD" > $WDIR/$DIR/$TNAME.frames.html
626 # The script detects changed lines as any line that has a "<span
627 # class=" string embedded (unchanged lines have no class set and are
628 # not part of a <span>. Blank lines (without a sequence number)
629 # are also detected since they flag lines that have been inserted or
630 # deleted.
631 #
632 function insert_anchors
633 {
634 $AWK '
635 function ia() {
636 # This should be able to be a singleton <a /> but that
637 # seems to trigger a bug in firefox a:hover rule processing
638 printf "<a name=\"%d\" id=\"anc%d\"></a>", anc, anc++;
639 }
640
641 BEGIN {
642 anc=1;
643 inblock=1;
644 printf "<pre>\n";
645 }
646 NF == 0 || /^<span class=/ {
647 if (inblock == 0) {
648 ia();
649 inblock=1;
650 }
651 print;
652 next;
653 }
654 {
655 inblock=0;
656 print;
657 }
658 END {
659 ia();
660
661 printf "<b style=\"font-size: large; color: red\">";
662 printf "--- EOF ---</b>"
663 for(i=0;i<8;i++) printf "\n\n\n\n\n\n\n\n\n\n";
664 printf "</pre>"
665 printf "<form name=\"eof\">";
666 printf "<input name=\"value\" value=\"%d\" type=\"hidden\" />",
667 anc - 1;
668 printf "</form>";
669 }
670 ' $1
671 }
672
673
674 #
675 # relative_dir
676 #
677 # Print a relative return path from $1 to $2. For example if
678 # $1=/tmp/myreview/raw_files/usr/src/tools/scripts and $2=/tmp/myreview,
679 # this function would print "../../../../".
680 #
681 # In the event that $1 is not in $2 a warning is printed to stderr,
682 # and $2 is returned-- the result of this is that the resulting webrev
683 # is not relocatable.
684 #
685 function relative_dir
909 cat << \EOF
910 </head>
911 <body id="SUNWwebrev" bgcolor="#eeeeee" onload="document.diff.real.focus();"
912 onkeypress="keypress(event);">
913 <noscript lang="javascript">
914 <center>
915 <p><big>Framed Navigation controls require Javascript</big><br />
916 Either this browser is incompatable or javascript is not enabled</p>
917 </center>
918 </noscript>
919 <table width="100%" border="0" align="center">
920 <tr>
921 <td valign="middle" width="25%">Diff navigation:
922 Use 'j' and 'k' for next and previous diffs; or use buttons
923 at right</td>
924 <td align="center" valign="top" width="50%">
925 <div class="button">
926 <table border="0" align="center">
927 <tr>
928 <td>
929 <a onMouseDown="handlePress(1);return true;"
930 onMouseUp="handleRelease(1);return true;"
931 onMouseOut="handleRelease(1);return true;"
932 onClick="return false;"
933 title="Go to Beginning Of file">BOF</a></td>
934 <td>
935 <a onMouseDown="handlePress(3);return true;"
936 onMouseUp="handleRelease(3);return true;"
937 onMouseOut="handleRelease(3);return true;"
938 title="Scroll Up: Press and Hold to accelerate"
939 onClick="return false;">Scroll Up</a></td>
940 <td>
941 <a onMouseDown="handlePress(2);return true;"
942 onMouseUp="handleRelease(2);return true;"
943 onMouseOut="handleRelease(2);return true;"
944 title="Go to previous Diff"
945 onClick="return false;">Prev Diff</a>
946 </td></tr>
947
948 <tr>
949 <td>
950 <a onMouseDown="handlePress(6);return true;"
951 onMouseUp="handleRelease(6);return true;"
952 onMouseOut="handleRelease(6);return true;"
953 onClick="return false;"
954 title="Go to End Of File">EOF</a></td>
955 <td>
956 <a onMouseDown="handlePress(4);return true;"
957 onMouseUp="handleRelease(4);return true;"
958 onMouseOut="handleRelease(4);return true;"
959 title="Scroll Down: Press and Hold to accelerate"
960 onClick="return false;">Scroll Down</a></td>
961 <td>
962 <a onMouseDown="handlePress(5);return true;"
963 onMouseUp="handleRelease(5);return true;"
964 onMouseOut="handleRelease(5);return true;"
965 title="Go to next Diff"
966 onClick="return false;">Next Diff</a></td>
967 </tr>
968 </table>
969 </div>
970 </td>
971 <th valign="middle" width="25%">
972 <form action="" name="diff" onsubmit="return ValidateDiffNum();">
973 <input name="display" value="BOF" size="8" type="text" />
974 <input name="real" value="0" size="8" type="hidden" />
975 </form>
976 </th>
977 </tr>
978 </table>
979 </body>
980 </html>
981 EOF
982 }
983
984
985
986 #
1003 print "$UDIFFCSS"
1004 fi
1005
1006 cat <<-EOF
1007 </head>
1008 <body id="SUNWwebrev">
1009 <h2>$TPATH</h2>
1010 <a class="print" href="javascript:print()">Print this page</a>
1011 <pre>$COMMENT</pre>
1012 <pre>
1013 EOF
1014
1015 html_quote | $AWK '
1016 /^--- new/ { next }
1017 /^\+\+\+ new/ { next }
1018 /^--- old/ { next }
1019 /^\*\*\* old/ { next }
1020 /^\*\*\*\*/ { next }
1021 /^-------/ { printf "<center><h1>%s</h1></center>\n", $0; next }
1022 /^\@\@.*\@\@$/ { printf "</pre><hr /><pre>\n";
1023 printf "<span class=\"newmarker\">%s</span>\n", $0;
1024 next}
1025
1026 /^\*\*\*/ { printf "<hr /><span class=\"oldmarker\">%s</span>\n", $0;
1027 next}
1028 /^---/ { printf "<span class=\"newmarker\">%s</span>\n", $0;
1029 next}
1030 /^\+/ {printf "<span class=\"new\">%s</span>\n", $0; next}
1031 /^!/ {printf "<span class=\"changed\">%s</span>\n", $0; next}
1032 /^-/ {printf "<span class=\"removed\">%s</span>\n", $0; next}
1033 {printf "%s\n", $0; next}
1034 '
1035
1036 print "</pre></body></html>\n"
1037 }
1038
1039
1040 #
1041 # source_to_html { new | old } <filename>
1042 #
1043 # Process a plain vanilla source file to transform it into an HTML file.
1044 #
1045 source_to_html()
1046 {
1047 WHICH=$1
1048 TNAME=$2
1049
1050 print "$HTML<head>$STDHEAD"
1051 print "<title>$WHICH $TNAME</title>"
1052 print "<body id=\"SUNWwebrev\">"
1053 print "<pre>"
1054 html_quote | $AWK '{line += 1 ; printf "%4d %s\n", line, $0 }'
1055 print "</pre></body></html>"
1056 }
1057
1058 #
1059 # teamwarecomments {text|html} parent-file child-file
1060 #
1061 # Find the first delta in the child that's not in the parent. Get the
1062 # newest delta from the parent, get all deltas from the child starting
1063 # with that delta, and then get all info starting with the second oldest
1064 # delta in that list (the first delta unique to the child).
1065 #
1066 # This code adapted from Bill Shannon's "spc" script
1067 #
1068 comments_from_teamware()
1069 {
1070 fmt=$1
1071 pfile=$PWS/$2
1072 cfile=$CWS/$3
1311
1312 # End of $AWK, Check to see if any trouble occurred.
1313 if (( $? > 0 || err > 0 )); then
1314 print "Unexpected Error occurred reading" \
1315 "\`diff -e $1 $2\`: \$?=$?, err=" $err
1316 return
1317 fi
1318
1319 # Accumulate totals
1320 (( TOTL += tot ))
1321 (( TMOD += mod ))
1322 (( TDEL += del ))
1323 (( TINS += ins ))
1324 # Calculate unchanged lines
1325 unc=`wc -l < $1`
1326 if (( unc > 0 )); then
1327 (( unc -= del + mod ))
1328 (( TUNC += unc ))
1329 fi
1330 # print summary
1331 print "<span class=\"lineschanged\">\c"
1332 printCI $tot $ins $del $mod $unc
1333 print "</span>"
1334 }
1335
1336
1337 #
1338 # flist_from_wx
1339 #
1340 # Sets up webrev to source its information from a wx-formatted file.
1341 # Sets the global 'wxfile' variable.
1342 #
1343 function flist_from_wx
1344 {
1345 typeset argfile=$1
1346 if [[ -n ${argfile%%/*} ]]; then
1347 #
1348 # If the wx file pathname is relative then make it absolute
1349 # because the webrev does a "cd" later on.
1350 #
1351 wxfile=$PWD/$argfile
3003 # <title>6641309: Wrong Cookie separator used in HttpURLConnection</title>
3004 #
3005 if [[ -n $CRID ]]; then
3006 for id in $CRID
3007 do
3008 print "<tr><th>Bug id:</th><td>"
3009 url="${BUGURL}${id}"
3010 if [[ -n $WGET ]]; then
3011 msg=`$WGET -q $url -O - | grep '<title>' | sed 's/<title>\(.*\)<\/title>/\1/' | sed 's/Bug ID://'`
3012 fi
3013 if [[ -n $msg ]]; then
3014 print "<a href=\"$url\">$msg</a>"
3015 else
3016 print $id | bug2url
3017 fi
3018
3019 print "</td></tr>"
3020 done
3021 fi
3022 print "<tr><th>Legend:</th><td>"
3023 print "<b>Modified file</b><br><font color=red><b>Deleted file</b></font><br><font color=green><b>New file</b></font></td></tr>"
3024 print "</table>"
3025 print "</div>"
3026
3027 #
3028 # Second pass through the files: generate the rest of the index file
3029 #
3030 while read LINE
3031 do
3032 set - $LINE
3033 if [[ $1 == "Revision:" ]]; then
3034 FIRST_CREV=`expr $3 + 1`
3035 continue
3036 fi
3037 P=$1
3038
3039 if [[ $# == 2 ]]; then
3040 PP=$2
3041 oldname=" <i>(was $PP)</i>"
3042
3043 else
3143 fi
3144
3145 # Add additional comments comment
3146
3147 print "<!-- Add comments to explain changes in $P here -->"
3148
3149 # Add count of changes.
3150
3151 if [[ -f $F.count ]]; then
3152 cat $F.count
3153 rm $F.count
3154 fi
3155 print "</blockquote>"
3156 done < $FLIST
3157
3158 print
3159 print
3160 print "<hr />"
3161 print "<p style=\"font-size: small\">"
3162 print "This code review page was prepared using <b>$0</b>"
3163 print "(vers $WEBREV_UPDATED)."
3164 print "</body>"
3165 print "</html>"
3166
3167 if [[ -n $ZIP ]]; then
3168 # Let's generate a zip file for convenience
3169 cd $WDIR/..
3170 if [ -f webrev.zip ]; then
3171 rm webrev.zip
3172 fi
3173 $ZIP -r webrev webrev >/dev/null 2>&1
3174 fi
3175
3176 exec 1<&- # Close FD 1.
3177 exec 1<&3 # dup FD 3 to restore stdout.
3178 exec 3<&- # close FD 3.
3179
3180 print "Done."
3181 print "Output to: $WDIR"
3182
|
72 }
73 div.summary table th {
74 text-align: right;
75 vertical-align: top;
76 white-space: nowrap;
77 }
78 span.lineschanged {
79 font-size: 0.7em;
80 }
81 span.oldmarker {
82 color: red;
83 font-size: large;
84 font-weight: bold;
85 }
86 span.newmarker {
87 color: green;
88 font-size: large;
89 font-weight: bold;
90 }
91 span.removed {
92 color: #A52A2A; /*brown*/
93 }
94 span.changed {
95 color: blue;
96 }
97 span.new {
98 color: blue;
99 font-weight: bold;
100 }
101 a.print { font-size: x-small; }
102
103 </style>
104
105 <style type="text/css" media="print">
106 pre { font-size: 0.8em; font-family: courier, monospace; }
107 span.removed { color: #444; font-style: italic }
108 span.changed { font-weight: bold; }
109 span.new { font-weight: bold; }
110 span.newmarker { font-size: 1.2em; font-weight: bold; }
111 span.oldmarker { font-size: 1.2em; font-weight: bold; }
112 a.print {display: none}
160 sac2url()
161 {
162 if [[ -z $Oflag ]]; then
163 sed -e 's|\([A-Z]\{1,2\}ARC\)[ /]\([0-9]\{4\}\)/\([0-9]\{3\}\)|<a href=\"'$SACURL'\1/\2/\3\">\1 \2/\3</a>|g'
164 else
165 sed -e 's|\([A-Z]\{1,2\}ARC\)[ /]\([0-9]\{4\}\)/\([0-9]\{3\}\)|<a href=\"'$SACURL'/\2/\3\">\1 \2/\3</a>|g'
166 fi
167 }
168
169 #
170 # strip_unchanged <infile> | output_cmd
171 #
172 # Removes chunks of sdiff documents that have not changed. This makes it
173 # easier for a code reviewer to find the bits that have changed.
174 #
175 # Deleted lines of text are replaced by a horizontal rule. Some
176 # identical lines are retained before and after the changed lines to
177 # provide some context. The number of these lines is controlled by the
178 # variable C in the $AWK script below.
179 #
180 # The script detects changed lines as any line that has a "<span class="
181 # string embedded (unchanged lines have no particular class and are not
182 # part of a <span>). Blank lines (without a sequence number) are also
183 # detected since they flag lines that have been inserted or deleted.
184 #
185 strip_unchanged()
186 {
187 $AWK '
188 BEGIN { C = c = 20 }
189 NF == 0 || /span class=/ {
190 if (c > C) {
191 c -= C
192 inx = 0
193 if (c > C) {
194 print "\n</pre><hr></hr><pre>"
195 inx = c % C
196 c = C
197 }
198
199 for (i = 0; i < c; i++)
200 print ln[(inx + i) % C]
201 }
202 c = 0;
203 print
204 next
205 }
206 { if (c >= C) {
207 ln[c % C] = $0
208 c++;
209 next;
275 #
276 # Blank lines are inserted in each file to keep unchanged lines in sync
277 # (side-by-side). This format is familiar to users of sdiff(1) or
278 # Teamware's filemerge tool.
279 #
280 sdiff_to_html()
281 {
282 diff -b $1 $2 > /tmp/$$.diffs
283
284 TNAME=$3
285 TPATH=$4
286 COMMENT=$5
287
288 #
289 # Now we have the diffs, generate the HTML for the old file.
290 #
291 $AWK '
292 BEGIN {
293 printf "function sp(n) {for (i=0;i<n;i++)printf \"\\n\"}\n"
294 printf "function removed() "
295 printf "{printf \"<span class=\\\"removed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
296 printf "function changed() "
297 printf "{printf \"<span class=\\\"changed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
298 printf "function bl() {printf \"%%4d %%s\\n\", NR, $0}\n"
299 }
300 /^</ {next}
301 /^>/ {next}
302 /^---/ {next}
303
304 {
305 split($1, a, /[cad]/) ;
306 if (index($1, "a")) {
307 if (a[1] == 0) {
308 n = split(a[2], r, /,/);
309 if (n == 1)
310 printf "BEGIN\t\t{sp(1)}\n"
311 else
312 printf "BEGIN\t\t{sp(%d)}\n",\
313 (r[2] - r[1]) + 1
314 next
315 }
316
317 printf "NR==%s\t\t{", a[1]
357 if (n > 1) printf "if (NR==%d)", final
358 printf "sp(%d);", d2 - d1
359 }
360 }
361 printf "next}\n" ;
362
363 next
364 }
365 }
366
367 END { printf "{printf \"%%4d %%s\\n\", NR, $0 }\n" }
368 ' /tmp/$$.diffs > /tmp/$$.file1
369
370 #
371 # Now generate the HTML for the new file
372 #
373 $AWK '
374 BEGIN {
375 printf "function sp(n) {for (i=0;i<n;i++)printf \"\\n\"}\n"
376 printf "function new() "
377 printf "{printf \"<span class=\\\"new\\\">%%4d %%s</span>\\n\", NR, $0}\n"
378 printf "function changed() "
379 printf "{printf \"<span class=\\\"changed\\\">%%4d %%s</span>\\n\", NR, $0}\n"
380 printf "function bl() {printf \"%%4d %%s\\n\", NR, $0}\n"
381 }
382
383 /^</ {next}
384 /^>/ {next}
385 /^---/ {next}
386
387 {
388 split($1, a, /[cad]/) ;
389 if (index($1, "d")) {
390 if (a[2] == 0) {
391 n = split(a[1], r, /,/);
392 if (n == 1)
393 printf "BEGIN\t\t{sp(1)}\n"
394 else
395 printf "BEGIN\t\t{sp(%d)}\n",\
396 (r[2] - r[1]) + 1
397 next
398 }
399
492 #
493 # $WDIR/DIR/$TNAME.lhs.html
494 # $WDIR/DIR/$TNAME.rhs.html
495 # $WDIR/DIR/$TNAME.frames.html
496 #
497 # NOTE: We rely on standard usage of $WDIR and $DIR.
498 #
499 function framed_sdiff
500 {
501 typeset TNAME=$1
502 typeset TPATH=$2
503 typeset lhsfile=$3
504 typeset rhsfile=$4
505 typeset comments=$5
506 typeset RTOP
507
508 # Enable html files to access WDIR via a relative path.
509 RTOP=$(relative_dir $TPATH $WDIR)
510
511 # Make the rhs/lhs files and output the frameset file.
512 print "$HTML<head>$STDHEAD <title>$WNAME rhs/lhs "\
513 "$TPATH/$TNAME</title>" > $WDIR/$DIR/$TNAME.lhs.html
514
515 cat >> $WDIR/$DIR/$TNAME.lhs.html <<-EOF
516 <script type="text/javascript" src="$RTOP/ancnav.js"></script>
517 </head>
518 <body id="SUNWwebrev" onkeypress="keypress(event);">
519 <a name="0"></a>
520 <pre>$comments</pre><hr></hr>
521 EOF
522
523 cp $WDIR/$DIR/$TNAME.lhs.html $WDIR/$DIR/$TNAME.rhs.html
524
525 insert_anchors $lhsfile >> $WDIR/$DIR/$TNAME.lhs.html
526 insert_anchors $rhsfile >> $WDIR/$DIR/$TNAME.rhs.html
527
528 close='</body></html>'
529
530 print $close >> $WDIR/$DIR/$TNAME.lhs.html
531 print $close >> $WDIR/$DIR/$TNAME.rhs.html
532
533 print "$FRAMEHTML<head>$STDHEAD" > $WDIR/$DIR/$TNAME.frames.html
627 # The script detects changed lines as any line that has a "<span
628 # class=" string embedded (unchanged lines have no class set and are
629 # not part of a <span>. Blank lines (without a sequence number)
630 # are also detected since they flag lines that have been inserted or
631 # deleted.
632 #
633 function insert_anchors
634 {
635 $AWK '
636 function ia() {
637 # This should be able to be a singleton <a /> but that
638 # seems to trigger a bug in firefox a:hover rule processing
639 printf "<a name=\"%d\" id=\"anc%d\"></a>", anc, anc++;
640 }
641
642 BEGIN {
643 anc=1;
644 inblock=1;
645 printf "<pre>\n";
646 }
647 NF == 0 || /^<span class=/ {
648 if (inblock == 0) {
649 ia();
650 inblock=1;
651 }
652 print;
653 next;
654 }
655 {
656 inblock=0;
657 print;
658 }
659 END {
660 ia();
661
662 printf "<b style=\"font-size: large; color: red\">";
663 printf "--- EOF ---</b>"
664 for(i=0;i<8;i++) printf "\n\n\n\n\n\n\n\n\n\n";
665 printf "</pre>"
666 printf "<form name=\"eof\" action=\"#\">";
667 printf "<input name=\"value\" value=\"%d\" type=\"hidden\" />",
668 anc - 1;
669 printf "</form>";
670 }
671 ' $1
672 }
673
674
675 #
676 # relative_dir
677 #
678 # Print a relative return path from $1 to $2. For example if
679 # $1=/tmp/myreview/raw_files/usr/src/tools/scripts and $2=/tmp/myreview,
680 # this function would print "../../../../".
681 #
682 # In the event that $1 is not in $2 a warning is printed to stderr,
683 # and $2 is returned-- the result of this is that the resulting webrev
684 # is not relocatable.
685 #
686 function relative_dir
910 cat << \EOF
911 </head>
912 <body id="SUNWwebrev" bgcolor="#eeeeee" onload="document.diff.real.focus();"
913 onkeypress="keypress(event);">
914 <noscript lang="javascript">
915 <center>
916 <p><big>Framed Navigation controls require Javascript</big><br />
917 Either this browser is incompatable or javascript is not enabled</p>
918 </center>
919 </noscript>
920 <table width="100%" border="0" align="center">
921 <tr>
922 <td valign="middle" width="25%">Diff navigation:
923 Use 'j' and 'k' for next and previous diffs; or use buttons
924 at right</td>
925 <td align="center" valign="top" width="50%">
926 <div class="button">
927 <table border="0" align="center">
928 <tr>
929 <td>
930 <a onmousedown="handlePress(1);return true;"
931 onmouseup="handleRelease(1);return true;"
932 onmouseout="handleRelease(1);return true;"
933 onclick="return false;"
934 title="Go to Beginning Of file">BOF</a></td>
935 <td>
936 <a onmousedown="handlePress(3);return true;"
937 onmouseup="handleRelease(3);return true;"
938 onmouseout="handleRelease(3);return true;"
939 title="Scroll Up: Press and Hold to accelerate"
940 onclick="return false;">Scroll Up</a></td>
941 <td>
942 <a onmousedown="handlePress(2);return true;"
943 onmouseup="handleRelease(2);return true;"
944 onmouseout="handleRelease(2);return true;"
945 title="Go to previous Diff"
946 onclick="return false;">Prev Diff</a>
947 </td></tr>
948
949 <tr>
950 <td>
951 <a onmousedown="handlePress(6);return true;"
952 onmouseup="handleRelease(6);return true;"
953 onmouseout="handleRelease(6);return true;"
954 onclick="return false;"
955 title="Go to End Of File">EOF</a></td>
956 <td>
957 <a onmousedown="handlePress(4);return true;"
958 onmouseup="handleRelease(4);return true;"
959 onmouseout="handleRelease(4);return true;"
960 title="Scroll Down: Press and Hold to accelerate"
961 onclick="return false;">Scroll Down</a></td>
962 <td>
963 <a onmousedown="handlePress(5);return true;"
964 onmouseup="handleRelease(5);return true;"
965 onmouseout="handleRelease(5);return true;"
966 title="Go to next Diff"
967 onclick="return false;">Next Diff</a></td>
968 </tr>
969 </table>
970 </div>
971 </td>
972 <th valign="middle" width="25%">
973 <form action="" name="diff" onsubmit="return ValidateDiffNum();">
974 <input name="display" value="BOF" size="8" type="text" />
975 <input name="real" value="0" size="8" type="hidden" />
976 </form>
977 </th>
978 </tr>
979 </table>
980 </body>
981 </html>
982 EOF
983 }
984
985
986
987 #
1004 print "$UDIFFCSS"
1005 fi
1006
1007 cat <<-EOF
1008 </head>
1009 <body id="SUNWwebrev">
1010 <h2>$TPATH</h2>
1011 <a class="print" href="javascript:print()">Print this page</a>
1012 <pre>$COMMENT</pre>
1013 <pre>
1014 EOF
1015
1016 html_quote | $AWK '
1017 /^--- new/ { next }
1018 /^\+\+\+ new/ { next }
1019 /^--- old/ { next }
1020 /^\*\*\* old/ { next }
1021 /^\*\*\*\*/ { next }
1022 /^-------/ { printf "<center><h1>%s</h1></center>\n", $0; next }
1023 /^\@\@.*\@\@$/ { printf "</pre><hr /><pre>\n";
1024 printf "<span class=\"newmarker\">%s</span>\n", $0;
1025 next}
1026
1027 /^\*\*\*/ { printf "</pre><hr /><pre><span class=\"oldmarker\">%s</span>\n", $0;
1028 next}
1029 /^---/ { printf "<span class=\"newmarker\">%s</span>\n", $0;
1030 next}
1031 /^\+/ {printf "<span class=\"new\">%s</span>\n", $0; next}
1032 /^!/ {printf "<span class=\"changed\">%s</span>\n", $0; next}
1033 /^-/ {printf "<span class=\"removed\">%s</span>\n", $0; next}
1034 {printf "%s\n", $0; next}
1035 '
1036
1037 print "</pre></body></html>\n"
1038 }
1039
1040
1041 #
1042 # source_to_html { new | old } <filename>
1043 #
1044 # Process a plain vanilla source file to transform it into an HTML file.
1045 #
1046 source_to_html()
1047 {
1048 WHICH=$1
1049 TNAME=$2
1050
1051 print "$HTML<head>$STDHEAD"
1052 print "<title>$WHICH $TNAME</title>"
1053 print "</head><body id=\"SUNWwebrev\">"
1054 print "<pre>"
1055 html_quote | $AWK '{line += 1 ; printf "%4d %s\n", line, $0 }'
1056 print "</pre></body></html>"
1057 }
1058
1059 #
1060 # teamwarecomments {text|html} parent-file child-file
1061 #
1062 # Find the first delta in the child that's not in the parent. Get the
1063 # newest delta from the parent, get all deltas from the child starting
1064 # with that delta, and then get all info starting with the second oldest
1065 # delta in that list (the first delta unique to the child).
1066 #
1067 # This code adapted from Bill Shannon's "spc" script
1068 #
1069 comments_from_teamware()
1070 {
1071 fmt=$1
1072 pfile=$PWS/$2
1073 cfile=$CWS/$3
1312
1313 # End of $AWK, Check to see if any trouble occurred.
1314 if (( $? > 0 || err > 0 )); then
1315 print "Unexpected Error occurred reading" \
1316 "\`diff -e $1 $2\`: \$?=$?, err=" $err
1317 return
1318 fi
1319
1320 # Accumulate totals
1321 (( TOTL += tot ))
1322 (( TMOD += mod ))
1323 (( TDEL += del ))
1324 (( TINS += ins ))
1325 # Calculate unchanged lines
1326 unc=`wc -l < $1`
1327 if (( unc > 0 )); then
1328 (( unc -= del + mod ))
1329 (( TUNC += unc ))
1330 fi
1331 # print summary
1332 print "<span class=\"lineschanged\">\c"
1333 printCI $tot $ins $del $mod $unc
1334 print "</span>"
1335 }
1336
1337
1338 #
1339 # flist_from_wx
1340 #
1341 # Sets up webrev to source its information from a wx-formatted file.
1342 # Sets the global 'wxfile' variable.
1343 #
1344 function flist_from_wx
1345 {
1346 typeset argfile=$1
1347 if [[ -n ${argfile%%/*} ]]; then
1348 #
1349 # If the wx file pathname is relative then make it absolute
1350 # because the webrev does a "cd" later on.
1351 #
1352 wxfile=$PWD/$argfile
3004 # <title>6641309: Wrong Cookie separator used in HttpURLConnection</title>
3005 #
3006 if [[ -n $CRID ]]; then
3007 for id in $CRID
3008 do
3009 print "<tr><th>Bug id:</th><td>"
3010 url="${BUGURL}${id}"
3011 if [[ -n $WGET ]]; then
3012 msg=`$WGET -q $url -O - | grep '<title>' | sed 's/<title>\(.*\)<\/title>/\1/' | sed 's/Bug ID://'`
3013 fi
3014 if [[ -n $msg ]]; then
3015 print "<a href=\"$url\">$msg</a>"
3016 else
3017 print $id | bug2url
3018 fi
3019
3020 print "</td></tr>"
3021 done
3022 fi
3023 print "<tr><th>Legend:</th><td>"
3024 print "<b>Modified file</b><br /><font color=\"red\"><b>Deleted file</b></font><br /><font color=\"green\"><b>New file</b></font></td></tr>"
3025 print "</table>"
3026 print "</div>"
3027
3028 #
3029 # Second pass through the files: generate the rest of the index file
3030 #
3031 while read LINE
3032 do
3033 set - $LINE
3034 if [[ $1 == "Revision:" ]]; then
3035 FIRST_CREV=`expr $3 + 1`
3036 continue
3037 fi
3038 P=$1
3039
3040 if [[ $# == 2 ]]; then
3041 PP=$2
3042 oldname=" <i>(was $PP)</i>"
3043
3044 else
3144 fi
3145
3146 # Add additional comments comment
3147
3148 print "<!-- Add comments to explain changes in $P here -->"
3149
3150 # Add count of changes.
3151
3152 if [[ -f $F.count ]]; then
3153 cat $F.count
3154 rm $F.count
3155 fi
3156 print "</blockquote>"
3157 done < $FLIST
3158
3159 print
3160 print
3161 print "<hr />"
3162 print "<p style=\"font-size: small\">"
3163 print "This code review page was prepared using <b>$0</b>"
3164 print "(vers $WEBREV_UPDATED).</p>"
3165 print "</body>"
3166 print "</html>"
3167
3168 if [[ -n $ZIP ]]; then
3169 # Let's generate a zip file for convenience
3170 cd $WDIR/..
3171 if [ -f webrev.zip ]; then
3172 rm webrev.zip
3173 fi
3174 $ZIP -r webrev webrev >/dev/null 2>&1
3175 fi
3176
3177 exec 1<&- # Close FD 1.
3178 exec 1<&3 # dup FD 3 to restore stdout.
3179 exec 3<&- # close FD 3.
3180
3181 print "Done."
3182 print "Output to: $WDIR"
3183
|