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 (direction


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/convert_html.c (direction_a): rename direction_anchor as direction_a. Update callers.
Date: Fri, 22 Dec 2023 05:22:50 -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 57b42f2828 * tp/Texinfo/XS/convert/convert_html.c (direction_a): 
rename direction_anchor as direction_a.  Update callers.
57b42f2828 is described below

commit 57b42f282895656ae82805a23c9ef702fdc2ad66
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Dec 22 11:22:47 2023 +0100

    * tp/Texinfo/XS/convert/convert_html.c (direction_a): rename
    direction_anchor as direction_a.  Update callers.
    
    * tp/Texinfo/XS/convert/convert_html.c
    (default_panel_button_dynamic_direction_internal): rearrange code
    and free href.
    
    * tp/Texinfo/XS/convert/convert_html.c (convert_xref_commands):
    allocate and free file, free href, destroy label_element and tree,
    removing leaks found by valgrind.
    
    * tp/Texinfo/XS/convert/convert_html.c (external_node_href):
    free parentheses_manual_name, removing leaks found by valgrind.
---
 ChangeLog                            | 16 ++++++++++++
 tp/Texinfo/XS/convert/convert_html.c | 49 ++++++++++++++++++------------------
 2 files changed, 41 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index efb4981900..9c84cda8fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2023-12-22  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/convert_html.c (direction_a): rename
+       direction_anchor as direction_a.  Update callers.
+
+       * tp/Texinfo/XS/convert/convert_html.c
+       (default_panel_button_dynamic_direction_internal): rearrange code
+       and free href.
+
+       * tp/Texinfo/XS/convert/convert_html.c (convert_xref_commands):
+       allocate and free file, free href, destroy label_element and tree,
+       removing leaks found by valgrind.
+
+       * tp/Texinfo/XS/convert/convert_html.c (external_node_href):
+       free parentheses_manual_name, removing leaks found by valgrind.
+
 2023-12-22  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/convert_html.c (convert_value_command)
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 211ad79dfc..f2bf334065 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -3027,6 +3027,7 @@ external_node_href (CONVERTER *self, const ELEMENT 
*external_node,
                   free (target_filebase);
                   return strdup ("");
                 }
+              free (parentheses_manual_name);
             }
         }
       p = strrchr (manual_name, '/');
@@ -5515,8 +5516,8 @@ direction_href_attributes (CONVERTER *self, int 
direction, TEXT *result)
 }
 
 static char *
-direction_anchor (CONVERTER *self, int direction, const char *href,
-                  const char *text, int omit_rel)
+direction_a (CONVERTER *self, int direction, const char *href,
+             const char *text, int omit_rel)
 {
   TEXT result;
   text_init (&result);
@@ -6622,22 +6623,19 @@ default_panel_button_dynamic_direction_internal 
(CONVERTER *self,
 
   if (node && node[strspn (node, whitespace_chars)] != '\0')
     {
-      char *hyperlink;
       char *text = direction_string (self, direction, TDS_type_text, 0);
       if (href && strlen (href))
         {
-          hyperlink =
-           direction_anchor (self, direction, href, node, omit_rel);
-          free (node);
+          char *hyperlink
+           = direction_a (self, direction, href, node, omit_rel);
+          xasprintf (&formatted_button->active, "%s: %s", text, hyperlink);
+          free (hyperlink);
         }
       else
-        hyperlink = node;
-
-      xasprintf (&formatted_button->active, "%s: %s", text, hyperlink);
-      free (hyperlink);
-      return formatted_button;
+        xasprintf (&formatted_button->active, "%s: %s", text, node);
     }
 
+  free (href);
   free (node);
   return formatted_button;
 }
@@ -6732,7 +6730,7 @@ html_default_format_button (CONVERTER *self,
                   if (href)
                     {
                       formatted_button->active
-                        = direction_anchor (self, direction, href, text, 0);
+                        = direction_a (self, direction, href, text, 0);
                       free (href);
                     }
                   else
@@ -6766,8 +6764,8 @@ html_default_format_button (CONVERTER *self,
                   if (href)
                     {
                       formatted_button->active
-                        = direction_anchor (self, direction, href,
-                                                    text_formatted, 0);
+                        = direction_a (self, direction, href,
+                                       text_formatted, 0);
                     }
                   else
                     formatted_button->passive = strdup (text_formatted);
@@ -8227,7 +8225,7 @@ convert_xref_commands (CONVERTER *self, const enum 
command_id cmd,
 {
   char *name = 0;
   HTML_ARG_FORMATTED *file_arg = 0;
-  const char *file = 0;
+  char *file = 0;
   const char *book = 0;
   const ELEMENT *arg_node = 0;
   const ELEMENT *target_node = 0;
@@ -8260,7 +8258,7 @@ convert_xref_commands (CONVERTER *self, const enum 
command_id cmd,
   if (file_arg && file_arg->formatted[AFT_type_filenametext]
       && strlen (file_arg->formatted[AFT_type_filenametext]))
     {
-      file = file_arg->formatted[AFT_type_filenametext];
+      file = strdup (file_arg->formatted[AFT_type_filenametext]);
     }
 
   if (args_formatted->number > 4
@@ -8367,7 +8365,7 @@ convert_xref_commands (CONVERTER *self, const enum 
command_id cmd,
           attribute_class = html_attribute_class (self, "a", classes);
           text_append (&reference_element->text, attribute_class);
           text_printf (&reference_element->text, " href=\"%s\">%s</a>",
-                                              href, name);
+                                                 href, name);
           free (attribute_class);
           destroy_strings_list (classes);
         }
@@ -8375,6 +8373,7 @@ convert_xref_commands (CONVERTER *self, const enum 
command_id cmd,
         {
           text_append (&reference_element->text, name);
         }
+      free (href);
 
       add_element_to_named_string_element_list (substrings,
                           "reference_name", reference_element);
@@ -8494,8 +8493,12 @@ convert_xref_commands (CONVERTER *self, const enum 
command_id cmd,
             }
         }
 
-      if (label_element && !html_in_string (self))
-        href = html_command_href (self, label_element, 0, element, 0);
+      if (label_element)
+        {
+          if (!html_in_string (self))
+            href = html_command_href (self, label_element, 0, element, 0);
+          destroy_element (label_element);
+        }
 
       if (href)
         {
@@ -8684,13 +8687,11 @@ convert_xref_commands (CONVERTER *self, const enum 
command_id cmd,
       convert_to_html_internal (self, tree, result, context_str);
       remove_element_from_list (&self->tree_to_build, tree);
       free (context_str);
+      /* should destroy reference_element and book_element */
+      destroy_element_and_children (tree);
     }
 
-  if (reference_element)
-    destroy_element (reference_element);
-  if (book_element)
-    destroy_element (book_element);
-
+  free (file);
   free (name);
 }
 



reply via email to

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