texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/main/utils.c (width_multibyte): s


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/utils.c (width_multibyte): start counting from the last end of line if there is one, to get the same result as in Perl Unicode.pm string_width where count is reset at a newline.
Date: Sun, 31 Dec 2023 19:39:24 -0500

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 997de3d4b2 * tp/Texinfo/XS/main/utils.c (width_multibyte): start 
counting from the last end of line if there is one, to get the same result as 
in Perl Unicode.pm string_width where count is reset at a newline.
997de3d4b2 is described below

commit 997de3d4b2cd105b9c3270b5112ba39d6bb37e08
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jan 1 01:39:23 2024 +0100

    * tp/Texinfo/XS/main/utils.c (width_multibyte): start counting from
    the last end of line if there is one, to get the same result as in
    Perl Unicode.pm string_width where count is reset at a newline.
---
 ChangeLog                  | 6 ++++++
 tp/Texinfo/XS/main/utils.c | 6 +++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index d8e73dcb6c..1a41c167a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-12-31  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/utils.c (width_multibyte): start counting from
+       the last end of line if there is one, to get the same result as in
+       Perl Unicode.pm string_width where count is reset at a newline.
+
 2023-12-31  Gavin Smith <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/Convert/Plaintext.pm (_convert) <menu entries>:
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index a5817fbbce..31e167acf1 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -225,12 +225,16 @@ to_upper_or_lower_multibyte (const char *text, int 
lower_or_upper)
   return result;
 }
 
+/* end of line resets the count, same as in perl */
 int
 width_multibyte (const char *text)
 {
   int result;
+  const char *p = strrchr (text, '\n');
+  if (!p)
+    p = text;
   /* FIXME error checking? */
-  uint8_t *u8_text = u8_strconv_from_encoding (text, "UTF-8",
+  uint8_t *u8_text = u8_strconv_from_encoding (p, "UTF-8",
                                                  iconveh_question_mark);
   /* FIXME the libunistring documentation described encoding as
      The encoding argument identifies the encoding (e.g. "ISO-8859-2"



reply via email to

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