groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/01: Retain plain ascii labels when possible.


From: Deri James
Subject: [groff] 01/01: Retain plain ascii labels when possible.
Date: Sun, 14 Jan 2024 09:11:56 -0500 (EST)

deri pushed a commit to branch master
in repository groff.

commit e62b188aacb0669bf45628796dd543992e440047
Author: Deri James <deri@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)));
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]