@@ -268,7 +268,7 @@ sub include {
268268sub got_para {
269269 local ($_ ) = @_ ;
270270 my $pflags = " " , $i , $w , $l , $t ;
271- my @ para = () ;
271+ my $ para = [] ;
272272
273273 return if !/\S/;
274274
@@ -294,7 +294,7 @@ sub got_para {
294294 $l =~ s /\\\{ / \{ / g ;
295295 $l =~ s /\\\} / }/ g ;
296296 $l =~ s /\\\\ / \\ / g ;
297- push @para , $l ;
297+ push @$ para , $l ;
298298 }
299299 $_ = ' ' ; # suppress word-by-word code
300300 } elsif (/ ^\\ C/ ) {
@@ -308,7 +308,7 @@ sub got_para {
308308 die " badly formatted chapter heading: $_ \n " if !/^\\C\{([^\}]*)\}\s * (.* )$/ ;
309309 $refs {$1 } = "chapter $cnum ";
310310 $node = "Chapter $cnum ";
311- &add_item($node , 1);
311+ &add_item($node , 1, $para );
312312 $xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
313313 $xrefs {$1 } = $xref ;
314314 $_ = $2 ;
@@ -325,7 +325,7 @@ sub got_para {
325325 die "badly formatted appendix heading: $_ \n " if !/^\\ A\{ ([^\} ]* )}\s * (.* )$/ ;
326326 $refs {$1 } = "appendix $cnum ";
327327 $node = "Appendix $cnum ";
328- &add_item($node , 1);
328+ &add_item($node , 1, $para );
329329 $xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
330330 $xrefs {$1 } = $xref ;
331331 $_ = $2 ;
@@ -339,7 +339,7 @@ sub got_para {
339339 die "badly formatted heading: $_ \n " if !/^\\ [HP]\{ ([^\} ]* )\}\s * (.* )$/ ;
340340 $refs {$1 } = "section $cnum .$hnum ";
341341 $node = "Section $cnum .$hnum ";
342- &add_item($node , 2);
342+ &add_item($node , 2, $para );
343343 $xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
344344 $xrefs {$1 } = $xref ;
345345 $_ = $2 ;
@@ -352,7 +352,7 @@ sub got_para {
352352 die "badly formatted subheading: $_ \n " if !/^\\ S\{ ([^\} ]* )\}\s * (.* )$/ ;
353353 $refs {$1 } = "section $cnum .$hnum .$snum ";
354354 $node = "Section $cnum .$hnum .$snum ";
355- &add_item($node , 3);
355+ &add_item($node , 3, $para );
356356 $xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
357357 $xrefs {$1 } = $xref ;
358358 $_ = $2 ;
@@ -389,11 +389,11 @@ sub got_para {
389389 $pflags = " norm" ;
390390 }
391391
392- # The word-by-word code: unless @para is already defined (which it
392+ # The word-by-word code: unless @$ para is already defined (which it
393393 # will be in the case of a code paragraph), split the paragraph up
394- # into words and push each on @para.
394+ # into words and push each on @$ para.
395395 #
396- # Each thing pushed on @para should have a two-character type
396+ # Each thing pushed on @$ para should have a two-character type
397397 # code followed by the text.
398398 #
399399 # Type codes are:
@@ -416,7 +416,7 @@ sub got_para {
416416 # index-items arrays
417417 # "sp" for space
418418 while (/ \S / ) {
419- s / ^\s *// , push @para , " sp" if / ^\s / ;
419+ s / ^\s *// , push @$ para , " sp" if / ^\s / ;
420420 $indexing = $qindex = 0;
421421 if (/ ^(\\ [iI])?\\ c/ ) {
422422 $qindex = 1 if $1 eq " \\ I" ;
@@ -429,8 +429,8 @@ sub got_para {
429429 $w =~ s /\\\} / \} / g ;
430430 $w =~ s /\\ -/ -/ g ;
431431 $w =~ s /\\\\ / \\ / g ;
432- push (@para , addidx($node , $w , " c $w " )) if ($indexing );
433- push (@para , " c $w " ) if (!$qindex );
432+ push (@$ para , addidx($node , $w , " c $w " )) if ($indexing );
433+ push (@$ para , " c $w " ) if (!$qindex );
434434 } elsif (/ ^\\ [iIe]/ ) {
435435 / ^(\\ [iI])?(\\ e)?/ ;
436436 $emph = 0;
@@ -456,7 +456,7 @@ sub got_para {
456456 if ($indexing ) {
457457 $w =~ tr / A-Z/ a-z/ ;
458458 pop @ientry ; # remove final space
459- push (@para , addidx($node , $w , @ientry ));
459+ push (@$ para , addidx($node , $w , @ientry ));
460460 }
461461 if (!$qindex ) {
462462 pop @pentry ; # remove final space
@@ -465,15 +465,15 @@ sub got_para {
465465 } elsif ($emph ) {
466466 substr ($pentry [-1],0,2) = ' ee' ;
467467 }
468- push (@para , @pentry );
468+ push (@$ para , @pentry );
469469 }
470470 } elsif (/ ^\\ [kK]/ ) {
471471 $t = " k " ;
472472 $t = " kK" if / ^\\ K/ ;
473473 s / ^\\ [kK]// ;
474474 die " badly formatted \\ k: \\ k$_ \n " if !/\{([^\}]*)\}(.*)$/ ;
475475 $_ = $2 ;
476- push @para ," $t$1 " ;
476+ push @$ para ," $t$1 " ;
477477 } elsif (/ ^\\ W/ ) {
478478 s / ^\\ W// ;
479479 die " badly formatted \\ W: \\ W$_ \n "
@@ -488,8 +488,8 @@ sub got_para {
488488 $w =~ s /\\\} / \} / g ;
489489 $w =~ s /\\ -/ -/ g ;
490490 $w =~ s /\\\\ / \\ / g ;
491- push (@para , addidx($node , $w , " c $w " )) if $indexing ;
492- push (@para , " $t <$l >$w " );
491+ push (@$ para , addidx($node , $w , " c $w " )) if $indexing ;
492+ push (@$ para , " $t <$l >$w " );
493493 } else {
494494 die " what the hell? $_ \n " if !/^(([^\s \\\-]|\\[\\{}\-])*-?)(.*)$/ ;
495495 die " painful death! $_ \n " if !length $1 ;
@@ -500,18 +500,18 @@ sub got_para {
500500 $w =~ s /\\ -/ -/ g ;
501501 $w =~ s /\\\\ / \\ / g ;
502502 if ($w eq ' --' ) {
503- push @para , ' dm' ;
503+ push @$ para , ' dm' ;
504504 } elsif ($w eq ' -' ) {
505- push @para , ' da' ;
505+ push @$ para , ' da' ;
506506 } else {
507- push @para ," n $w " ;
507+ push @$ para ," n $w " ;
508508 }
509509 }
510510 }
511511 if ($irewrite ne undef ) {
512- addidx(undef , $irewrite , @para );
512+ addidx(undef , $irewrite , @$ para );
513513 } else {
514- push @pnames , [ @ para] ;
514+ push @pnames , $ para ;
515515 push @pflags , $pflags ;
516516 }
517517}
@@ -769,6 +769,15 @@ sub word_txt {
769769 }
770770}
771771
772+ sub html_filename ($) {
773+ my ($node ) = @_ ;
774+
775+ (my $number = lc ($xrefnodes {$node })) =~ s / .*-// ;
776+ my $fname =" nasmdocx.html" ;
777+ substr ($fname ,8 - length $number , length $number ) = $number ;
778+ return $fname ;
779+ }
780+
772781sub write_html {
773782 # This is called from the top level, so I won't bother using
774783 # my or local.
@@ -778,6 +787,8 @@ sub write_html {
778787 print " writing contents file..." ;
779788 open TEXT, ' >' , File::Spec-> catfile($out_path , ' nasmdoc0.html' );
780789 select TEXT;
790+ undef $html_nav_last ;
791+ $html_nav_next = $tstruct_next {' Top' };
781792 &html_preamble(0);
782793 print " <p>This manual documents NASM, the Netwide Assembler: an assembler\n " ;
783794 print " targeting the Intel x86 series of processors, with portable source.\n </p>" ;
@@ -797,22 +808,13 @@ sub write_html {
797808 }
798809 $level = $tstruct_level {$node };
799810 if ($level == 1) {
800- # Invent a file name.
801- ($number = lc ($xrefnodes {$node })) =~ s / .*-// ;
802- $fname =" nasmdocx.html" ;
803- substr ($fname ,8 - length $number , length $number ) = $number ;
804- $html_fnames {$node } = $fname ;
805- $link = $fname ;
811+ $link = $fname = html_filename($node );
806812 } else {
807813 # Use the preceding filename plus a marker point.
808814 $link = $fname . " #$xrefnodes {$node }" ;
809815 }
810- $title = ' ' ;
811816 $pname = $tstruct_pname {$node };
812- foreach $i (@$pname ) {
813- $ww = &word_html($i );
814- $title .= $ww unless $ww eq " \001 " ;
815- }
817+ $title = plist_to_html(@$pname );
816818 print " <li class=\" toc${level} \" >\n " ;
817819 print " <span class=\" node\" >$node : </span><a href=\" $link \" >$title </a>\n " ;
818820 }
@@ -857,7 +859,7 @@ sub write_html {
857859 $html_nav_last = $chapternode ;
858860 $chapternode = $nodexrefs {$xref };
859861 $html_nav_next = $tstruct_mnext {$chapternode };
860- open (TEXT, ' >' , File::Spec-> catfile($out_path , $html_fnames { $ chapternode} ));
862+ open (TEXT, ' >' , File::Spec-> catfile($out_path , html_filename( $ chapternode) ));
861863 select TEXT;
862864 &html_preamble(1);
863865 foreach $i (@$pname ) {
@@ -875,7 +877,7 @@ sub write_html {
875877 $html_nav_last = $chapternode ;
876878 $chapternode = $nodexrefs {$xref };
877879 $html_nav_next = $tstruct_mnext {$chapternode };
878- open (TEXT, ' >' , File::Spec-> catfile($out_path , $html_fnames { $ chapternode} ));
880+ open (TEXT, ' >' , File::Spec-> catfile($out_path , html_filename( $ chapternode) ));
879881 select TEXT;
880882 &html_preamble(1);
881883 foreach $i (@$pname ) {
@@ -992,11 +994,11 @@ sub html_preamble {
992994 # Navigation bar
993995 print " <ul class=\" navbar\" >\n " ;
994996 if (defined ($html_nav_last )) {
995- my $lastf = $html_fnames { $ html_nav_last} ;
997+ my $lastf = html_filename( $ html_nav_last) ;
996998 print " <li class=\" first\" ><a class=\" prev\" href=\" $lastf \" >$html_nav_last </a></li>\n " ;
997999 }
9981000 if (defined ($html_nav_next )) {
999- my $nextf = $html_fnames { $ html_nav_next} ;
1001+ my $nextf = html_filename( $ html_nav_next) ;
10001002 print " <li><a class=\" next\" href=\" $nextf \" >$html_nav_next </a></li>\n " ;
10011003 }
10021004 print " <li><a class=\" toc\" href=\" nasmdoc0.html\" >Contents</a></li>\n " ;
@@ -1066,7 +1068,19 @@ sub html_index {
10661068 print " </ul>\n " ;
10671069}
10681070
1069- sub word_html {
1071+ sub plist_to_html (@) {
1072+ my $ws = ' ' ;
1073+
1074+ foreach my $w (@_ ) {
1075+ my $ww = word_html($w );
1076+ next if ($ww eq " \001 " );
1077+ $ws .= $ww ;
1078+ }
1079+
1080+ return $ws ;
1081+ }
1082+
1083+ sub word_html ($) {
10701084 my ($w ) = @_ ;
10711085 my $wtype , $wmajt , $pfx , $sfx ;
10721086
@@ -1106,7 +1120,7 @@ sub word_html {
11061120 my $level = $tstruct_level {$node }; # and its level
11071121 my $up = $node , $uplev = $level -1;
11081122 $up = $tstruct_up {$up } while $uplev --; # get top node of containing file
1109- my $file = ($up ne $chapternode ) ? $html_fnames { $up } : " " ;
1123+ my $file = ($up ne $chapternode ) ? html_filename( $up ) : " " ;
11101124 my $marker = ($level == 1 and $file ) ? " " : " #$w " ;
11111125 return " <a href=\" $file$marker \" >" ;
11121126 } elsif ($wtype eq " xe" ) {
@@ -1119,11 +1133,11 @@ sub word_html {
11191133}
11201134
11211135# Make tree structures. $tstruct_* is top-level and global.
1122- sub add_item {
1123- my ($item , $level ) = @_ ;
1136+ sub add_item ($$$) {
1137+ my ($item , $level , $para ) = @_ ;
11241138 my $i ;
11251139
1126- $tstruct_pname {$item } = $pname ;
1140+ $tstruct_pname {$item } = $para ;
11271141 $tstruct_next {$tstruct_previtem } = $item ;
11281142 $tstruct_prev {$item } = $tstruct_previtem ;
11291143 $tstruct_level {$item } = $level ;
0 commit comments