Skip to content

Commit b67d423

Browse files
author
H. Peter Anvin
committed
doc: fix HTML table of contents generation
Fix the HTML table of contents being completely broken. Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 49bbfed commit b67d423

File tree

2 files changed

+46
-31
lines changed

2 files changed

+46
-31
lines changed

doc/changes.src

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
The NASM 2 series supports x86-64, and is the production version of NASM
88
since 2007.
99

10+
\S{cl-2.16.01} Version 2.16.01
11+
12+
\e{This is a documentation update release only.}
13+
14+
\b Fix the creation of the table of contents in the HTML version of
15+
the documentation.
16+
1017
\S{cl-2.16} Version 2.16
1118

1219
\b Support for the \c{rdf} format has been discontinued and all the

doc/rdsrc.pl

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ sub include {
268268
sub 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
}
@@ -807,12 +807,8 @@ sub write_html {
807807
# Use the preceding filename plus a marker point.
808808
$link = $fname . "#$xrefnodes{$node}";
809809
}
810-
$title = '';
811810
$pname = $tstruct_pname{$node};
812-
foreach $i (@$pname) {
813-
$ww = &word_html($i);
814-
$title .= $ww unless $ww eq "\001";
815-
}
811+
$title = plist_to_html(@$pname);
816812
print "<li class=\"toc${level}\">\n";
817813
print "<span class=\"node\">$node: </span><a href=\"$link\">$title</a>\n";
818814
}
@@ -1066,7 +1062,19 @@ sub html_index {
10661062
print "</ul>\n";
10671063
}
10681064

1069-
sub word_html {
1065+
sub plist_to_html(@) {
1066+
my $ws = '';
1067+
1068+
foreach my $w (@_) {
1069+
my $ww = word_html($w);
1070+
next if ($ww eq "\001");
1071+
$ws .= $ww;
1072+
}
1073+
1074+
return $ws;
1075+
}
1076+
1077+
sub word_html($) {
10701078
my ($w) = @_;
10711079
my $wtype, $wmajt, $pfx, $sfx;
10721080

@@ -1119,11 +1127,11 @@ sub word_html {
11191127
}
11201128

11211129
# Make tree structures. $tstruct_* is top-level and global.
1122-
sub add_item {
1123-
my ($item, $level) = @_;
1130+
sub add_item($$$) {
1131+
my ($item, $level, $para) = @_;
11241132
my $i;
11251133

1126-
$tstruct_pname{$item} = $pname;
1134+
$tstruct_pname{$item} = $para;
11271135
$tstruct_next{$tstruct_previtem} = $item;
11281136
$tstruct_prev{$item} = $tstruct_previtem;
11291137
$tstruct_level{$item} = $level;

0 commit comments

Comments
 (0)