[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/xspara.c (xspara_add_text): Proce
From: |
Gavin D. Smith |
Subject: |
branch master updated: * tp/Texinfo/XS/xspara.c (xspara_add_text): Process multiple space characters together, in order to more closely match the execution order of the Perl code. (xspara__print_escaped_spaces): Take length argument. (debug): Declare as static. |
Date: |
Wed, 25 Oct 2023 14:06:25 -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 ca85ec57d2 * tp/Texinfo/XS/xspara.c (xspara_add_text): Process
multiple space characters together, in order to more closely match the
execution order of the Perl code. (xspara__print_escaped_spaces): Take length
argument. (debug): Declare as static.
ca85ec57d2 is described below
commit ca85ec57d2d0122c08f422607c61a5cac90c5df7
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Wed Oct 25 19:06:17 2023 +0100
* tp/Texinfo/XS/xspara.c (xspara_add_text): Process multiple
space characters together, in order to more closely match the
execution order of the Perl code.
(xspara__print_escaped_spaces): Take length argument.
(debug): Declare as static.
---
ChangeLog | 8 ++++++++
tp/Texinfo/XS/xspara.c | 25 ++++++++++++-------------
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ac4e73f3a3..0485f21b49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-10-25 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/XS/xspara.c (xspara_add_text): Process multiple
+ space characters together, in order to more closely match the
+ execution order of the Perl code.
+ (xspara__print_escaped_spaces): Take length argument.
+ (debug): Declare as static.
+
2023-10-25 Gavin Smith <gavinsmith0123@gmail.com>
* tp/t/02coverage.t (commands_in_math): Remove trailing space on
diff --git a/tp/Texinfo/XS/xspara.c b/tp/Texinfo/XS/xspara.c
index 703f669d1b..2cb2dd90e2 100644
--- a/tp/Texinfo/XS/xspara.c
+++ b/tp/Texinfo/XS/xspara.c
@@ -48,7 +48,7 @@
#include "xspara_text.h"
-int debug = 0;
+static int debug = 0;
typedef struct {
TEXT space; /* Pending space, to be output before the pending word. */
@@ -238,12 +238,12 @@ iswupper (wint_t wi)
/* for debug */
char *
-xspara__print_escaped_spaces (char *string)
+xspara__print_escaped_spaces (char *string, size_t len)
{
static TEXT t;
char *p = string;
text_reset (&t);
- while (*p)
+ while (p < string + len)
{
if (*p == ' ')
text_append_n (&t, p, 1);
@@ -899,7 +899,8 @@ xspara_add_text (char *text, int len)
fprintf(stderr, "p (%d+%d) s `%s', l `%lc', w `%s'\n",
state.counter, state.word_counter,
state.space.end == 0 ? ""
- : xspara__print_escaped_spaces (state.space.text),
+ : xspara__print_escaped_spaces (state.space.text,
+ state.space.end),
state.last_letter,
state.word.end > 0 ? state.word.text : "UNDEF");
}
@@ -975,7 +976,7 @@ xspara_add_text (char *text, int len)
/* TODO: test just one character at a time to start. then
we can gradually work on the various blocks of
code to operate on multiple characters. */
- if ((type != type_regular)
+ if ((type != type_regular && type != type_spaces)
|| next_type != type || next_type == type_finished)
break;
@@ -997,25 +998,22 @@ xspara_add_text (char *text, int len)
{
if (debug)
{
- char t[2];
- t[0] = *p;
- t[1] = '\0';
fprintf(stderr, "SPACES(%d) `%s'\n", state.counter,
- xspara__print_escaped_spaces (t));
+ xspara__print_escaped_spaces (p, q - p));
}
if (state.unfilled)
{
xspara__add_pending_word (&result, 0);
- if (*p == '\n')
+ if (memchr (p, '\n', q - p))
{
xspara__end_line ();
text_append (&result, "\n");
}
else
{
- text_append_n (&state.space, p, 1);
- state.space_counter++;
+ text_append_n (&state.space, p, q - p);
+ state.space_counter += q - p;
}
}
else if (state.no_break)
@@ -1078,7 +1076,8 @@ xspara_add_text (char *text, int len)
xspara__cut_line (&result);
}
- if (!state.unfilled && *p == '\n' && state.keep_end_lines)
+ if (!state.unfilled && state.keep_end_lines
+ && memchr (p, '\n', q - p))
{
xspara__end_line ();
text_append (&result, "\n");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/xspara.c (xspara_add_text): Process multiple space characters together, in order to more closely match the execution order of the Perl code. (xspara__print_escaped_spaces): Take length argument. (debug): Declare as static.,
Gavin D. Smith <=