[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 28 Sep 2024 15:54:37 -0400 (EDT) |
branch: master
commit e0985097c6f62b741dfa15c35ff1dc758732b23f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jun 1 09:46:32 2024 +0200
* tp/Texinfo/XS/main/element_types.txt: add more text flags for text
elements.
* tp/Texinfo/XS/main/manipulate_tree.c (copy_tree_internal): text
elements may have inserted info set, so copy info.
* tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash):
reorganize to take into account that text element do not args nor
contents nor extras.
* tp/Texinfo/XS/parsetexi/parser.c (isolate_trailing_space)
(isolate_last_space, process_remaining_on_line): pass last contents
element as isolate_trailing_space argument.
* tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash),
tp/Texinfo/XS/parsetexi/parser.c (check_space_element)
(text_contents_to_plain_text, merge_text, isolate_trailing_space),
(process_remaining_on_line), tp/Texinfo/XS/parsetexi/source_marks.c
(place_source_mark): use type flags to determine if an element
is a text element.
---
ChangeLog | 23 ++++++++++
tp/TODO | 21 +--------
tp/Texinfo/XS/main/build_perl_info.c | 21 +++++----
tp/Texinfo/XS/main/element_types.txt | 16 +++----
tp/Texinfo/XS/main/manipulate_tree.c | 1 +
tp/Texinfo/XS/parsetexi/parser.c | 78 +++++++++++++++-------------------
tp/Texinfo/XS/parsetexi/source_marks.c | 4 +-
7 files changed, 84 insertions(+), 80 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3f314629d3..85f1dda97d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,29 @@
* NEWS, doc/info-stnd.texi (Custom Key Bindings): update.
+2024-05-31 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/element_types.txt: add more text flags for text
+ elements.
+
+ * tp/Texinfo/XS/main/manipulate_tree.c (copy_tree_internal): text
+ elements may have inserted info set, so copy info.
+
+ * tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash):
+ reorganize to take into account that text element do not args nor
+ contents nor extras.
+
+ * tp/Texinfo/XS/parsetexi/parser.c (isolate_trailing_space)
+ (isolate_last_space, process_remaining_on_line): pass last contents
+ element as isolate_trailing_space argument.
+
+ * tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash),
+ tp/Texinfo/XS/parsetexi/parser.c (check_space_element)
+ (text_contents_to_plain_text, merge_text, isolate_trailing_space),
+ (process_remaining_on_line), tp/Texinfo/XS/parsetexi/source_marks.c
+ (place_source_mark): use type flags to determine if an element
+ is a text element.
+
2024-05-31 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/element_types.awk: order correctly the types.
diff --git a/tp/TODO b/tp/TODO
index d918eb4708..0786caee87 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -91,28 +91,11 @@ ELEMENT *elements[3]
4) separate the structure of text elements and other elements, as text elements
never have contents/args/info/extra, have cmd != 0.
EXCEPTION: needed transient _copy and _counter in copy_tree_internal in
extra
+ EXCEPTION: info inserted for spaces in @def* for definition aliases
- if (content->type != ET_normal_text)
- fprintf (stderr, "TTT %s\n", print_element_debug (content, 1));
-
-
-parsetexi
- close.c
- is_container_empty: (all text types) current->text.end == 0
- debug_parser.c
- print_element_debug_parser e->text.end > 0
- parser.c
- merge_text last_element->text.space > 0
- check_space_element e->text.space > 0
- text_contents_to_plain_text e1->text.end > 0
- isolate_last_space text_len = last_elt->text.end; text_len <= 0
- process_remaining_on_line && last_contents_child (current)->text.end > 0
- source_marks.c
- place_source_mark last_child->text.end > 0
-
+type_data[->type].flags & TF_text
main
build_perl_info.c
- element_to_perl_hash e->text.space > 0
extra_misc_args contents.list[j]->text.end > 0
convert_to_texinfo.c
convert_to_texinfo_internal e->text.end > 0
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index ab628aa116..41ad4926e0 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -34,6 +34,7 @@
#include "command_ids.h"
#include "element_types.h"
+#include "types_data.h"
#include "tree_types.h"
#include "global_commands_types.h"
/* for GLOBAL_INFO ERROR_MESSAGE */
@@ -609,12 +610,23 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
hv_store (e->hv, "parent", strlen ("parent"), sv, HSH_parent);
}
+ store_source_mark_list (e);
+
if (e->type && e->type != ET_normal_text && e->type != ET_other_text)
{
sv = newSVpv (element_type_names[e->type], 0);
hv_store (e->hv, "type", strlen ("type"), sv, HSH_type);
}
+ store_additional_info (e, &e->info_info, "info", avoid_recursion);
+
+ if (type_data[e->type].flags & TF_text)
+ {
+ sv = newSVpv_utf8 (e->text.text, e->text.end);
+ hv_store (e->hv, "text", strlen ("text"), sv, HSH_text);
+ return;
+ }
+
if (e->cmd)
{
sv = newSVpv (element_command_name (e), 0);
@@ -668,14 +680,7 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
}
}
- if (e->text.space > 0)
- {
- sv = newSVpv_utf8 (e->text.text, e->text.end);
- hv_store (e->hv, "text", strlen ("text"), sv, HSH_text);
- }
-
store_additional_info (e, &e->extra_info, "extra", avoid_recursion);
- store_additional_info (e, &e->info_info, "info", avoid_recursion);
if (e->associated_unit)
{
@@ -691,8 +696,6 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
}
}
- store_source_mark_list (e);
-
if (e->source_info.line_nr)
{
#define STORE(key, sv, hsh) hv_store (hv, key, strlen (key), sv, hsh)
diff --git a/tp/Texinfo/XS/main/element_types.txt
b/tp/Texinfo/XS/main/element_types.txt
index 5cf9bd65a0..42abd691d9 100644
--- a/tp/Texinfo/XS/main/element_types.txt
+++ b/tp/Texinfo/XS/main/element_types.txt
@@ -54,7 +54,7 @@ brace_command_arg
brace_command_context
block_line_arg
line_arg
-rawline_arg
+rawline_arg text
menu_entry
menu_entry_leading_text text
@@ -70,8 +70,8 @@ internal_spaces_before_argument text
internal_spaces_before_brace_in_index text
internal_spaces_after_cmd_before_arg text
-macro_name
-macro_arg
+macro_name text
+macro_arg text
before_item
table_entry
table_term
@@ -86,7 +86,7 @@ multitable_body
row
balanced_braces
bracketed_arg
-bracketed_linemacro_arg
+bracketed_linemacro_arg text
# container of definition line argument content
def_line_arg
@@ -104,10 +104,10 @@ def_typearg
def_arg
# text for def commands, definition line direct arguments
-delimiter
-spaces
+delimiter text
+spaces text
# type of text element inserted in untranslated_def_line_arg
-untranslated
+untranslated text
# for unexpanded parts of conditionals
elided_rawpreformatted
@@ -124,7 +124,7 @@ text
# for HTML converter
_code
-_converted
+_converted text
_string
# not in parser, for virtual element associated to special output units
diff --git a/tp/Texinfo/XS/main/manipulate_tree.c
b/tp/Texinfo/XS/main/manipulate_tree.c
index dcade5d597..ce4966d7f6 100644
--- a/tp/Texinfo/XS/main/manipulate_tree.c
+++ b/tp/Texinfo/XS/main/manipulate_tree.c
@@ -176,6 +176,7 @@ copy_tree_internal (ELEMENT* current, ELEMENT *parent)
if (current->text.space > 0)
{
text_append (&new->text, current->text.text);
+ copy_associated_info (¤t->extra_info, &new->extra_info);
return new;
}
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index e9755e76e6..cfbd12b0da 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -23,6 +23,7 @@
#include "element_types.h"
#include "tree_types.h"
#include "global_commands_types.h"
+#include "types_data.h"
#include "tree.h"
#include "extra.h"
#include "builtin_commands.h"
@@ -173,7 +174,7 @@ check_space_element (ELEMENT *e)
|| e->cmd == CM_c
|| e->cmd == CM_comment
|| e->cmd == CM_COLON
- || (e->text.space > 0
+ || (type_data[e->type].flags & TF_text
&& (e->text.end == 0
|| !*(e->text.text + strspn (e->text.text, whitespace_chars))))
))
@@ -201,8 +202,8 @@ text_contents_to_plain_text (ELEMENT *e, int
*superfluous_arg)
text_init (&result);
for (i = 0; i < e->contents.number; i++)
{
- ELEMENT *e1 = contents_child_by_index (e, i);
- if (e1->text.end > 0)
+ const ELEMENT *e1 = contents_child_by_index (e, i);
+ if (type_data[e1->type].flags & TF_text && e1->text.end > 0)
ADD(e1->text.text);
else if (e1->cmd == CM_AT_SIGN
|| e1->cmd == CM_atchar)
@@ -732,23 +733,10 @@ merge_text (ELEMENT *current, const char *text, size_t
len_text,
last_element = last_contents_child (current);
if (!no_merge_with_following_text
&& last_element
- /* There is a difference between the text being defined and empty,
- and not defined at all. The latter is true for 'brace_command_arg'
- elements. We need either to make sure that we initialize all elements
- with text_append (&e->text, "") where we want merging with following
- text, or treat as a special case here. */
- && (last_element->text.space > 0
- && !strchr (last_element->text.text, '\n')))
- {
- /*
- if (last_element->type != ET_normal_text && last_element->type !=
ET_empty_line
- && last_element->type != ET_ignorable_spaces_after_command
- && last_element->type != ET_internal_spaces_after_command
- && last_element->type != ET_internal_spaces_before_argument
- && last_element->type != ET_spaces_after_close_brace)
- fprintf (stderr, "EEE %s '%s'\n",
element_type_names[last_element->type],
- last_element->text.text);
- */
+ /* can actually be normal_text, and some space elements */
+ && type_data[last_element->type].flags & TF_text
+ && !strchr (last_element->text.text, '\n'))
+ {
/* Transfer source marks */
if (transfer_marks_element
&& transfer_marks_element->source_mark_list.number > 0)
@@ -872,7 +860,7 @@ abort_empty_line (ELEMENT **current_inout)
return retval;
}
-/* The caller verifies that the element is a text element */
+/* The caller verifies that last_elt is a text element */
static void
isolate_last_space_internal (ELEMENT *current, ELEMENT *last_elt)
{
@@ -921,18 +909,13 @@ isolate_last_space_internal (ELEMENT *current, ELEMENT
*last_elt)
}
}
-/* The callers verify that the last_elt is a text element */
+/* The caller verifies that last_elt is a text element */
static void
-isolate_trailing_space (ELEMENT *current, enum element_type spaces_type)
+isolate_trailing_space (ELEMENT *current, ELEMENT *last_elt,
+ enum element_type spaces_type)
{
- ELEMENT *last_elt;
- char *text;
- int text_len;
+ char *text = last_elt->text.text;
- last_elt = last_contents_child (current);
- text = element_text (last_elt);
-
- text_len = last_elt->text.end;
/* If text all whitespace */
if (text[strspn (text, whitespace_chars)] == '\0')
@@ -943,6 +926,7 @@ isolate_trailing_space (ELEMENT *current, enum element_type
spaces_type)
{
ELEMENT *new_spaces;
int i, trailing_spaces;
+ int text_len = last_elt->text.end;
trailing_spaces = 0;
for (i = text_len - 1;
@@ -988,6 +972,9 @@ isolate_last_space (ELEMENT *current)
last_elt = last_contents_child (current);
+ if (!(type_data[last_elt->type].flags & TF_text))
+ goto no_isolate_space;
+
text_len = last_elt->text.end;
if (text_len <= 0)
goto no_isolate_space;
@@ -1002,7 +989,7 @@ isolate_last_space (ELEMENT *current)
debug_parser_print_element (last_elt, 0); debug ("");
if (current->type == ET_menu_entry_node)
- isolate_trailing_space (current, ET_space_at_end_menu_node);
+ isolate_trailing_space (current, last_elt, ET_space_at_end_menu_node);
else
isolate_last_space_internal (current, last_elt);
@@ -2309,25 +2296,30 @@ process_remaining_on_line (ELEMENT **current_inout,
const char **line_inout)
|| cmd == CM_seealso
|| cmd == CM_subentry)
&& current->contents.number > 0
- && last_contents_child (current)->text.end > 0
/* it is important to check if in an index command, as otherwise
the internal space type is not processed and remains as is in
the final tree. */
&& (command_flags(current->parent) & CF_index_entry_command
|| current->parent->cmd == CM_subentry))
{
- if (cmd == CM_subentry)
- {
- isolate_trailing_space (current, ET_spaces_at_end);
- }
- else
- /* an internal and temporary space type that is converted to
- a normal space without type if followed by text or a
- "spaces_at_end" if followed by spaces only when the
- index or subentry command is done. */
+ ELEMENT *last_elt = last_contents_child (current);
+
+ if (last_elt && type_data[last_elt->type].flags & TF_text
+ && last_elt->text.end > 0)
{
- isolate_trailing_space (current,
-
ET_internal_spaces_before_brace_in_index);
+ if (cmd == CM_subentry)
+ {
+ isolate_trailing_space (current, last_elt, ET_spaces_at_end);
+ }
+ else
+ /* an internal and temporary space type that is converted to
+ a normal space without type if followed by text or a
+ "spaces_at_end" if followed by spaces only when the
+ index or subentry command is done. */
+ {
+ isolate_trailing_space (current, last_elt,
+ ET_internal_spaces_before_brace_in_index);
+ }
}
}
diff --git a/tp/Texinfo/XS/parsetexi/source_marks.c
b/tp/Texinfo/XS/parsetexi/source_marks.c
index 34c7d76342..ff0fef86d2 100644
--- a/tp/Texinfo/XS/parsetexi/source_marks.c
+++ b/tp/Texinfo/XS/parsetexi/source_marks.c
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include "tree_types.h"
+#include "types_data.h"
#include "tree.h"
/* for count_multibyte and other */
#include "utils.h"
@@ -63,7 +64,8 @@ place_source_mark (ELEMENT *e, SOURCE_MARK *source_mark)
{
ELEMENT *last_child = last_contents_child (e);
mark_element = last_child;
- if (last_child->text.end > 0)
+ if (type_data[last_child->type].flags & TF_text
+ && last_child->text.end > 0)
source_mark->position = count_multibyte (last_child->text.text);
}
else
- master updated (2947533e23 -> ff6bdbe123), Patrice Dumas, 2024/09/28
- [no subject], Patrice Dumas, 2024/09/28
- [no subject], Patrice Dumas, 2024/09/28
- [no subject],
Patrice Dumas <=
- [no subject], Patrice Dumas, 2024/09/28
- [no subject], Patrice Dumas, 2024/09/28
- [no subject], Patrice Dumas, 2024/09/28