texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/convert/convert_html.c, tp/Texinf


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/convert_html.c, tp/Texinfo/XS/main/tree_types.h: add const.
Date: Wed, 13 Mar 2024 11:09:04 -0400

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 4f5a7e79de * tp/Texinfo/XS/convert/convert_html.c, 
tp/Texinfo/XS/main/tree_types.h: add const.
4f5a7e79de is described below

commit 4f5a7e79dee381ea2edda4e26d91b5baf4e0f564
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Mar 13 16:08:54 2024 +0100

    * tp/Texinfo/XS/convert/convert_html.c,
    tp/Texinfo/XS/main/tree_types.h: add const.
    
    * tp/Texinfo/XS/convert/convert_html.c (normalized_label_id_file):
    reorganize code, add const.
    
    * tp/Texinfo/XS/structuring_transfo/transformations.c
    (protect_first_parenthesis): reorganiza code, add const.
---
 ChangeLog                                          | 11 ++++++
 tp/TODO                                            |  2 --
 tp/Texinfo/XS/convert/convert_html.c               | 40 ++++++++++++----------
 tp/Texinfo/XS/convert/converter.c                  |  2 +-
 tp/Texinfo/XS/convert/converter.h                  |  2 +-
 tp/Texinfo/XS/main/targets.c                       |  4 +--
 tp/Texinfo/XS/main/tree_types.h                    |  2 +-
 .../XS/structuring_transfo/transformations.c       |  7 ++--
 8 files changed, 40 insertions(+), 30 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f6a79fb3d8..487152de87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-03-13  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/convert_html.c,
+       tp/Texinfo/XS/main/tree_types.h: add const.
+
+       * tp/Texinfo/XS/convert/convert_html.c (normalized_label_id_file):
+       reorganize code, add const.
+
+       * tp/Texinfo/XS/structuring_transfo/transformations.c
+       (protect_first_parenthesis): reorganiza code, add const.
+
 2024-03-12  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/ConvertXS.xs
diff --git a/tp/TODO b/tp/TODO
index bc5e616346..a5b16bb24c 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -10,8 +10,6 @@ This is the todo list for texi2any
 Before next release
 ===================
 
-Check if LABEL identifier should be const
-
 Remove the need for Texinfo::Structuring::rebuild_output_units, currently seems
 to be called in t/test_utils.pl only.
 
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 521a36aff6..d07dcede68 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -1857,7 +1857,7 @@ prepare_associated_special_units_targets (CONVERTER *self)
 }
 
 static char *
