@@ -268,7 +268,7 @@ sub include {
268
268
sub got_para {
269
269
local ($_ ) = @_ ;
270
270
my $pflags = " " , $i , $w , $l , $t ;
271
- my @ para = () ;
271
+ my $ para = [] ;
272
272
273
273
return if !/\S/;
274
274
@@ -294,7 +294,7 @@ sub got_para {
294
294
$l =~ s /\\\{ / \{ / g ;
295
295
$l =~ s /\\\} / }/ g ;
296
296
$l =~ s /\\\\ / \\ / g ;
297
- push @para , $l ;
297
+ push @$ para , $l ;
298
298
}
299
299
$_ = ' ' ; # suppress word-by-word code
300
300
} elsif (/ ^\\ C/ ) {
@@ -308,7 +308,7 @@ sub got_para {
308
308
die " badly formatted chapter heading: $_ \n " if !/^\\C\{([^\}]*)\}\s * (.* )$/ ;
309
309
$refs {$1 } = "chapter $cnum ";
310
310
$node = "Chapter $cnum ";
311
- &add_item($node , 1);
311
+ &add_item($node , 1, $para );
312
312
$xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
313
313
$xrefs {$1 } = $xref ;
314
314
$_ = $2 ;
@@ -325,7 +325,7 @@ sub got_para {
325
325
die "badly formatted appendix heading: $_ \n " if !/^\\ A\{ ([^\} ]* )}\s * (.* )$/ ;
326
326
$refs {$1 } = "appendix $cnum ";
327
327
$node = "Appendix $cnum ";
328
- &add_item($node , 1);
328
+ &add_item($node , 1, $para );
329
329
$xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
330
330
$xrefs {$1 } = $xref ;
331
331
$_ = $2 ;
@@ -339,7 +339,7 @@ sub got_para {
339
339
die "badly formatted heading: $_ \n " if !/^\\ [HP]\{ ([^\} ]* )\}\s * (.* )$/ ;
340
340
$refs {$1 } = "section $cnum .$hnum ";
341
341
$node = "Section $cnum .$hnum ";
342
- &add_item($node , 2);
342
+ &add_item($node , 2, $para );
343
343
$xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
344
344
$xrefs {$1 } = $xref ;
345
345
$_ = $2 ;
@@ -352,7 +352,7 @@ sub got_para {
352
352
die "badly formatted subheading: $_ \n " if !/^\\ S\{ ([^\} ]* )\}\s * (.* )$/ ;
353
353
$refs {$1 } = "section $cnum .$hnum .$snum ";
354
354
$node = "Section $cnum .$hnum .$snum ";
355
- &add_item($node , 3);
355
+ &add_item($node , 3, $para );
356
356
$xrefnodes {$node } = $xref ; $nodexrefs {$xref } = $node ;
357
357
$xrefs {$1 } = $xref ;
358
358
$_ = $2 ;
@@ -389,11 +389,11 @@ sub got_para {
389
389
$pflags = " norm" ;
390
390
}
391
391
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
393
393
# 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.
395
395
#
396
- # Each thing pushed on @para should have a two-character type
396
+ # Each thing pushed on @$ para should have a two-character type
397
397
# code followed by the text.
398
398
#
399
399
# Type codes are:
@@ -416,7 +416,7 @@ sub got_para {
416
416
# index-items arrays
417
417
# "sp" for space
418
418
while (/ \S / ) {
419
- s / ^\s *// , push @para , " sp" if / ^\s / ;
419
+ s / ^\s *// , push @$ para , " sp" if / ^\s / ;
420
420
$indexing = $qindex = 0;
421
421
if (/ ^(\\ [iI])?\\ c/ ) {
422
422
$qindex = 1 if $1 eq " \\ I" ;
@@ -429,8 +429,8 @@ sub got_para {
429
429
$w =~ s /\\\} / \} / g ;
430
430
$w =~ s /\\ -/ -/ g ;
431
431
$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 );
434
434
} elsif (/ ^\\ [iIe]/ ) {
435
435
/ ^(\\ [iI])?(\\ e)?/ ;
436
436
$emph = 0;
@@ -456,7 +456,7 @@ sub got_para {
456
456
if ($indexing ) {
457
457
$w =~ tr / A-Z/ a-z/ ;
458
458
pop @ientry ; # remove final space
459
- push (@para , addidx($node , $w , @ientry ));
459
+ push (@$ para , addidx($node , $w , @ientry ));
460
460
}
461
461
if (!$qindex ) {
462
462
pop @pentry ; # remove final space
@@ -465,15 +465,15 @@ sub got_para {
465
465
} elsif ($emph ) {
466
466
substr ($pentry [-1],0,2) = ' ee' ;
467
467
}
468
- push (@para , @pentry );
468
+ push (@$ para , @pentry );
469
469
}
470
470
} elsif (/ ^\\ [kK]/ ) {
471
471
$t = " k " ;
472
472
$t = " kK" if / ^\\ K/ ;
473
473
s / ^\\ [kK]// ;
474
474
die " badly formatted \\ k: \\ k$_ \n " if !/\{([^\}]*)\}(.*)$/ ;
475
475
$_ = $2 ;
476
- push @para ," $t$1 " ;
476
+ push @$ para ," $t$1 " ;
477
477
} elsif (/ ^\\ W/ ) {
478
478
s / ^\\ W// ;
479
479
die " badly formatted \\ W: \\ W$_ \n "
@@ -488,8 +488,8 @@ sub got_para {
488
488
$w =~ s /\\\} / \} / g ;
489
489
$w =~ s /\\ -/ -/ g ;
490
490
$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 " );
493
493
} else {
494
494
die " what the hell? $_ \n " if !/^(([^\s \\\-]|\\[\\{}\-])*-?)(.*)$/ ;
495
495
die " painful death! $_ \n " if !length $1 ;
@@ -500,18 +500,18 @@ sub got_para {
500
500
$w =~ s /\\ -/ -/ g ;
501
501
$w =~ s /\\\\ / \\ / g ;
502
502
if ($w eq ' --' ) {
503
- push @para , ' dm' ;
503
+ push @$ para , ' dm' ;
504
504
} elsif ($w eq ' -' ) {
505
- push @para , ' da' ;
505
+ push @$ para , ' da' ;
506
506
} else {
507
- push @para ," n $w " ;
507
+ push @$ para ," n $w " ;
508
508
}
509
509
}
510
510
}
511
511
if ($irewrite ne undef ) {
512
- addidx(undef , $irewrite , @para );
512
+ addidx(undef , $irewrite , @$ para );
513
513
} else {
514
- push @pnames , [ @ para] ;
514
+ push @pnames , $ para ;
515
515
push @pflags , $pflags ;
516
516
}
517
517
}
@@ -769,6 +769,15 @@ sub word_txt {
769
769
}
770
770
}
771
771
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
+
772
781
sub write_html {
773
782
# This is called from the top level, so I won't bother using
774
783
# my or local.
@@ -778,6 +787,8 @@ sub write_html {
778
787
print " writing contents file..." ;
779
788
open TEXT, ' >' , File::Spec-> catfile($out_path , ' nasmdoc0.html' );
780
789
select TEXT;
790
+ undef $html_nav_last ;
791
+ $html_nav_next = $tstruct_next {' Top' };
781
792
&html_preamble(0);
782
793
print " <p>This manual documents NASM, the Netwide Assembler: an assembler\n " ;
783
794
print " targeting the Intel x86 series of processors, with portable source.\n </p>" ;
@@ -797,22 +808,13 @@ sub write_html {
797
808
}
798
809
$level = $tstruct_level {$node };
799
810
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 );
806
812
} else {
807
813
# Use the preceding filename plus a marker point.
808
814
$link = $fname . " #$xrefnodes {$node }" ;
809
815
}
810
- $title = ' ' ;
811
816
$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 );
816
818
print " <li class=\" toc${level} \" >\n " ;
817
819
print " <span class=\" node\" >$node : </span><a href=\" $link \" >$title </a>\n " ;
818
820
}
@@ -857,7 +859,7 @@ sub write_html {
857
859
$html_nav_last = $chapternode ;
858
860
$chapternode = $nodexrefs {$xref };
859
861
$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) ));
861
863
select TEXT;
862
864
&html_preamble(1);
863
865
foreach $i (@$pname ) {
@@ -875,7 +877,7 @@ sub write_html {
875
877
$html_nav_last = $chapternode ;
876
878
$chapternode = $nodexrefs {$xref };
877
879
$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) ));
879
881
select TEXT;
880
882
&html_preamble(1);
881
883
foreach $i (@$pname ) {
@@ -992,11 +994,11 @@ sub html_preamble {
992
994
# Navigation bar
993
995
print " <ul class=\" navbar\" >\n " ;
994
996
if (defined ($html_nav_last )) {
995
- my $lastf = $html_fnames { $ html_nav_last} ;
997
+ my $lastf = html_filename( $ html_nav_last) ;
996
998
print " <li class=\" first\" ><a class=\" prev\" href=\" $lastf \" >$html_nav_last </a></li>\n " ;
997
999
}
998
1000
if (defined ($html_nav_next )) {
999
- my $nextf = $html_fnames { $ html_nav_next} ;
1001
+ my $nextf = html_filename( $ html_nav_next) ;
1000
1002
print " <li><a class=\" next\" href=\" $nextf \" >$html_nav_next </a></li>\n " ;
1001
1003
}
1002
1004
print " <li><a class=\" toc\" href=\" nasmdoc0.html\" >Contents</a></li>\n " ;
@@ -1066,7 +1068,19 @@ sub html_index {
1066
1068
print " </ul>\n " ;
1067
1069
}
1068
1070
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 ($) {
1070
1084
my ($w ) = @_ ;
1071
1085
my $wtype , $wmajt , $pfx , $sfx ;
1072
1086
@@ -1106,7 +1120,7 @@ sub word_html {
1106
1120
my $level = $tstruct_level {$node }; # and its level
1107
1121
my $up = $node , $uplev = $level -1;
1108
1122
$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 ) : " " ;
1110
1124
my $marker = ($level == 1 and $file ) ? " " : " #$w " ;
1111
1125
return " <a href=\" $file$marker \" >" ;
1112
1126
} elsif ($wtype eq " xe" ) {
@@ -1119,11 +1133,11 @@ sub word_html {
1119
1133
}
1120
1134
1121
1135
# 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 ) = @_ ;
1124
1138
my $i ;
1125
1139
1126
- $tstruct_pname {$item } = $pname ;
1140
+ $tstruct_pname {$item } = $para ;
1127
1141
$tstruct_next {$tstruct_previtem } = $item ;
1128
1142
$tstruct_prev {$item } = $tstruct_previtem ;
1129
1143
$tstruct_level {$item } = $level ;
0 commit comments