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/utils.c (add_string): return


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/utils.c (add_string): return the newly duplicated string.
Date: Sun, 17 Dec 2023 16:40:57 -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 fbc557973e * tp/Texinfo/XS/main/utils.c (add_string): return the newly 
duplicated string.
fbc557973e is described below

commit fbc557973e238086d5d41ea4c108f75ab0e315c4
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 17 22:40:52 2023 +0100

    * tp/Texinfo/XS/main/utils.c (add_string): return the newly duplicated
    string.
    
    * tp/Texinfo/XS/main/get_perl_info.c (get_line_message): replace
    strings in source_info by the strings saved in
    self->document->small_strings.
---
 ChangeLog                          |  9 +++++++++
 tp/Texinfo/XS/main/get_perl_info.c | 21 ++++++++++++++++-----
 tp/Texinfo/XS/main/utils.c         |  8 ++++++--
 tp/Texinfo/XS/main/utils.h         |  2 +-
 4 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2e32072d9a..19a5e0c38a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-12-17  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/utils.c (add_string): return the newly duplicated
+       string.
+
+       * tp/Texinfo/XS/main/get_perl_info.c (get_line_message): replace
+       strings in source_info by the strings saved in
+       self->document->small_strings.
+
 2023-12-17  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/call_html_perl_function.c: free memory/destroy
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index 705daa3d74..833ac33058 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -244,14 +244,25 @@ get_line_message (CONVERTER *self, enum error_type type, 
int continuation,
 {
   int do_warn = (self->conf->DEBUG > 1);
   SOURCE_INFO *source_info = get_source_info (error_location_info);
-  message_list_line_formatted_message (&self->error_messages,
-                                       type, continuation, source_info,
-                                       message, do_warn);
   if (source_info->file_name)
-    add_string (source_info->file_name, self->document->small_strings);
+    {
+      char *saved_string = add_string (source_info->file_name,
+                                       self->document->small_strings);
+      free (source_info->file_name);
+      source_info->file_name = saved_string;
+    }
 
   if (source_info->macro)
-    add_string (source_info->macro, self->document->small_strings);
+    {
+      char *saved_string = add_string (source_info->macro,
+                                       self->document->small_strings);
+      free (source_info->macro);
+      source_info->macro = saved_string;
+    }
+
+  message_list_line_formatted_message (&self->error_messages,
+                                       type, continuation, source_info,
+                                       message, do_warn);
 
   free (source_info);
 }
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 7d97b3d1a3..7e430443af 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -749,15 +749,19 @@ add_include_directory (char *input_filename, STRING_LIST 
*include_dirs_list)
   free (filename);
 }
 
-void
+char *
 add_string (const char *string, STRING_LIST *strings_list)
 {
+  char *result;
   if (strings_list->number == strings_list->space)
     {
       strings_list->list = realloc (strings_list->list,
                    sizeof (char *) * (strings_list->space += 5));
     }
-  strings_list->list[strings_list->number++] = strdup (string);
+  strings_list->list[strings_list->number] = strdup (string);
+  result = strings_list->list[strings_list->number];
+  strings_list->number++;
+  return result;
 }
 
 void
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index bf5bb57b19..df9e95704d 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -198,7 +198,7 @@ int is_content_empty (ELEMENT *tree, int 
do_not_ignore_index_entries);
 void clear_strings_list (STRING_LIST *strings);
 void free_strings_list (STRING_LIST *strings);
 void destroy_strings_list (STRING_LIST *strings);
-void add_string (const char *string, STRING_LIST *strings_list);
+char *add_string (const char *string, STRING_LIST *strings_list);
 void merge_strings (STRING_LIST *strings_list, STRING_LIST *merged_strings);
 size_t find_string (STRING_LIST *strings_list, const char *string);
 



reply via email to

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