Skip to content

Commit a5fc643

Browse files
author
H. Peter Anvin
committed
doc/genps.pl: handle large lists of index entries
If a list of index entries is so long that the whole list can't fit onto a single page, we *have* to break it. Treat the hanging-comma line as a potential widow, but allow column breaks elsewhere in the list. Signed-off-by: H. Peter Anvin <[email protected]>
1 parent d77a86b commit a5fc643

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

doc/genps.pl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
require 'pswidth.ph'; # PostScript string width
4343
require 'findfont.ph'; # Find fonts in the system
4444

45+
sub basename($) {
46+
my($path) = @_;
47+
my($vol,$dir,$file) = File::Spec->splitpath($path);
48+
return $file;
49+
}
50+
4551
#
4652
# Document formatting parameters
4753
#
@@ -869,7 +875,8 @@ ($$)
869875
# Paragraph types which are heading (meaning they should not be broken
870876
# immediately after)
871877
my $nobreakafter = "^(chap|appn|head|subh)\$";
872-
# Paragraph types which should never be broken *before*
878+
# Paragraph types which should never be broken *before*, unless
879+
# the previous paragraph has the same type
873880
my $nobreakbefore = "^idx[1-9]\$";
874881
# Paragraph types which are set in columnar format
875882
my $columnregexp = "^idx.\$";
@@ -918,15 +925,17 @@ ($$)
918925
# This would be an orphan, don't break.
919926
} elsif ( $$linfo[1] & 1 ) {
920927
# Sole line or start of paragraph. Break unless
921-
# the previous line was part of a heading.
922-
$broken = 1 if ( $$pinfo[0] !~ /$nobreakafter/o &&
923-
$$linfo[0] !~ /$nobreakbefore/o );
928+
# the previous line was part of a heading or a comma
929+
# index entry.
930+
$broken = $$pinfo[0] !~ /$nobreakafter/o &&
931+
($$linfo[0] !~ /$nobreakbefore/o ||
932+
$$linfo[0] eq $$pinfo[0]);
924933
} else {
925934
# Middle of paragraph. Break unless we're in a
926935
# no-break paragraph, or the previous line would
927936
# end up being a widow.
928-
$broken = 1 if ( $$linfo[0] !~ /$nobreakregexp/o &&
929-
$$pinfo[1] != 1 );
937+
$broken = $$linfo[0] !~ /$nobreakregexp/o &&
938+
$$pinfo[1] != 1;
930939
}
931940
$i--;
932941
}
@@ -1066,7 +1075,7 @@ ($$)
10661075
print "%!PS-Adobe-3.0\n";
10671076
print "%%Pages: $curpage\n";
10681077
print "%%BoundingBox: 0 0 ", $psconf{pagewidth}, ' ', $psconf{pageheight}, "\n";
1069-
print "%%Creator: (NASM psflow.pl)\n";
1078+
print "%%Creator: ", basename($0), "\n";
10701079
print "%%DocumentData: Clean7Bit\n";
10711080
print "%%DocumentFonts: $all_fonts_str\n";
10721081
print "%%DocumentNeededFonts: $need_fonts_str\n";

0 commit comments

Comments
 (0)