deri pushed a commit to branch master
in repository groff.

commit e62b188aacb0669bf45628796dd543992e440047
Author: Deri James <d...@chuzzlewit.myzen.co.uk>
AuthorDate: Sun Jan 14 13:57:30 2024 +0000

    Retain plain ascii labels when possible.
    
    * src/devices/gropdf/gropdf.pl: Do not use hexed label unless
    necessary.
    
    Restores the ability for some pdf viewers to accept "#label" as
    suffix to filename.
---
 src/devices/gropdf/gropdf.pl | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl
index 870eca5e8..f0b04909a 100644
--- a/src/devices/gropdf/gropdf.pl
+++ b/src/devices/gropdf/gropdf.pl
@@ -2002,6 +2002,7 @@ sub Clean
 sub utf16
 {
     my $p=Clean(shift);
+    my $label=shift;
 
     $p=~s/\\\[(.*?)\]/FindChr($1,0)/eg;
     $p=~s/\\C($parcln)/FindChr($1,1)/eg;
@@ -2014,6 +2015,8 @@ sub utf16
             unpack "C*", encode('utf16', $p);
     }
 
+    return($p) if $label;
+
     $p=~s/(?<!\\)\(/\\\(/g;
     $p=~s/(?<!\\)\)/\\\)/g;
 
@@ -2059,14 +2062,19 @@ sub UTFName
     my $r='';
 
     $s=substr($s,1);
-    return '/'.join '', map { MakeLabel($_) } unpack('C*',$s);
+    my $s1=$s;
+    $s1=~s/([[:xdigit:]]{2})/chr(hex($1))/eg;
+    my $s2=utf16($s1,1);
+#    return "/".MakeLabel((substr($s2,0,1) eq '/')?$s:$s2);
+    my $s3='/'.join '', map { MakeLabel($_) } unpack('C*',(substr($s2,0,1) eq 
'\\')?$s:$s2);
+    return $s3;
 
 }
 
 sub MakeLabel
 {
     my $c=chr(shift);
-    return($c) if $c=~m/[\w:]/;
+    return($c) if ($c=~m/[\w\d:]/);
     return(sprintf("#%02x",ord($c)));
 }
 

_______________________________________________
Groff-commit mailing list
Groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to