texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/Unicode.pm (string_width): r


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/Unicode.pm (string_width): replace IsPrint by more explicit character classes.
Date: Fri, 08 Sep 2023 13:08:48 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 1144063467 * tp/Texinfo/Convert/Unicode.pm (string_width): replace 
IsPrint by more explicit character classes.
1144063467 is described below

commit 1144063467b1d3af0af2a69172830ba3377a616c
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Sep 8 19:08:39 2023 +0200

    * tp/Texinfo/Convert/Unicode.pm (string_width): replace IsPrint
    by more explicit character classes.
---
 ChangeLog                     | 5 +++++
 tp/Texinfo/Convert/Unicode.pm | 9 ++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cac40be18c..50fbd7e044 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-09-08  Patrice Dumas <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Unicode.pm (string_width): replace IsPrint
+       by more explicit character classes.
+
 2023-09-07  Patrice Dumas <pertusus@free.fr>
 
        * tp/Texinfo/Convert/Unicode.pm (string_width): use
diff --git a/tp/Texinfo/Convert/Unicode.pm b/tp/Texinfo/Convert/Unicode.pm
index c2b1355b4a..7e20d53825 100644
--- a/tp/Texinfo/Convert/Unicode.pm
+++ b/tp/Texinfo/Convert/Unicode.pm
@@ -1669,7 +1669,8 @@ sub string_width($)
   # DefaultIgnorableCodePoint is documented in perl 5.10.1. In 2023 perl,
   # it is Default_Ignorable_Code_Point, but DefaultIgnorableCodePoint
   # seems to work too.
-  if ($string =~ /^[\p{IsPrint}]*$/
+  #if ($string =~ /^[\p{IsPrint}]*$/
+  if ($string =~ /^[\p{L}\p{N}\p{P}\p{S}\p{Zs}]*$/
       and $string !~ /[\p{InFullwidth}\pM\p{DefaultIgnorableCodePoint}]/) {
     return length($string);
   }
@@ -1677,7 +1678,8 @@ sub string_width($)
   $string =~ s/\p{InFullwidth}/\x{02}/g;
   $string =~ s/\pM/\x{00}/g;
   $string =~ s/\p{DefaultIgnorableCodePoint}/\x{00}/g;
-  $string =~ s/\p{IsPrint}/\x{01}/g;
+  #$string =~ s/\p{IsPrint}/\x{01}/g;
+  $string =~ s/[\p{L}\p{N}\p{P}\p{S}\p{Zs}]/\x{01}/g;
   $string =~ s/[^\x{01}\x{02}]/\x{00}/g;
 
   # This sums up the byte values of the bytes in $string, which now are
@@ -1695,7 +1697,8 @@ sub string_width($)
     } elsif ($character =~ /[\pM\p{DefaultIgnorableCodePoint}]/) {
       # a mark set at length 0 or a Default Ignorable Code Point
       # that have no visible glyph or advance width in and of themselves
-    } elsif ($character =~ /\p{IsPrint}/) {
+    #} elsif ($character =~ /\p{IsPrint}/) {
+    } elsif ($character =~ /[\p{L}\p{N}\p{P}\p{S}\p{Zs}]/) {
       $width += 1;
     } elsif ($character =~ /\p{IsControl}/) {
       # Control chars may be added, for instance, as part of @image formatting



reply via email to

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