texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/xspara.c (PRINTABLE_ASCII): New m


From: Gavin D. Smith
Subject: branch master updated: * tp/Texinfo/XS/xspara.c (PRINTABLE_ASCII): New macro. (xspara__add_next): Use btowc for printable ASCII bytes rather than mbrtowc.
Date: Sun, 09 Apr 2023 12:36:02 -0400

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

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new de7a2feb74 * tp/Texinfo/XS/xspara.c (PRINTABLE_ASCII): New macro. 
(xspara__add_next): Use btowc for printable ASCII bytes rather than mbrtowc.
de7a2feb74 is described below

commit de7a2feb7462b9bc0fbf1f6eec7ff623c8bbd973
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Apr 9 17:35:54 2023 +0100

    * tp/Texinfo/XS/xspara.c (PRINTABLE_ASCII): New macro.
    (xspara__add_next): Use btowc for printable ASCII bytes rather
    than mbrtowc.
---
 ChangeLog              |  6 ++++++
 tp/Texinfo/XS/xspara.c | 21 ++++++++++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f3fc8c9d6f..ed50a59577 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-04-09  Gavin Smith <gavinsmith0123@gmail.com>
+
+       * tp/Texinfo/XS/xspara.c (PRINTABLE_ASCII): New macro.
+       (xspara__add_next): Use btowc for printable ASCII bytes rather
+       than mbrtowc.
+
 2023-04-09  Gavin Smith <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/XS/parsetexi/debug.c (debug_print_element):
diff --git a/tp/Texinfo/XS/xspara.c b/tp/Texinfo/XS/xspara.c
index e0c2fa09ea..4d01751586 100644
--- a/tp/Texinfo/XS/xspara.c
+++ b/tp/Texinfo/XS/xspara.c
@@ -645,6 +645,9 @@ xspara_end (void)
     return "";
 }
 
+/* check if a byte is in the printable ASCII range */
+#define PRINTABLE_ASCII(c) (0x20 <= (c) && (c) <= 0x7E)
+
 /* Add WORD to paragraph in RESULT, not refilling WORD.  If we go past the end 
    of the line start a new one.  TRANSPARENT means that the letters in WORD
    are ignored for the purpose of deciding whether a full stop ends a sentence
@@ -688,10 +691,18 @@ xspara__add_next (TEXT *result, char *word, int word_len, 
int transparent)
 
               if (!strchr (".?!\"')", *p))
                 {
-                  wchar_t wc = L'\0';
-                  mbrtowc (&wc, p, len, NULL);
-                  state.last_letter = wc;
-                  break;
+                  if (!PRINTABLE_ASCII(*p))
+                    {
+                      wchar_t wc = L'\0';
+                      mbrtowc (&wc, p, len, NULL);
+                      state.last_letter = wc;
+                      break;
+                    }
+                  else
+                    {
+                      state.last_letter = btowc (*p);
+                      break;
+                    }
                 }
             }
         }
@@ -717,7 +728,7 @@ xspara__add_next (TEXT *result, char *word, int word_len, 
int transparent)
           int columns;
           int char_len;
 
-          if (0x20 <= *p && *p <= 0x7E) /* in printable ASCII range */
+          if (PRINTABLE_ASCII(*p))
             {
               len++; p++; left--;
               continue;



reply via email to

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