[nasm:master] doc/genps.pl: handle large lists of index entries

nasm-bot for H. Peter Anvin hpa at zytor.com
Tue Nov 8 17:58:53 PST 2022


Commit-ID:  a5fc643cb901d9010084a7c82a7cab55cdc73678
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=a5fc643cb901d9010084a7c82a7cab55cdc73678
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Tue, 8 Nov 2022 15:24:24 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Tue, 8 Nov 2022 15:24:24 -0800

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 <hpa at zytor.com>


---
 doc/genps.pl | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/doc/genps.pl b/doc/genps.pl
index e41c4367..cce27d74 100755
--- a/doc/genps.pl
+++ b/doc/genps.pl
@@ -42,6 +42,12 @@ require 'psfonts.ph';		# The fonts we want to use
 require 'pswidth.ph';		# PostScript string width
 require 'findfont.ph';		# Find fonts in the system
 
+sub basename($) {
+    my($path) = @_;
+    my($vol,$dir,$file) = File::Spec->splitpath($path);
+    return $file;
+}
+
 #
 # Document formatting parameters
 #
@@ -869,7 +875,8 @@ sub ps_break_pages($$) {
     # Paragraph types which are heading (meaning they should not be broken
     # immediately after)
     my $nobreakafter = "^(chap|appn|head|subh)\$";
-    # Paragraph types which should never be broken *before*
+    # Paragraph types which should never be broken *before*, unless
+    # the previous paragraph has the same type
     my $nobreakbefore = "^idx[1-9]\$";
     # Paragraph types which are set in columnar format
     my $columnregexp = "^idx.\$";
@@ -918,15 +925,17 @@ sub ps_break_pages($$) {
 		    # This would be an orphan, don't break.
 		} elsif ( $$linfo[1] & 1 ) {
 		    # Sole line or start of paragraph.  Break unless
-		    # the previous line was part of a heading.
-		    $broken = 1 if ( $$pinfo[0] !~ /$nobreakafter/o &&
-				     $$linfo[0] !~ /$nobreakbefore/o );
+		    # the previous line was part of a heading or a comma
+		    # index entry.
+		    $broken = $$pinfo[0] !~ /$nobreakafter/o &&
+			($$linfo[0] !~ /$nobreakbefore/o ||
+			 $$linfo[0] eq $$pinfo[0]);
 		} else {
 		    # Middle of paragraph.  Break unless we're in a
 		    # no-break paragraph, or the previous line would
 		    # end up being a widow.
-		    $broken = 1 if ( $$linfo[0] !~ /$nobreakregexp/o &&
-				     $$pinfo[1] != 1 );
+		    $broken = $$linfo[0] !~ /$nobreakregexp/o &&
+			$$pinfo[1] != 1;
 		}
 		$i--;
 	    }
@@ -1066,7 +1075,7 @@ $need_fonts_str = join(' ', @need_fonts_lst);
 print "%!PS-Adobe-3.0\n";
 print "%%Pages: $curpage\n";
 print "%%BoundingBox: 0 0 ", $psconf{pagewidth}, ' ', $psconf{pageheight}, "\n";
-print "%%Creator: (NASM psflow.pl)\n";
+print "%%Creator: ", basename($0), "\n";
 print "%%DocumentData: Clean7Bit\n";
 print "%%DocumentFonts: $all_fonts_str\n";
 print "%%DocumentNeededFonts: $need_fonts_str\n";


More information about the Nasm-commits mailing list