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/convert_utils.c (output_file


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/convert_utils.c (output_files_open_out), tp/Texinfo/XS/convert/convert_html.c (convert_output_output_unit_internal, html_node_redirections): add an output argument to output_files_open_out as in Perl, to get the information that a file was reused. Also, as in Perl, add the file path to opened_files only if not already there.
Date: Sat, 13 Apr 2024 18:24:35 -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 b44713788d * tp/Texinfo/XS/main/convert_utils.c 
(output_files_open_out), tp/Texinfo/XS/convert/convert_html.c 
(convert_output_output_unit_internal, html_node_redirections): add an output 
argument to output_files_open_out as in Perl, to get the information that a 
file was reused.  Also, as in Perl, add the file path to opened_files only if 
not already there.
b44713788d is described below

commit b44713788d791c6a1fa9350094134b02ed64aa15
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Apr 14 00:24:27 2024 +0200

    * tp/Texinfo/XS/main/convert_utils.c (output_files_open_out),
    tp/Texinfo/XS/convert/convert_html.c
    (convert_output_output_unit_internal, html_node_redirections): add an
    output argument to output_files_open_out as in Perl, to get the
    information that a file was reused.  Also, as in Perl, add the file
    path to opened_files only if not already there.
---
 ChangeLog                            | 11 ++++++++++-
 tp/Texinfo/XS/convert/convert_html.c | 10 ++++++++--
 tp/Texinfo/XS/main/convert_utils.c   | 12 ++++++++++--
 tp/Texinfo/XS/main/convert_utils.h   |  2 +-
 4 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4e777b7a87..0e3beaf3e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-04-13  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/convert_utils.c (output_files_open_out),
+       tp/Texinfo/XS/convert/convert_html.c
+       (convert_output_output_unit_internal, html_node_redirections): add an
+       output argument to output_files_open_out as in Perl, to get the
+       information that a file was reused.  Also, as in Perl, add the file
+       path to opened_files only if not already there.
+
 2024-04-13  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/build_perl_info.c
@@ -74,7 +83,7 @@
        * tp/Texinfo/Common.pm (output_files_open_out),
        tp/Texinfo/Convert/HTML.pm (_do_jslicenses_file): have
        output_files_open_out return the information that a file that was
-       already opened is opened agains, which means overwritting.  Add a
+       already opened is opened again, which means overwritting.  Add a
        warning in the case that can actually happen, with js licenses file.
 
        * tp/tests/formatting/list-of-tests (js_license_reuse_output_file):
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 405f3c9212..fecc4aa8f6 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -18618,12 +18618,15 @@ convert_output_output_unit_internal (CONVERTER *self,
       char *out_filepath = unit_file->filepath;
       char *path_encoding;
       char *open_error_message;
+      int overwritten_file;
 
       char *encoded_out_filepath = encoded_output_file_name (self->conf,
                                self->document->global_info, out_filepath,
                                                        &path_encoding, 0);
+      /* overwritten_file being set cannot happen */
       FILE *file_fh = output_files_open_out (&self->output_files_information,
-                               encoded_out_filepath, &open_error_message, 0);
+                               encoded_out_filepath, &open_error_message,
+                               &overwritten_file, 0);
       free (path_encoding);
       if (!file_fh)
         {
@@ -19049,6 +19052,7 @@ html_node_redirections (CONVERTER *self,
                   char *out_filepath;
                   char *path_encoding;
                   char *open_error_message;
+                  int overwritten_file;
 
                   add_to_files_source_info (files_source_info,
                                  redirection_filename, "redirection", 0,
@@ -19069,9 +19073,11 @@ html_node_redirections (CONVERTER *self,
                      = encoded_output_file_name (self->conf,
                                    self->document->global_info, out_filepath,
                                                            &path_encoding, 0);
+                  /* overwritten_file being set cannot happen */
                   FILE *file_fh
                     = output_files_open_out (&self->output_files_information,
-                               encoded_out_filepath, &open_error_message, 0);
+                               encoded_out_filepath, &open_error_message,
+                               &overwritten_file, 0);
                   free (path_encoding);
                   if (!file_fh)
                     {
diff --git a/tp/Texinfo/XS/main/convert_utils.c 
b/tp/Texinfo/XS/main/convert_utils.c
index 23a453a560..d3bb5ab835 100644
--- a/tp/Texinfo/XS/main/convert_utils.c
+++ b/tp/Texinfo/XS/main/convert_utils.c
@@ -782,18 +782,25 @@ clear_output_files_information (OUTPUT_FILES_INFORMATION 
*self)
  Returns
   - as return value, the opened filehandle, or 0 if opening failed,
   - in *error_message, the errno message or 0 if opening succeeded.
+  - in *overwritten_file, 1 if the FILE_PATH was already opened,
+    which means overwritting.
 */
 FILE *
 output_files_open_out (OUTPUT_FILES_INFORMATION *self, const char *file_path,
-                       char **error_message, int binary)
+                       char **error_message, int *overwritten_file, int binary)
 {
   FILE *stream_handle;
   *error_message = 0;
+  *overwritten_file = 0;
   if (!strcmp (file_path, "-"))
     {
       register_unclosed_file (self, file_path, stdout);
       return stdout;
     }
+
+  if (find_string (&self->opened_files, file_path))
+    *overwritten_file = 1;
+
   if (binary)
     stream_handle = fopen (file_path, "wb");
   else
@@ -806,7 +813,8 @@ output_files_open_out (OUTPUT_FILES_INFORMATION *self, 
const char *file_path,
   else
     {
       register_unclosed_file (self, file_path, stream_handle);
-      add_string (file_path, &self->opened_files);
+      if (!(*overwritten_file))
+        add_string (file_path, &self->opened_files);
     }
   return stream_handle;
 }
diff --git a/tp/Texinfo/XS/main/convert_utils.h 
b/tp/Texinfo/XS/main/convert_utils.h
index d5028df204..bcbfa278f3 100644
--- a/tp/Texinfo/XS/main/convert_utils.h
+++ b/tp/Texinfo/XS/main/convert_utils.h
@@ -55,7 +55,7 @@ char *encoded_output_file_name (const OPTIONS *options,
 
 FILE *output_files_open_out (OUTPUT_FILES_INFORMATION *self,
                              const char *file_path,
-                             char **error_message, int binary);
+                     char **error_message, int *overwritten_file, int binary);
 void output_files_register_closed (OUTPUT_FILES_INFORMATION *self,
                                    const char *file_path);
 void free_output_files_information (OUTPUT_FILES_INFORMATION *self);



reply via email to

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