[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/parsetexi/end_line.c (end_line_de
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line): move end_line_def_line definition up in the file to be before the functions using it. |
Date: |
Sun, 05 Mar 2023 07:19:26 -0500 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 0703a64a49 * tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line):
move end_line_def_line definition up in the file to be before the functions
using it.
0703a64a49 is described below
commit 0703a64a490949cc9eabf707dce8d5be0533937d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Mar 5 13:19:17 2023 +0100
* tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line): move
end_line_def_line definition up in the file to be before the functions
using it.
* tp/Texinfo/XS/parsetexi/end_line.c, tp/Texinfo/XS/parsetexi/labels.c
(check_register_target_element_label, parse_node_manual): move
parse_node_manual and check_register_target_element_label to labels.c.
* tp/Texinfo/XS/parsetexi/parser.h: do not include "def.h", let the
files using functions from def.c include it directly.
Do not define end_line_def_line which is only used within end_line.c.
---
ChangeLog | 14 +
tp/Texinfo/XS/parsetexi/close.c | 1 +
tp/Texinfo/XS/parsetexi/end_line.c | 463 ++++++------------------------
tp/Texinfo/XS/parsetexi/handle_commands.c | 1 +
tp/Texinfo/XS/parsetexi/labels.c | 301 +++++++++++++++++++
tp/Texinfo/XS/parsetexi/labels.h | 7 +-
tp/Texinfo/XS/parsetexi/parser.h | 5 -
7 files changed, 407 insertions(+), 385 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4e0c98db2d..f8d0eb59d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-03-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line): move
+ end_line_def_line definition up in the file to be before the functions
+ using it.
+
+ * tp/Texinfo/XS/parsetexi/end_line.c, tp/Texinfo/XS/parsetexi/labels.c
+ (check_register_target_element_label, parse_node_manual): move
+ parse_node_manual and check_register_target_element_label to labels.c.
+
+ * tp/Texinfo/XS/parsetexi/parser.h: do not include "def.h", let the
+ files using functions from def.c include it directly.
+ Do not define end_line_def_line which is only used within end_line.c.
+
2023-03-05 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/parsetexi/end_line.c,
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index e877cfa4d9..cf2e3ff59d 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -19,6 +19,7 @@
#include <string.h>
#include "parser.h"
+#include "def.h"
#include "debug.h"
#include "source_marks.h"
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index da9d3240b3..ae82ba58dc 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -26,6 +26,7 @@
#include "convert.h"
#include "labels.h"
#include "indices.h"
+#include "def.h"
#include "source_marks.h"
#include "handle_commands.h"
@@ -608,325 +609,115 @@ parse_line_command_args (ELEMENT *line_command)
#undef ADD_ARG
}
-void
-check_register_target_element_label (ELEMENT *label_element,
- ELEMENT *target_element)
+/* for now done in Texinfo::Convert::NodeNameNormalization, but could be
+ good to do in Parser/XS */
+/* Array of recorded @float's. */
+
+FLOAT_RECORD *floats_list = 0;
+size_t floats_number = 0;
+size_t floats_space = 0;
+
+
+char *
+parse_float_type (ELEMENT *current)
{
- if (label_element)
+ char *normalized;
+ if (current->args.number > 0)
{
- /* check that the label used as an anchor for link target has no
- external manual part */
- NODE_SPEC_EXTRA *label_info = parse_node_manual (label_element, 0);
- if (label_info && label_info->manual_content)
- {
- /* show contents only to avoid leading/trailing spaces */
- char *texi = convert_contents_to_texinfo (label_element);
- line_error ("syntax for an external node used for `%s'", texi);
- free (texi);
- }
- destroy_node_spec (label_info);
+ /* TODO convert_to_texinfo is incorrect here, conversion should follow
+ code of
Texinfo::Convert::NodeNameNormalization::convert_to_normalized */
+ normalized = convert_to_texinfo (current->args.list[0]);
}
- register_label (target_element);
+ else
+ normalized = strdup ("");
+ add_extra_string (current, "float_type", normalized);
+ return normalized;
}
-/* NODE->contents is the Texinfo for the specification of a node. This
- function sets two fields on the returned object:
-
- manual_content - Texinfo tree for a manual name extracted from the
- node specification.
- node_content - Texinfo tree for the node name on its own
-
- Objects returned from this function are used as an 'extra' key in
- the element for elements linking to nodes (such as @*ref,
- menu_entry_node or node direction arguments). In that case
- modify_node is set to 1 and the node contents are modified in-place to
- hold the same elements as the returned objects.
-
- This function is also used for elements that are targets of links (@node and
- @anchor first argument, float second argument) mainly to check that
- the syntax for an external node is not used. In that case modify_node
- is set to 0 and the node is not modified, and added elements are
- collected in a thirs field of the returned object,
- out_of_tree_elements - elements collected in manual_content or
- node_content and not in the node
- */
-
-NODE_SPEC_EXTRA *
-parse_node_manual (ELEMENT *node, int modify_node)
+ELEMENT *
+end_line_def_line (ELEMENT *current)
{
- NODE_SPEC_EXTRA *result;
- ELEMENT *node_content = 0;
- int idx = 0; /* index into node->contents */
-
- result = malloc (sizeof (NODE_SPEC_EXTRA));
- result->manual_content = result->node_content = 0;
- /* if not modifying the tree, and there is a manual name, the elements
- added for the manual name and for the node content that are based
- on texts from tree elements are not anywhere in the tree.
- They are collected in result->out_of_tree_element to be freed later.
- These elements correspond to the text after the first manual name
- opening brace and text before and after the closing manual name brace */
- result->out_of_tree_elements = 0;
-
- /* If the content starts with a '(', try to get a manual name. */
- if (node->contents.number > 0 && node->contents.list[0]->text.end > 0
- && node->contents.list[0]->text.text[0] == '(')
- {
- ELEMENT *manual, *first;
- ELEMENT *new_first = 0;
- ELEMENT *opening_brace = 0;
- char *opening_bracket, *closing_bracket;
+ enum command_id def_command;
+ DEF_INFO *def_info = 0;
+ static DEF_INFO zero_def_info; /* always stays zeroed */
+ KEY_PAIR *k;
+
+ if (pop_context () != ct_def)
+ fatal ("def context expected");
+
+ k = lookup_extra (current->parent, "def_command");
+ def_command = lookup_command ((char *) k->value);
- /* Handle nested parentheses in the manual name, for whatever reason. */
- int bracket_count = 1; /* Number of ( seen minus number of ) seen. */
+ def_info = parse_def (def_command, current);
- manual = new_element (ET_NONE);
+ current = current->parent;
- /* If the first contents element is "(" followed by more text, split
- the leading "(" into its own element. */
- first = node->contents.list[0];
- if (first->text.end > 1)
+ /* Record the index entry if def_info is not empty. */
+ if (!memcmp(def_info, &zero_def_info, sizeof (DEF_INFO)))
+ {
+ free (def_info);
+ k = lookup_extra (current, "original_def_cmdname");
+ command_warn (current, "missing category for @%s", (char *) k->value);
+ }
+ else
+ {
+ ELEMENT *index_entry = 0; /* Index entry text. */
+
+ add_extra_def_info (current, "def_parsed_hash", def_info);
+
+ if (def_info->name)
{
- if (modify_node)
+ char *t;
+ /* Set index_entry unless an empty ET_bracketed_def_content. */
+ if (def_info->name->type == ET_bracketed_def_content
+ && (def_info->name->contents.number == 0
+ || (def_info->name->contents.number == 1
+ && (t = def_info->name->contents.list[0]->text.text)
+ && t[strspn (t, whitespace_chars)] == '\0')))
{
- opening_brace = new_element (0);
- text_append_n (&opening_brace->text, "(", 1);
}
- new_first = new_element (0);
- text_append_n (&new_first->text, first->text.text +1,
first->text.end -1);
- }
- else
- {
- /* first element is "(", keep it */
- idx++;
+ else
+ index_entry = def_info->name;
}
- for (; idx < node->contents.number; idx++)
+ if (index_entry)
{
- ELEMENT *e;
- char *p, *q;
-
- if (idx == 0)
- e = new_first;
- else
- e = node->contents.list[idx];
- if (e->text.end == 0)
+ if (def_info->class &&
+ (def_command == CM_defop
+ || def_command == CM_deftypeop
+ || def_command == CM_defmethod
+ || def_command == CM_deftypemethod
+ || def_command == CM_defivar
+ || def_command == CM_deftypeivar
+ || def_command == CM_deftypecv))
{
- /* Put this element in the manual contents. */
- add_to_contents_as_array (manual, e);
- continue;
+ /* def_index_element will be set in
+ Texinfo::Translations::complete_indices */
+ if (global_documentlanguage)
+ add_extra_string_dup (current, "documentlanguage",
+ global_documentlanguage);
}
- p = e->text.text;
- while (p < e->text.text + e->text.end
- && bracket_count > 0)
+ else
{
- opening_bracket = strchr (p, '(');
- closing_bracket = strchr (p, ')');
- if (!opening_bracket && !closing_bracket)
- {
- break;
- }
- else if (opening_bracket && !closing_bracket)
- {
- bracket_count++;
- p = opening_bracket + 1;
- }
- else if (!opening_bracket && closing_bracket)
- {
- bracket_count--;
- p = closing_bracket + 1;
- }
- else if (opening_bracket < closing_bracket)
- {
- bracket_count++;
- p = opening_bracket + 1;
- }
- else if (opening_bracket > closing_bracket)
- {
- bracket_count--;
- p = closing_bracket + 1;
- }
+ add_extra_element (current, "def_index_element",
+ index_entry);
}
- if (bracket_count > 0)
- add_to_contents_as_array (manual, e);
- else /* end of filename component */
- {
- size_t current_position = 0;
- /* At this point, we are sure that there is a manual part,
- so the pending removal/addition of elements at the beginning
- of the manual can proceed (if modify_node). */
- /* Also, split the element in two, putting the part before the
")"
- in the manual name, leaving the part afterwards for the
- node name. */
- if (modify_node)
- {
- if (opening_brace)
- {
- /* remove the original first element and prepend the
- split "(" and text elements */
- remove_from_contents (node, 0); /* remove first element
*/
- insert_into_contents (node, new_first, 0);
- insert_into_contents (node, opening_brace, 0);
- idx++;
- if (first->source_mark_list.number > 0)
- {
- size_t current_position
- = relocate_source_marks
(&(first->source_mark_list),
- opening_brace, 0,
- count_convert_u8
(opening_brace->text.text));
- relocate_source_marks (&(first->source_mark_list),
- new_first, current_position,
- count_convert_u8
(new_first->text.text));
- }
- destroy_element (first);
- }
- remove_from_contents (node, idx); /* Remove current element e
- with closing brace from
the tree. */
- }
- else
- {
- /* collect elements out of tree */
- result->out_of_tree_elements = calloc (3, sizeof (ELEMENT
*));
- if (new_first)
- result->out_of_tree_elements[0] = new_first;
- }
- p--; /* point at ) */
- if (p > e->text.text)
- {
- /* text before ), part of the manual name */
- ELEMENT *last_manual_element = new_element (ET_NONE);
- text_append_n (&last_manual_element->text, e->text.text,
- p - e->text.text);
- add_to_contents_as_array (manual, last_manual_element);
- if (modify_node)
- {
- insert_into_contents (node, last_manual_element, idx++);
- current_position
- = relocate_source_marks (&(e->source_mark_list),
- last_manual_element,
- current_position,
- count_convert_u8 (last_manual_element->text.text));
- }
- else
- result->out_of_tree_elements[1] = last_manual_element;
- }
-
- if (modify_node)
- {
- ELEMENT *closing_brace = new_element (0);
- text_append_n (&closing_brace->text, ")", 1);
- insert_into_contents (node, closing_brace, idx++);
- current_position
- = relocate_source_marks (&(e->source_mark_list),
- closing_brace,
- current_position,
- count_convert_u8 (closing_brace->text.text));
- }
-
- /* Skip ')' and any following whitespace.
- Note that we don't manage to skip any multibyte
- UTF-8 space characters here. */
- p++;
- q = p + strspn (p, whitespace_chars);
- if (q > p && modify_node)
- {
- ELEMENT *spaces_element = new_element (0);
- text_append_n (&spaces_element->text, p, q - p);
- insert_into_contents (node, spaces_element, idx++);
- current_position
- = relocate_source_marks (&(e->source_mark_list),
- spaces_element,
- current_position,
- count_convert_u8 (spaces_element->text.text));
- }
-
- p = q;
- if (*p)
- {
- /* text after ), part of the node name. */
- ELEMENT *leading_node_content = new_element (ET_NONE);
- text_append_n (&leading_node_content->text, p,
- e->text.text + e->text.end - p);
- /* start node_content */
- node_content = new_element (0);
- add_to_contents_as_array (node_content,
leading_node_content);
- if (modify_node)
- {
- insert_into_contents (node, leading_node_content, idx);
- current_position
- = relocate_source_marks (&(e->source_mark_list),
- leading_node_content,
- current_position,
- count_convert_u8
(leading_node_content->text.text));
- }
- else
- result->out_of_tree_elements[2] = leading_node_content;
- idx++;
- }
- if (modify_node)
- destroy_element (e);
- break;
- }
- } /* for */
-
- if (bracket_count == 0)
- result->manual_content = manual;
- else /* Unbalanced parentheses, consider that there is no manual
- afterall. So far the node has not been modified, so the
- only thing that needs to be done is to remove the manual
- element and the elements allocated for the beginning of
- the manual, and start over */
+ if (def_command != CM_defline)
+ enter_index_entry (def_command, current);
+ }
+ else
{
- destroy_element (manual);
- if (new_first)
- destroy_element (new_first);
- if (opening_brace)
- destroy_element (opening_brace);
- idx = 0; /* Back to the start, and consider the whole thing
- as a node name. */
+ k = lookup_extra (current, "original_def_cmdname");
+ command_warn (current, "missing name for @%s", (char *) k->value);
}
}
- /* If anything left, it is part of the node name. */
- if (idx < node->contents.number)
- {
- if (!node_content)
- node_content = new_element (0);
- insert_slice_into_contents (node_content, node_content->contents.number,
- node, idx, node->contents.number);
- }
-
- if (node_content)
- result->node_content = node_content;
-
- return result;
-}
-
-/* for now done in Texinfo::Convert::NodeNameNormalization, but could be
- good to do in Parser/XS */
-/* Array of recorded @float's. */
-
-FLOAT_RECORD *floats_list = 0;
-size_t floats_number = 0;
-size_t floats_space = 0;
-
+ current = current->parent;
+ current = begin_preformatted (current);
-char *
-parse_float_type (ELEMENT *current)
-{
- char *normalized;
- if (current->args.number > 0)
- {
- /* TODO convert_to_texinfo is incorrect here, conversion should follow
- code of
Texinfo::Convert::NodeNameNormalization::convert_to_normalized */
- normalized = convert_to_texinfo (current->args.list[0]);
- }
- else
- normalized = strdup ("");
- add_extra_string (current, "float_type", normalized);
- return normalized;
+ return current;
}
/* Actions to be taken at the end of a line that started a block that
@@ -1967,92 +1758,6 @@ end_line_misc_line (ELEMENT *current)
return current;
}
-ELEMENT *
-end_line_def_line (ELEMENT *current)
-{
- enum command_id def_command;
- DEF_INFO *def_info = 0;
- static DEF_INFO zero_def_info; /* always stays zeroed */
- KEY_PAIR *k;
-
- if (pop_context () != ct_def)
- fatal ("def context expected");
-
- k = lookup_extra (current->parent, "def_command");
- def_command = lookup_command ((char *) k->value);
-
- def_info = parse_def (def_command, current);
-
- current = current->parent;
-
- /* Record the index entry if def_info is not empty. */
- if (!memcmp(def_info, &zero_def_info, sizeof (DEF_INFO)))
- {
- free (def_info);
- k = lookup_extra (current, "original_def_cmdname");
- command_warn (current, "missing category for @%s", (char *) k->value);
- }
- else
- {
- ELEMENT *index_entry = 0; /* Index entry text. */
-
- add_extra_def_info (current, "def_parsed_hash", def_info);
-
- if (def_info->name)
- {
- char *t;
- /* Set index_entry unless an empty ET_bracketed_def_content. */
- if (def_info->name->type == ET_bracketed_def_content
- && (def_info->name->contents.number == 0
- || (def_info->name->contents.number == 1
- && (t = def_info->name->contents.list[0]->text.text)
- && t[strspn (t, whitespace_chars)] == '\0')))
- {
- }
- else
- index_entry = def_info->name;
- }
-
- if (index_entry)
- {
-
- if (def_info->class &&
- (def_command == CM_defop
- || def_command == CM_deftypeop
- || def_command == CM_defmethod
- || def_command == CM_deftypemethod
- || def_command == CM_defivar
- || def_command == CM_deftypeivar
- || def_command == CM_deftypecv))
- {
- /* def_index_element will be set in
- Texinfo::Translations::complete_indices */
- if (global_documentlanguage)
- add_extra_string_dup (current, "documentlanguage",
- global_documentlanguage);
- }
- else
- {
- add_extra_element (current, "def_index_element",
- index_entry);
- }
-
- if (def_command != CM_defline)
- enter_index_entry (def_command, current);
- }
- else
- {
- k = lookup_extra (current, "original_def_cmdname");
- command_warn (current, "missing name for @%s", (char *) k->value);
- }
- }
-
- current = current->parent;
- current = begin_preformatted (current);
-
- return current;
-}
-
/* Actions to be taken when a whole line of input has been processed */
ELEMENT *
end_line (ELEMENT *current)
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 817ccefd0d..541caff476 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -20,6 +20,7 @@
#include <ctype.h>
#include "parser.h"
+#include "def.h"
#include "debug.h"
#include "tree.h"
#include "input.h"
diff --git a/tp/Texinfo/XS/parsetexi/labels.c b/tp/Texinfo/XS/parsetexi/labels.c
index 1ee347c783..bda9965b6e 100644
--- a/tp/Texinfo/XS/parsetexi/labels.c
+++ b/tp/Texinfo/XS/parsetexi/labels.c
@@ -13,9 +13,12 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include <string.h>
+
#include <config.h>
#include "parser.h"
#include "convert.h"
+#include "source_marks.h"
#include "labels.h"
/* Array of recorded elements with labels. */
@@ -47,8 +50,306 @@ reset_labels (void)
{
labels_number = 0;
}
+
+void
+check_register_target_element_label (ELEMENT *label_element,
+ ELEMENT *target_element)
+{
+ if (label_element)
+ {
+ /* check that the label used as an anchor for link target has no
+ external manual part */
+ NODE_SPEC_EXTRA *label_info = parse_node_manual (label_element, 0);
+ if (label_info && label_info->manual_content)
+ {
+ /* show contents only to avoid leading/trailing spaces */
+ char *texi = convert_contents_to_texinfo (label_element);
+ line_error ("syntax for an external node used for `%s'", texi);
+ free (texi);
+ }
+ destroy_node_spec (label_info);
+ }
+ register_label (target_element);
+}
+
+/* NODE->contents is the Texinfo for the specification of a node. This
+ function sets two fields on the returned object:
+
+ manual_content - Texinfo tree for a manual name extracted from the
+ node specification.
+ node_content - Texinfo tree for the node name on its own
+
+ Objects returned from this function are used as an 'extra' key in
+ the element for elements linking to nodes (such as @*ref,
+ menu_entry_node or node direction arguments). In that case
+ modify_node is set to 1 and the node contents are modified in-place to
+ hold the same elements as the returned objects.
+
+ This function is also used for elements that are targets of links (@node and
+ @anchor first argument, float second argument) mainly to check that
+ the syntax for an external node is not used. In that case modify_node
+ is set to 0 and the node is not modified, and added elements are
+ collected in a thirs field of the returned object,
+ out_of_tree_elements - elements collected in manual_content or
+ node_content and not in the node
+ */
+
+NODE_SPEC_EXTRA *
+parse_node_manual (ELEMENT *node, int modify_node)
+{
+ NODE_SPEC_EXTRA *result;
+ ELEMENT *node_content = 0;
+ int idx = 0; /* index into node->contents */
+
+ result = malloc (sizeof (NODE_SPEC_EXTRA));
+ result->manual_content = result->node_content = 0;
+ /* if not modifying the tree, and there is a manual name, the elements
+ added for the manual name and for the node content that are based
+ on texts from tree elements are not anywhere in the tree.
+ They are collected in result->out_of_tree_element to be freed later.
+ These elements correspond to the text after the first manual name
+ opening brace and text before and after the closing manual name brace */
+ result->out_of_tree_elements = 0;
+
+ /* If the content starts with a '(', try to get a manual name. */
+ if (node->contents.number > 0 && node->contents.list[0]->text.end > 0
+ && node->contents.list[0]->text.text[0] == '(')
+ {
+ ELEMENT *manual, *first;
+ ELEMENT *new_first = 0;
+ ELEMENT *opening_brace = 0;
+ char *opening_bracket, *closing_bracket;
+
+ /* Handle nested parentheses in the manual name, for whatever reason. */
+ int bracket_count = 1; /* Number of ( seen minus number of ) seen. */
+
+ manual = new_element (ET_NONE);
+
+ /* If the first contents element is "(" followed by more text, split
+ the leading "(" into its own element. */
+ first = node->contents.list[0];
+ if (first->text.end > 1)
+ {
+ if (modify_node)
+ {
+ opening_brace = new_element (0);
+ text_append_n (&opening_brace->text, "(", 1);
+ }
+ new_first = new_element (0);
+ text_append_n (&new_first->text, first->text.text +1,
first->text.end -1);
+ }
+ else
+ {
+ /* first element is "(", keep it */
+ idx++;
+ }
+
+ for (; idx < node->contents.number; idx++)
+ {
+ ELEMENT *e;
+ char *p, *q;
+
+ if (idx == 0)
+ e = new_first;
+ else
+ e = node->contents.list[idx];
+
+ if (e->text.end == 0)
+ {
+ /* Put this element in the manual contents. */
+ add_to_contents_as_array (manual, e);
+ continue;
+ }
+ p = e->text.text;
+ while (p < e->text.text + e->text.end
+ && bracket_count > 0)
+ {
+ opening_bracket = strchr (p, '(');
+ closing_bracket = strchr (p, ')');
+ if (!opening_bracket && !closing_bracket)
+ {
+ break;
+ }
+ else if (opening_bracket && !closing_bracket)
+ {
+ bracket_count++;
+ p = opening_bracket + 1;
+ }
+ else if (!opening_bracket && closing_bracket)
+ {
+ bracket_count--;
+ p = closing_bracket + 1;
+ }
+ else if (opening_bracket < closing_bracket)
+ {
+ bracket_count++;
+ p = opening_bracket + 1;
+ }
+ else if (opening_bracket > closing_bracket)
+ {
+ bracket_count--;
+ p = closing_bracket + 1;
+ }
+ }
+
+ if (bracket_count > 0)
+ add_to_contents_as_array (manual, e);
+ else /* end of filename component */
+ {
+ size_t current_position = 0;
+ /* At this point, we are sure that there is a manual part,
+ so the pending removal/addition of elements at the beginning
+ of the manual can proceed (if modify_node). */
+ /* Also, split the element in two, putting the part before the
")"
+ in the manual name, leaving the part afterwards for the
+ node name. */
+ if (modify_node)
+ {
+ if (opening_brace)
+ {
+ /* remove the original first element and prepend the
+ split "(" and text elements */
+ remove_from_contents (node, 0); /* remove first element
*/
+ insert_into_contents (node, new_first, 0);
+ insert_into_contents (node, opening_brace, 0);
+ idx++;
+ if (first->source_mark_list.number > 0)
+ {
+ size_t current_position
+ = relocate_source_marks
(&(first->source_mark_list),
+ opening_brace, 0,
+ count_convert_u8
(opening_brace->text.text));
+ relocate_source_marks (&(first->source_mark_list),
+ new_first, current_position,
+ count_convert_u8
(new_first->text.text));
+ }
+ destroy_element (first);
+ }
+ remove_from_contents (node, idx); /* Remove current element e
+ with closing brace from
the tree. */
+ }
+ else
+ {
+ /* collect elements out of tree */
+ result->out_of_tree_elements = calloc (3, sizeof (ELEMENT
*));
+ if (new_first)
+ result->out_of_tree_elements[0] = new_first;
+ }
+ p--; /* point at ) */
+ if (p > e->text.text)
+ {
+ /* text before ), part of the manual name */
+ ELEMENT *last_manual_element = new_element (ET_NONE);
+ text_append_n (&last_manual_element->text, e->text.text,
+ p - e->text.text);
+ add_to_contents_as_array (manual, last_manual_element);
+ if (modify_node)
+ {
+ insert_into_contents (node, last_manual_element, idx++);
+ current_position
+ = relocate_source_marks (&(e->source_mark_list),
+ last_manual_element,
+ current_position,
+ count_convert_u8 (last_manual_element->text.text));
+ }
+ else
+ result->out_of_tree_elements[1] = last_manual_element;
+ }
+
+ if (modify_node)
+ {
+ ELEMENT *closing_brace = new_element (0);
+ text_append_n (&closing_brace->text, ")", 1);
+ insert_into_contents (node, closing_brace, idx++);
+ current_position
+ = relocate_source_marks (&(e->source_mark_list),
+ closing_brace,
+ current_position,
+ count_convert_u8 (closing_brace->text.text));
+ }
+
+ /* Skip ')' and any following whitespace.
+ Note that we don't manage to skip any multibyte
+ UTF-8 space characters here. */
+ p++;
+ q = p + strspn (p, whitespace_chars);
+ if (q > p && modify_node)
+ {
+ ELEMENT *spaces_element = new_element (0);
+ text_append_n (&spaces_element->text, p, q - p);
+ insert_into_contents (node, spaces_element, idx++);
+ current_position
+ = relocate_source_marks (&(e->source_mark_list),
+ spaces_element,
+ current_position,
+ count_convert_u8 (spaces_element->text.text));
+ }
+
+ p = q;
+ if (*p)
+ {
+ /* text after ), part of the node name. */
+ ELEMENT *leading_node_content = new_element (ET_NONE);
+ text_append_n (&leading_node_content->text, p,
+ e->text.text + e->text.end - p);
+ /* start node_content */
+ node_content = new_element (0);
+ add_to_contents_as_array (node_content,
leading_node_content);
+ if (modify_node)
+ {
+ insert_into_contents (node, leading_node_content, idx);
+ current_position
+ = relocate_source_marks (&(e->source_mark_list),
+ leading_node_content,
+ current_position,
+ count_convert_u8
(leading_node_content->text.text));
+ }
+ else
+ result->out_of_tree_elements[2] = leading_node_content;
+ idx++;
+ }
+ if (modify_node)
+ destroy_element (e);
+ break;
+ }
+ } /* for */
+
+ if (bracket_count == 0)
+ result->manual_content = manual;
+ else /* Unbalanced parentheses, consider that there is no manual
+ afterall. So far the node has not been modified, so the
+ only thing that needs to be done is to remove the manual
+ element and the elements allocated for the beginning of
+ the manual, and start over */
+ {
+ destroy_element (manual);
+ if (new_first)
+ destroy_element (new_first);
+ if (opening_brace)
+ destroy_element (opening_brace);
+ idx = 0; /* Back to the start, and consider the whole thing
+ as a node name. */
+ }
+ }
+
+ /* If anything left, it is part of the node name. */
+ if (idx < node->contents.number)
+ {
+ if (!node_content)
+ node_content = new_element (0);
+ insert_slice_into_contents (node_content, node_content->contents.number,
+ node, idx, node->contents.number);
+ }
+
+ if (node_content)
+ result->node_content = node_content;
+
+ return result;
+}
+
+
ELEMENT **internal_xref_list = 0;
size_t internal_xref_number = 0;
diff --git a/tp/Texinfo/XS/parsetexi/labels.h b/tp/Texinfo/XS/parsetexi/labels.h
index 3d83b25eae..f622dcad58 100644
--- a/tp/Texinfo/XS/parsetexi/labels.h
+++ b/tp/Texinfo/XS/parsetexi/labels.h
@@ -20,8 +20,13 @@
extern ELEMENT **target_elements_list;
extern size_t labels_number;
-void register_label (ELEMENT *current);
void reset_labels (void);
+void check_register_target_element_label (ELEMENT *label_element,
+ ELEMENT *target_element);
+
+
+
+NODE_SPEC_EXTRA *parse_node_manual (ELEMENT *node, int modify_node);
extern ELEMENT **internal_xref_list;
diff --git a/tp/Texinfo/XS/parsetexi/parser.h b/tp/Texinfo/XS/parsetexi/parser.h
index 2aacf0b090..c2751a7601 100644
--- a/tp/Texinfo/XS/parsetexi/parser.h
+++ b/tp/Texinfo/XS/parsetexi/parser.h
@@ -24,7 +24,6 @@
#include "context_stack.h"
#include "commands.h"
#include "handle_commands.h"
-#include "def.h"
#include "errors.h"
#include "counter.h"
#include "macro.h"
@@ -127,13 +126,9 @@ ELEMENT *close_brace_command (ELEMENT *current,
void close_ignored_block_conditional (ELEMENT *current);
/* In end_line.c */
-NODE_SPEC_EXTRA *parse_node_manual (ELEMENT *node, int modify_node);
ELEMENT *end_line (ELEMENT *current);
-ELEMENT *end_line_def_line (ELEMENT *current);
ELEMENT *end_line_misc_line (ELEMENT *current);
ELEMENT *end_line_starting_block (ELEMENT *current);
-void check_register_target_element_label (ELEMENT *label_element,
- ELEMENT *target_element);
typedef struct {
char *type;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line): move end_line_def_line definition up in the file to be before the functions using it.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/XS/parsetexi/end_line.c, tp/Texinfo/XS/parsetexi/handle_commands.c (skip_to_comment): (skip_to_comment_if_comment_or_spaces, parse_rawline_command): move parse_rawline_command, skip_to_comment and skip_to_comment_if_comment_or_spaces to handle_commands.c.
- Next by Date:
branch master updated: * tp/t/19def.t (defline_no_params, adjacent_defline, multiple_defline) (defblock_no_defline): New tests.
- Previous by thread:
branch master updated: * tp/Texinfo/XS/parsetexi/end_line.c, tp/Texinfo/XS/parsetexi/handle_commands.c (skip_to_comment): (skip_to_comment_if_comment_or_spaces, parse_rawline_command): move parse_rawline_command, skip_to_comment and skip_to_comment_if_comment_or_spaces to handle_commands.c.
- Next by thread:
branch master updated: * tp/t/19def.t (defline_no_params, adjacent_defline, multiple_defline) (defblock_no_defline): New tests.
- Index(es):