[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/xspara.c (xspara__add_next): Chec
From: |
Gavin D. Smith |
Subject: |
branch master updated: * tp/Texinfo/XS/xspara.c (xspara__add_next): Check return value for u8_mbtouc as documented, by checking for 0xfffd (replacement character), instead of using the same as mbrtowc. |
Date: |
Sat, 18 Nov 2023 16:35:52 -0500 |
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 ad43617b34 * tp/Texinfo/XS/xspara.c (xspara__add_next): Check return
value for u8_mbtouc as documented, by checking for 0xfffd (replacement
character), instead of using the same as mbrtowc.
ad43617b34 is described below
commit ad43617b34e52323e45ae3480f6b141f357c9b7f
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Nov 18 21:35:45 2023 +0000
* tp/Texinfo/XS/xspara.c (xspara__add_next): Check return value
for u8_mbtouc as documented, by checking for 0xfffd (replacement
character), instead of using the same as mbrtowc.
---
ChangeLog | 6 ++++++
tp/Texinfo/XS/xspara.c | 27 +++++++++------------------
2 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 98d9c335a1..44b1007e61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-11-18 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/XS/xspara.c (xspara__add_next): Check return value
+ for u8_mbtouc as documented, by checking for 0xfffd (replacement
+ character), instead of using the same as mbrtowc.
+
2023-11-18 Gavin Smith <gavinsmith0123@gmail.com>
* tp/Texinfo/XS/parsetexi/context_stack.c (pop_context):
diff --git a/tp/Texinfo/XS/xspara.c b/tp/Texinfo/XS/xspara.c
index e458aa4eae..ed0bea930d 100644
--- a/tp/Texinfo/XS/xspara.c
+++ b/tp/Texinfo/XS/xspara.c
@@ -548,24 +548,17 @@ xspara__add_next (TEXT *result, char *word, int word_len,
}
char_len = u8_mbtouc (&w, (uint8_t *) p, left);
- if (char_len == (size_t) -2) {
- /* unfinished multibyte character */
- char_len = left;
- } else if (char_len == (size_t) -1) {
- /* invalid character */
- char_len = 1;
- } else if (char_len == 0) {
- /* not sure what this means but we must avoid an infinite loop.
- Possibly only happens with invalid strings */
- char_len = 1;
- }
+ if (w == 0xfffd) /* bug - invalid string */
+ {
+ if (char_len <= 0)
+ char_len = 1; /* avoid an infinte loop */
+ }
left -= char_len;
+ p += char_len;
columns = uc_width (w, "UTF-8");
if (columns > 0)
len += columns;
-
- p += char_len;
}
state.word_counter += len;
}
@@ -736,12 +729,10 @@ xspara_add_text (char *text, int len)
char32_t wc;
next_len = u8_mbtouc (&wc, (uint8_t *) q, len);
- if ((long) next_len == 0)
- break; /* Null character. Shouldn't happen. */
- else if ((long) next_len < 0)
+ if (wc == 0xfffd) /* bug - invalid string */
{
- q++; len--; /* Invalid. Just try to keep going. */
- continue;
+ if (next_len <= 0)
+ next_len = 1; /* avoid an infinte loop */
}
/* Note: width == 0 includes accent characters. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/xspara.c (xspara__add_next): Check return value for u8_mbtouc as documented, by checking for 0xfffd (replacement character), instead of using the same as mbrtowc.,
Gavin D. Smith <=