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


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/convert_html.c (HTML_COMMAND_STRUCT) (register_format_context_command, convert_to_html_internal): set context command context string dynamically.
Date: Sun, 12 Nov 2023 07:09:05 -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 d4a6803189 * tp/Texinfo/XS/convert/convert_html.c 
(HTML_COMMAND_STRUCT) (register_format_context_command, 
convert_to_html_internal): set context command context string dynamically.
d4a6803189 is described below

commit d4a6803189551345f1365bc0a66e160bd5f658e5
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 12 13:07:43 2023 +0100

    * tp/Texinfo/XS/convert/convert_html.c (HTML_COMMAND_STRUCT)
    (register_format_context_command, convert_to_html_internal): set
    context command context string dynamically.
    
    * tp/Texinfo/XS/convert/converter.c (set_file_path): add more messages
    for file paths already set/reset, as in perl, and handle memory
    correctly in that case.
---
 ChangeLog                            | 10 ++++++++++
 tp/Texinfo/Convert/Converter.pm      |  5 +++--
 tp/Texinfo/XS/convert/convert_html.c | 12 +++++-------
 tp/Texinfo/XS/convert/converter.c    | 20 +++++++++++++++++++-
 tp/Texinfo/XS/main/translations.c    |  8 +++++++-
 5 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2b27d88939..728ff498e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-11-12  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/convert_html.c (HTML_COMMAND_STRUCT)
+       (register_format_context_command, convert_to_html_internal): set
+       context command context string dynamically.
+
+       * tp/Texinfo/XS/convert/converter.c (set_file_path): add more messages
+       for file paths already set/reset, as in perl, and handle memory
+       correctly in that case.
+
 2023-11-12  Gavin Smith <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/XS/xspara.c (xspara__add_next, xspara_add_next):
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 62098716ab..166886a411 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -874,8 +874,9 @@ sub set_file_path($$$;$)
       $filepath = $filename;
     }
   }
-  # should not happen, the file path should be set only once
-  # per file name.
+  # the file path should be set only once per file name.  With
+  # CASE_INSENSITIVE_FILENAMES the same file path can appear more
+  # than once when files differ in case.
   if (defined($self->{'out_filepaths'}->{$filename})) {
     if ($self->{'out_filepaths'}->{$filename} eq $filepath) {
       print STDERR "set_file_path: filepath set: $filepath\n"
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 4b200cd9e1..ef474c7268 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -86,7 +86,6 @@ CMD_VARIETY command_special_unit_variety[] = {
 typedef struct HTML_COMMAND_STRUCT {
     unsigned long flags;
     char *pre_class;
-    char *format_context;
 } HTML_COMMAND_STRUCT;
 
 static HTML_COMMAND_STRUCT html_commands_data[BUILTIN_CMD_NUMBER];
@@ -690,11 +689,6 @@ static enum command_id HTML_align_cmd[] = {
 void
 register_format_context_command (enum command_id cmd)
 {
-  char *context_str;
-
-  xasprintf (&context_str, "@%s", builtin_command_data[cmd].cmdname);
-
-  html_commands_data[cmd].format_context = context_str;
   html_commands_data[cmd].flags |= HF_format_context;
 }
 
@@ -3227,9 +3221,13 @@ convert_to_html_internal (CONVERTER *self, ELEMENT 
*element,
 
           if (html_commands_data[data_cmd].flags & HF_format_context)
             {
+              char *context_str;
+              xasprintf (&context_str, "@%s",
+                         builtin_command_data[data_cmd].cmdname);
               push_html_formatting_context (
                          &top_document_ctx->formatting_context,
-                         html_commands_data[cmd].format_context);
+                         context_str);
+              free (context_str);
               self->modified_state |= HMSF_formatting_context;
             }
 
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index edee23c94f..38f0982027 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -505,7 +505,25 @@ set_file_path (CONVERTER *self, char *filename, char 
*filepath,
   else
     filepath_str = filepath;
 
-  output_unit_file->filepath = strdup (filepath_str);
+  if (output_unit_file->filepath)
+    {
+      if (!strcmp (output_unit_file->filepath, filepath_str))
+        {
+          if (self->conf->DEBUG > 0)
+            fprintf (stderr, "set_file_path: filepath set: %s\n",
+                             filepath_str);
+        }
+      else
+        {
+          if (self->conf->DEBUG > 0)
+            fprintf (stderr, "set_file_path: filepath reset: %s, %s\n",
+                             output_unit_file->filepath, filepath_str);
+          free (output_unit_file->filepath);
+          output_unit_file->filepath = strdup (filepath_str);
+        }
+    }
+  else
+    output_unit_file->filepath = strdup (filepath_str);
   if (free_filepath)
     free (filepath_str);
 }
diff --git a/tp/Texinfo/XS/main/translations.c 
b/tp/Texinfo/XS/main/translations.c
index 44dfb60a33..6500d17f27 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -174,11 +174,17 @@ translate_string (OPTIONS *options, const char * string,
       lang = "en";
     }
 
+
+  /*
+  return strdup (string);
+   */
+
   #ifndef ENABLE_NLS
   
   translated_string = strdup (string);
 
   #else
+  /* with the following code valgrind reports issues in perl memory */
 
   /* if a code calls setlocale and accesses global locale while perl
      uses per thread locale, the result is unpredictable.  So we switch to
@@ -564,12 +570,12 @@ replace_convert_substrings (char *translated_string,
     }
 
 
+/*
   {
     char *result_texi = convert_to_texinfo (document->tree);
     debug("XS|RESULT GDT %d: '%s'\n", document_descriptor, result_texi);
     free (result_texi);
   }
-/*
 */
 
   return document_descriptor;



reply via email to

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