deri pushed a commit to branch master in repository groff. commit 0f96f3a281d82bb0c1a59e5e819d2a22bede6c5d Author: Deri James <d...@chuzzlewit.myzen.co.uk> AuthorDate: Thu Apr 18 01:17:22 2024 +0100
[gropdf] Handle both types in one document. The different format of font described in previous commit fails if document contains fonts of both formats. The reason is because the regexes included the /o flag (compile once) for speed, but if the format changed (from RD to -|) in a different font, parsing failed. Now the regexes are compiled once for each font. * src/devices/gropdf/gropdf.pl: Use qr// to compile regexes once per font. --- ChangeLog | 14 ++++++++++++++ src/devices/gropdf/gropdf.pl | 9 ++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1cce0827d..a88d52c5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2024-04-17 Deri James <d...@chuzzlewit.myzen.co.uk> + + [gropdf] Handle both types in one document. + + The different format of font described in previous commit fails if + document contains fonts of both formats. The reason is because the + regexes included the /o flag (compile once) for speed, but if the + format changed (from RD to -|) in a different font, parsing failed. + + Now the regexes are compiled once for each font. + + * src/devices/gropdf/gropdf.pl: Use qr// to compile regexes once + per font. + 2024-04-17 Deri James <d...@chuzzlewit.myzen.co.uk> [gropdf] Improve font parsing. diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl index 240f1025c..59434a8ec 100644 --- a/src/devices/gropdf/gropdf.pl +++ b/src/devices/gropdf/gropdf.pl @@ -4601,6 +4601,7 @@ sub map_subrs my $stage=0; my $lin=$lines->[0]; my $i=0; + my ($RDre,$NDre); for (my $j=0; $j<=$#{$lines}; $lin=$lines->[++$j] ) { @@ -4612,6 +4613,8 @@ sub map_subrs { $sec{'#Subrs'}=$j; $stage=1; + $RDre=qr/\Q$RD\E/; + $NDre=qr/\Q$ND\E/; } elsif ($lin=~m/^\/(.+?)\s+\{string currentfile exch readstring pop\}\s*executeonly def/) { @@ -4638,7 +4641,7 @@ sub map_subrs $stage=2; $i=0; } - elsif ($lin=~m/^\s*dup\s+(\d+)\s+(\d+)\s+\Q$RD\E (.*)/os) + elsif ($lin=~m/^\s*dup\s+(\d+)\s+(\d+)\s+$RDre (.*)/s) { my $n=$1; my $l=$2; @@ -4666,7 +4669,7 @@ sub map_subrs # subs_call($s,"#$n"); $lines->[$i]=["#$n",$l,$s,$NP]; } - elsif ($lin=~m/^\Q$ND\E/o) + elsif ($lin=~m/^$NDre/) {} else { @@ -4680,7 +4683,7 @@ sub map_subrs $sec{'#Pad'}=$j; $stage=3; } - elsif ($lin=~m/^\s*\/([-.\w]*)\s+(\d+)\s+\Q$RD\E (.*)/os) + elsif ($lin=~m/^\s*\/([-.\w]*)\s+(\d+)\s+$RDre (.*)/s) { my $n=$1; my $l=$2; _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit