texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/XS/main/targets.c (existing_label_er


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/targets.c (existing_label_error) (register_label_element), tp/Texinfo/XS/structuring_transfo/transformations.c (new_node) (insert_nodes_for_sectioning_commands): use message_list_* functions in existing_label_error. Pass error_messages to existing_label_error through new_node and register_label_element.
Date: Thu, 22 Feb 2024 18:37:15 -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 17bb768cae * tp/Texinfo/XS/main/targets.c (existing_label_error) 
(register_label_element), tp/Texinfo/XS/structuring_transfo/transformations.c 
(new_node) (insert_nodes_for_sectioning_commands): use message_list_* functions 
in existing_label_error.  Pass error_messages to existing_label_error through 
new_node and register_label_element.
17bb768cae is described below

commit 17bb768caefc4b49fb4672f3d6fb6fd9a92a2ac1
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Feb 23 00:37:12 2024 +0100

    * tp/Texinfo/XS/main/targets.c (existing_label_error)
    (register_label_element),
    tp/Texinfo/XS/structuring_transfo/transformations.c (new_node)
    (insert_nodes_for_sectioning_commands): use message_list_* functions
    in existing_label_error.  Pass error_messages to existing_label_error
    through new_node and register_label_element.
---
 ChangeLog                                          |  9 ++++++++
 tp/Texinfo/XS/main/targets.c                       | 27 ++++++++++++----------
 tp/Texinfo/XS/main/targets.h                       |  4 +++-
 .../XS/structuring_transfo/transformations.c       | 20 +++++++++-------
 4 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c18bb23233..865b416b7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-02-22  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/targets.c (existing_label_error)
+       (register_label_element),
+       tp/Texinfo/XS/structuring_transfo/transformations.c (new_node)
+       (insert_nodes_for_sectioning_commands): use message_list_* functions
+       in existing_label_error.  Pass error_messages to existing_label_error
+       through new_node and register_label_element.
+
 2024-02-22  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_parse_texi), tp/Texinfo/Translations.pm
diff --git a/tp/Texinfo/XS/main/targets.c b/tp/Texinfo/XS/main/targets.c
index 61f80f7a78..521e6c9669 100644
--- a/tp/Texinfo/XS/main/targets.c
+++ b/tp/Texinfo/XS/main/targets.c
@@ -22,6 +22,7 @@
 #include "tree_types.h"
 #include "document_types.h"
 #include "tree.h"
+#include "errors.h"
 #include "errors_parser.h"
 #include "debug.h"
 #include "builtin_commands.h"
@@ -240,25 +241,26 @@ add_element_to_identifiers_target (DOCUMENT *document, 
ELEMENT *element,
   return normalized;
 }
 
-/* TODO call message_list_* functions instead, but this would require
-   an ERROR_MESSAGE_LIST argument.
-   For now it is not useful, as the code calling register_label_element
-   makes sure that there is no preexisting target element with the
-   same noormalized identifier.
+/* NOTE this function cannot currently be called as the code calling
+   register_label_element makes sure that there is no preexisting
+   target element with the same normalized identifier.
    */
