Hi Branden, After applying Deri's patches, I can see the turtle. real 2m20.018s user 2m34.825s sys 0m0.571s Before that patch, it's real 0m14.576s user 0m18.171s sys 0m0.464s That means groff(1) is being ~9x slower. Have a lovely night! Alex On Tue, Apr 16, 2024 at 01:14:12AM +0100, Deri wrote: > diff --git a/tmac/an.tmac b/tmac/an.tmac > index d9e8232f8..46934fd62 100644 > --- a/tmac/an.tmac > +++ b/tmac/an.tmac > @@ -212,7 +212,7 @@ > . > .\" Customize this at the command line to, for example, group multiple > .\" man pages within a collection or containing document. > -.nr an*bookmark-base-level 0 > +.nr an*bookmark-base-level \n[an*bookmark-base-level]+0 > . > .\" Write a bookmark/anchor/link target $2 at hierarchical depth $1. > .de an*bookmark > @@ -230,7 +230,8 @@ > .ds an*bookmark*utf8 \" empty > . > .de an*bookmark*pdf > -. ie (\\$1 = 1) \ > +.nr an:lev \\n[an*bookmark-base-level]+1 > +. ie (\\$1 = \\n[an:lev]) \ > . pdfbookmark -T "\\$2" \\$1 \\$2 > . el \ > . pdfbookmark \\$1 \\$2 > diff --git a/share/mk/build/pdf/book/_.mk b/share/mk/build/pdf/book/_.mk > index 3395e67e9..9f1cdc520 100644 > --- a/share/mk/build/pdf/book/_.mk > +++ b/share/mk/build/pdf/book/_.mk > @@ -33,12 +33,12 @@ _PDF_BOOK := $(_PDFDIR)/$(PDF_BOOK) > $(_PDF_BOOK): $(_MANPAGES) $(_TINOS) $(MKBOOK) $(MK) | $$(@D)/ > $(info $(INFO_)GROPDF $@) > $(MKBOOKDIR)/prepare.pl $(_MANDIR) \ > - | $(CAT) $(MKBOOKDIR)/front.roff $(MKBOOKDIR)/an.tmac /dev/stdin \ > + | $(CAT) $(MKBOOKDIR)/front.roff /dev/stdin \ > | $(PRECONV) \ > | $(PIC) \ > | $(TBL) \ > | $(EQN) -Tpdf \ > - | $(TROFF) -Tpdf -F$(_FONTSDIR) -dpaper=a4 $(TROFFFLAGS) \ > + | pdfmom --roff -F$(_FONTSDIR) -man -r an*bookmark-base-level=1 -dpaper=a4 $(TROFFFLAGS) -Z \ > | $(GROPDF) -F$(_FONTSDIR) -pa4 $(GROPDFFLAGS) \ > | $(SPONGE) $@ > > diff --git a/share/mk/build/pdf/book/prepare.pl b/share/mk/build/pdf/book/prepare.pl > index e23f149c6..bc922bd88 100755 > --- a/share/mk/build/pdf/book/prepare.pl > +++ b/share/mk/build/pdf/book/prepare.pl > @@ -1,4 +1,4 @@ > -#!/usr/bin/perl -w > +#!/usr/bin/perl -wd > # > # BuildLinuxMan.pl : Build Linux manpages book > # Deri James (& Brian Inglis) : 15 Dec 2022 > @@ -49,16 +49,16 @@ my $dir2=$dir; > $dir2=~tr[.][_]; > my %files; > my %aliases; > -my %target; > +my %revalias; > > foreach my $al (`find "$dir"/man*/ -type f \\ > | grep "\\.[[:digit:]]\\([[:alpha:]][[:alnum:]]*\\)\\?\\>\$" \\ > | xargs grep '^\\.so' /dev/null;`) > { > #$al=~tr[.][_]; > - $al=~m/^$dir\/man\d[a-z]*\/(.*):\.\s*so\s*man\d[a-z]*\/(.*)/o; > + $al=~m/^$dir\/man\d[a-z]*\/(.*):\.\s*so\s*man\d[a-z]*\/(.*?)\.(.*)/o; > > - $aliases{$1}=$2; > + $aliases{$1}="$2($3)"; > } > > while (my ($k,$v)=each %aliases) > @@ -68,13 +68,18 @@ while (my ($k,$v)=each %aliases) > } > } > > +while (my ($k,$v)=each %aliases) > +{ > + push(@{$revalias{$v}},$k); > +} > + > foreach my $fn (`find "$dir"/man*/ -type f \\ > | grep "\\.[[:digit:]]\\([[:alpha:]][[:alnum:]]*\\)\\?\\>\$";`) > { > $fn=~s/\n//; > > my ($nm,$sec)=GetNmSec($fn,qr/\.\d[a-z]*/); > - $files{"${nm}.$sec"}=[$fn,(exists($aliases{"${nm}.$sec"}))?$aliases{"${nm}.$sec"}:"${nm}.$sec"]; > + $files{"${nm}.$sec"}=[$fn,(exists($aliases{"${nm}.$sec"}))?$aliases{"${nm}.$sec"}:"${nm}($sec)"]; > } > > my $Section=''; > @@ -97,7 +102,7 @@ sub BuildPage > my $fn=$files{$bkmark}->[0]; > my ($nm,$sec,$srt)=GetNmSec($bkmark,qr/\.[\da-z]+/); > > - my $title= "$nm\\($sec\\)"; > + my $title= "$nm($sec)"; > > print ".\\\" >>>>>> $nm($sec) <<<<<<\n.lf 0 $bkmark\n"; > > @@ -112,8 +117,10 @@ sub BuildPage > $Section=$sec; > } > > - if (exists($aliases{$bkmark})) { > + if (exists($aliases{$bkmark})) > + { > print ".eo\n.device ps:exec [/Dest /$aliases{$bkmark} /Title ($title) /Level 2 /OUT pdfmark\n.ec\n.fl\n"; > +# print ".pdfbookmark 2 $nm($sec)"; > return; > } > > @@ -137,7 +144,7 @@ sub BuildPage > > s/\\-/-/g if /^\.[BM]R\s+/; > > - if (m/^\.BR\s+([-\w\\.]+)\s+\((.+?)\)(.*)/ or m/^\.MR\s+([-\w\\.]+)\s+(\w+)\s+(.*)/ or m/^\\fB([-\w\\.]+)\\fR\((.+?)\)(.*)$/) { > + if (m/^\.BR\s+([-\w\\.]+)\s+\(([\d\w]+?)\)(.*)/ or m/^\.MR\s+([-\w\\.]+)\s+(\w+)\s+(.*)/ or m/^\\fB([-\w\\.]+)\\fR\((.+?)\)(.*)$/) { > my $bkmark="$1"; > my $sec=$2; > my $after=$3; > @@ -145,12 +152,7 @@ sub BuildPage > my $dest=$bkmark; > $dest=~s/\\-/-/g; > > - if (exists($files{"${bkmark}.$sec"})) { > - my $dest=$files{"${bkmark}.$sec"}->[1]; > - $_=".pdfhref L -D \"$dest\" -A \"$after\" -- \\fI$bkmark\\fP($sec)"; > - } else { > - $_=".IR $bkmark ($sec)\\c\n$after"; > - } > + $_=".MR \"$bkmark\" $sec $after"; > } > > s/^\.BI \\fB/.BI /; > @@ -175,16 +177,20 @@ sub BuildPage > s/\n\n/\n/g; > } > > - s/\\&\././ if m/^.TH /; > - > - if (m/^\.TH\s+"?([-\w\\.]+)"?\s+"?(\w+)"?/) { > - > - print "$_\n"; > - > - # Add a level two bookmark. We don't set it in the TH macro since the name passed > - # may be different from the filename, i.e. file = unimplemented.2, TH = UNIMPLEMENTED 2 > - > - print ".pdfbookmark -T $bkmark 2 $nm($sec)\n"; > +# s/\\&\././ if m/^.TH /; > +# > + if (m/^\.TH\s+"?([-\w\\.]+)"?\s+"?(\w+)"?(.*)/) > + { > + print ".TH \"$nm\" \"$2\" $3\n"; > + > + if (exists($revalias{"$nm($sec)"})) > + { > + foreach my $dest (@{$revalias{"$nm($sec)"}}) > + { > + my ($nm,$sec,$srt)=GetNmSec($dest,qr/\.[\da-z]+/); > + print ".pdfhref M -D $nm($sec)\n"; > + } > + } > > next; > } > @@ -199,11 +205,8 @@ sub doMR > my $nm=shift; > my $sec=shift; > > - if (exists($files{"${nm}.$sec"})) { > - return("\n.pdfhref L -D \"$files{\"${nm}.$sec\"}->[1]\" -A \"\\c\" -- \\fI$nm\\fP($sec)\n"); > - } else { > - return("\\fI$nm\\fP($sec)"); > - } > + return "\n.MR $nm $sec"; > + > } > > sub GetNmSec -- <https://www.alejandro-colomar.es/>
Attachment:
signature.asc
Description: PGP signature