[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Sat, 15 Jul 2023 12:19:47 -0400 (EDT) |
branch: master
commit 9d46dc85109d951b6f28ab1145a44442d3788a05
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Jul 15 17:13:26 2023 +0100
* tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line)
<accent commands>: Count UTF-8 continuation bytes for character
following accent command. Report from Patrice.
---
ChangeLog | 6 ++++++
tp/Texinfo/XS/parsetexi/parser.c | 14 ++++++++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 379d088f49..e4d53b3a62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-07-15 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line)
+ <accent commands>: Count UTF-8 continuation bytes for character
+ following accent command. Report from Patrice.
+
2023-07-15 Patrice Dumas <pertusus@free.fr>
* tp/Makefile.tres, tp/t/formats_encodings.t: add
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 938dff77a7..4b8639419f 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -2031,13 +2031,20 @@ process_remaining_on_line (ELEMENT **current_inout,
char **line_inout)
&& *line != '@')
{
ELEMENT *e, *e2;
+ int char_len;
+
if (current->contents.number > 0)
gather_spaces_after_cmd_before_arg (current);
e = new_element (ET_following_arg);
add_to_element_args (current, e);
+
+ /* Count any UTF-8 continuation bytes. */
+ char_len = 1;
+ while ((line[char_len] & 0xC0) == 0x80)
+ char_len++;
+
e2 = new_element (ET_NONE);
- /* FIXME what if the next character is not ASCII? */
- text_append_n (&e2->text, line, 1);
+ text_append_n (&e2->text, line, char_len);
debug ("ACCENT @%s following_arg: %s", command_name(current->cmd),
e2->text.text);
add_to_element_contents (e, e2);
@@ -2045,11 +2052,10 @@ process_remaining_on_line (ELEMENT **current_inout,
char **line_inout)
if (current->cmd == CM_dotless
&& *line != 'i' && *line != 'j')
{
- /* TODO may show a partial character if non-ascii */
line_error ("@dotless expects `i' or `j' as argument, "
"not `%c'", *line);
}
- line++;
+ line += char_len;
current = current->parent;
}
else