-void
-existing_label_error (DOCUMENT* document, ELEMENT *element, char *normalized)
+static void
+existing_label_error (DOCUMENT* document, ELEMENT *element, char *normalized,
+                      ERROR_MESSAGE_LIST *error_messages)
 {
-  if (normalized)
+  if (normalized && error_messages)
     {
       ELEMENT *existing_target
         = find_identifier_target (document->identifiers_target, normalized);
       ELEMENT *label_element = get_label_element (element);
       char *label_element_texi = convert_contents_to_texinfo (label_element);
-      command_error (element, "@%s `%s' previously defined",
+      message_list_command_error (error_messages, document->options,
+                     element, "@%s `%s' previously defined",
                      builtin_command_name (element->cmd),
                      label_element_texi);
-      line_error_ext (MSG_error, 1, &existing_target->source_info,
+      message_list_line_error_ext (error_messages, document->options,
+                      MSG_error, 1, &existing_target->source_info,
                       "here is the previous definition as @%s",
                       builtin_command_name (existing_target->cmd));
       free (label_element_texi);
@@ -267,7 +269,8 @@ existing_label_error (DOCUMENT* document, ELEMENT *element, 
char *normalized)
 
 /* return value is 1 for success, 0 for failure */
 int
-register_label_element (int document_descriptor, ELEMENT *element)
+register_label_element (int document_descriptor, ELEMENT *element,
+                        ERROR_MESSAGE_LIST *error_messages)
 {
   int status;
   DOCUMENT *document = retrieve_document (document_descriptor);
@@ -276,7 +279,7 @@ register_label_element (int document_descriptor, ELEMENT 
*element)
                                                         &status);
   if (!status)
     {
-      existing_label_error(document, element, normalized);
+      existing_label_error (document, element, normalized, error_messages);
     }
   register_label_in_list (document->labels_list, element,
                           normalized);
diff --git a/tp/Texinfo/XS/main/targets.h b/tp/Texinfo/XS/main/targets.h
index 6c9e5973aa..0f44691615 100644
--- a/tp/Texinfo/XS/main/targets.h
+++ b/tp/Texinfo/XS/main/targets.h
@@ -5,10 +5,12 @@
 #include <stddef.h>
 
 #include "tree_types.h"
+#include "document_types.h"
 
 ELEMENT *find_identifier_target (LABEL_LIST *identifiers_target,
                                  char *normalized);
-int register_label_element (int document_descriptor, ELEMENT *element);
+int register_label_element (int document_descriptor, ELEMENT *element,
+                            ERROR_MESSAGE_LIST *error_messages);
 
 LABEL_LIST *set_labels_identifiers_target (LABEL *list_of_labels,
                                            size_t labels_number);
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c 
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index ee740add21..36763fa934 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -543,12 +543,12 @@ move_index_entries_after_items_in_tree (ELEMENT *tree)
   modify_tree (tree, &move_index_entries_after_items_internal, 0);
 }
 
-/* in perl REGISTRAR and CUSTOMIZATION_INFORMATION used for error
-# reporting, but they should not be useful, as the code checks that
-# the new node target label does not exist already.
+/* ERROR_MESSAGES is not actually useful, as the code checks that
+   the new node target label does not exist already.
  */
 ELEMENT *
-new_node (ELEMENT *node_tree, DOCUMENT *document)
+new_node (ERROR_MESSAGE_LIST *error_messages, ELEMENT *node_tree,
+          DOCUMENT *document)
 {
   LABEL_LIST *identifiers_target = document->identifiers_target;
   int document_descriptor = document->descriptor;
@@ -670,7 +670,7 @@ new_node (ELEMENT *node_tree, DOCUMENT *document)
 
   add_extra_string (node, "normalized", normalized);
 
-  register_label_element (document_descriptor, node);
+  register_label_element (document_descriptor, node, error_messages);
 
   free (spaces_after_argument.text);
 
@@ -749,8 +749,11 @@ reassociate_to_node (const char *type, ELEMENT *current, 
void *argument)
   return 0;
 }
 
-/* in perl registrar and configuration, but they are not useful,
-   see comment before new_node */
+/* in perl registrar and configuration.  The document errors list
+   is used here.  It could be relevant to use an error messages list
+   as argument instead of using the document error messages list, but
+   it does not matter much as there should be no error, see comment
+   before new_node */
 ELEMENT_LIST *
 insert_nodes_for_sectioning_commands (DOCUMENT *document)
 {
@@ -786,7 +789,8 @@ insert_nodes_for_sectioning_commands (DOCUMENT *document)
                   new_node_tree = copy_contents(content->args.list[0],
                                                 ET_NONE);
                 }
-              added_node = new_node (new_node_tree, document);
+              added_node = new_node (document->error_messages, new_node_tree,
+                                     document);
               destroy_element (new_node_tree);
               if (added_node)
                 {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]