-normalized_to_id (char *id)
+normalized_to_id (const char *id)
 {
   if (isascii_digit (id[0]) || id[0] == '_')
     {
@@ -1869,30 +1869,35 @@ normalized_to_id (char *id)
 }
 
 static TARGET_FILENAME *
-normalized_label_id_file (CONVERTER *self, char *normalized,
+normalized_label_id_file (CONVERTER *self, const char *normalized,
                           const ELEMENT* label_element)
 {
   int called;
-  char *target;
+  char *target = 0;
   char *target_customized;
+  char *normalized_label = 0;
   TARGET_FILENAME *target_filename
     = (TARGET_FILENAME *) malloc (sizeof (TARGET_FILENAME));
 
-  int normalized_need_to_be_freed = 0;
-  if (!normalized && label_element)
+  if (normalized)
+    {
+      normalized_label = strdup (normalized);
+      target = normalized_to_id (normalized);
+    }
+  else if (label_element)
     {
-      normalized = convert_contents_to_identifier (label_element);
-      normalized_need_to_be_freed = 1;
+      normalized_label
+       = convert_contents_to_identifier (label_element);
+      if (normalized_label)
+        target = normalized_to_id (normalized_label);
     }
 
-  if (normalized)
-    target = normalized_to_id (normalized);
-  else
+  if (!target)
     target = strdup ("");
 
   /* to find out the Top node, one could check $normalized */
   target_customized = call_file_id_setting_label_target_name (self,
-                                  normalized, label_element, target,
+                                  normalized_label, label_element, target,
                                   &called);
 
   if (target_customized)
@@ -1901,18 +1906,17 @@ normalized_label_id_file (CONVERTER *self, char 
*normalized,
       target = target_customized;
     }
 
-  if (normalized_need_to_be_freed)
-    free (normalized);
-
   target_filename->target = target;
-  target_filename->filename = node_information_filename (self, normalized,
-                                                         label_element);
+  target_filename->filename
+    = node_information_filename (self, normalized_label, label_element);
+
+  free (normalized_label);
 
   return target_filename;
 }
 
-char *
-unique_target (CONVERTER *self, char *target_base)
+static char *
+unique_target (CONVERTER *self, const char *target_base)
 {
   int nr = 1;
   char *target = strdup (target_base);
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 4b095c0e5f..d088c90237 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -292,7 +292,7 @@ normalized_sectioning_command_filename (CONVERTER *self, 
const ELEMENT *command)
 }
 
 char *
-node_information_filename (CONVERTER *self, char *normalized,
+node_information_filename (CONVERTER *self, const char *normalized,
                            const ELEMENT *label_element)
 {
   char *filename;
diff --git a/tp/Texinfo/XS/convert/converter.h 
b/tp/Texinfo/XS/convert/converter.h
index 7d41067621..229f51e77e 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -83,7 +83,7 @@ void set_global_document_commands (CONVERTER *converter,
                                   const enum command_location location,
                                   const enum command_id *cmd_list);
 
-char *node_information_filename (CONVERTER *self, char *normalized,
+char *node_information_filename (CONVERTER *self, const char *normalized,
                                  const ELEMENT *label_element);
 
 TREE_ADDED_ELEMENTS *new_tree_added_elements
diff --git a/tp/Texinfo/XS/main/targets.c b/tp/Texinfo/XS/main/targets.c
index 202d85f7f8..830a4ec108 100644
--- a/tp/Texinfo/XS/main/targets.c
+++ b/tp/Texinfo/XS/main/targets.c
@@ -142,7 +142,7 @@ set_labels_identifiers_target (LABEL *list_of_labels, 
size_t labels_number)
               size_t n;
               for (n = i+1; n < j + 1; n++)
                 {
-                  ELEMENT *label_element
+                  const ELEMENT *label_element
                      = get_label_element (targets[n].element);
                   char *texi_str = convert_contents_to_texinfo (label_element);
                   line_error_ext (MSG_error, 0, 
&targets[n].element->source_info,
@@ -255,7 +255,7 @@ existing_label_error (DOCUMENT* document, ELEMENT *element, 
char *normalized,
     {
       ELEMENT *existing_target
         = find_identifier_target (document->identifiers_target, normalized);
-      ELEMENT *label_element = get_label_element (element);
+      const ELEMENT *label_element = get_label_element (element);
       char *label_element_texi = convert_contents_to_texinfo (label_element);
       message_list_command_error (error_messages, document->options,
                      element, "@%s `%s' previously defined",
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index 38bba86d0e..8b99f13215 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -279,7 +279,7 @@ typedef struct {
 
 typedef struct {
     size_t label_number;
-    char *identifier;
+    const char *identifier;
     ELEMENT *element;
  /* for label that is a duplicate, points to the element used in links */
     const ELEMENT *reference;
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c 
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index 1d2d09b876..652d9cc6e8 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -78,17 +78,14 @@ lookup_index_entry (ELEMENT *index_entry_info, INDEX 
**indices_information)
 void
 protect_first_parenthesis (ELEMENT *element)
 {
-  ELEMENT *content;
-  char *p;
   int i;
 
   if (element->contents.number <= 0)
     return;
   for (i = 0; i < element->contents.number; i++)
     {
-      content = element->contents.list[i];
-      if (content->text.space == 0)
-        return;
+      ELEMENT *content = element->contents.list[i];
+      const char *p;
       if (content->text.end == 0)
         continue;
       p = content->text.text;



reply via email to

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