texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Fri, 26 Jan 2024 06:36:17 -0500 (EST)

branch: master
commit 123acd36abcc1c6e205f0d6f01cd626bd5eafb96
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Jan 26 11:55:26 2024 +0100

    Gather include file paths in document global information
    
    * tp/Texinfo/ParserNonXS.pm (_end_line_misc_line),
    tp/Texinfo/XS/main/build_perl_info.c (build_global_info),
    tp/Texinfo/XS/main/document_types.h (GLOBAL_INFO),
    tp/Texinfo/XS/main/utils.c (delete_global_info),
    tp/Texinfo/XS/parsetexi/end_line.c (end_line_misc_line),
    tp/Texinfo/XS/parsetexi/parser.c (store_document): store include file
    paths in included_files global information new field.
---
 ChangeLog                            | 12 ++++++++
 tp/Texinfo/Document.pm               |  5 ++++
 tp/Texinfo/ParserNonXS.pm            |  1 +
 tp/Texinfo/XS/main/build_perl_info.c | 58 ++++++++++++++++++++----------------
 tp/Texinfo/XS/main/document_types.h  |  1 +
 tp/Texinfo/XS/main/utils.c           |  1 +
 tp/Texinfo/XS/parsetexi/end_line.c   |  1 +
 tp/Texinfo/XS/parsetexi/parser.c     |  3 ++
 8 files changed, 57 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e7097c864b..9ec469043c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-01-26  Patrice Dumas  <pertusus@free.fr>
+
+       Gather include file paths in document global information
+
+       * tp/Texinfo/ParserNonXS.pm (_end_line_misc_line),
+       tp/Texinfo/XS/main/build_perl_info.c (build_global_info),
+       tp/Texinfo/XS/main/document_types.h (GLOBAL_INFO),
+       tp/Texinfo/XS/main/utils.c (delete_global_info),
+       tp/Texinfo/XS/parsetexi/end_line.c (end_line_misc_line),
+       tp/Texinfo/XS/parsetexi/parser.c (store_document): store include file
+       paths in included_files global information new field.
+
 2024-01-26  Patrice Dumas  <pertusus@free.fr>
 
        * doc/texi2any_api.texi (Getting Constants), tp/Texinfo/Common.pm
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index da1338efc2..50c109e9e6 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -405,6 +405,11 @@ The I<$info> returned is a hash reference.  The possible 
keys are
 An array of successive C<@dircategory> and C<@direntry> as they appear
 in the document.
 
+=item included_files
+
+An array of included file paths as they appear in the document.  Binary
+strings.
+
 =item input_encoding_name
 
 =item input_perl_encoding
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 20c0561cca..4f222e5f45 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -3583,6 +3583,7 @@ sub _end_line_misc_line($$$)
             $include_source_mark = {'sourcemark_type' => $command,
                                     'status' => 'start'};
             $self->{'input'}->[0]->{'input_source_mark'} = 
$include_source_mark;
+            push @{$self->{'global_info'}->{'included_files'}}, 
$included_file_path;
           } else {
             my $decoded_file_path
                 = Encode::decode($file_name_encoding, $included_file_path);
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 0e4ed18616..e8f64f05f2 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -888,6 +888,30 @@ build_index_data (INDEX **index_names_in)
 }
 
 
+AV *
+build_string_list (STRING_LIST *strings_list, enum sv_string_type type)
+{
+  AV *av;
+  int i;
+
+  dTHX;
+
+  av = newAV ();
+
+  for (i = 0; i < strings_list->number; i++)
+    {
+      char *value = strings_list->list[i];
+      if (!value)
+        av_push (av, newSV (0));
+      else if (type == svt_char)
+        av_push (av, newSVpv_utf8 (value, 0));
+      else
+        av_push (av, newSVpv_byte (value, 0));
+    }
+  return av;
+}
+
+
 /* Return object to be used as 'info', retrievable with the
    'global_information' function. */
 HV *
@@ -916,6 +940,15 @@ build_global_info (GLOBAL_INFO *global_info_ref,
     hv_store (hv, "input_perl_encoding", strlen ("input_perl_encoding"),
               newSVpv (global_info.input_perl_encoding, 0), 0);
 
+  if (global_info.included_files.number)
+    {
+      AV *av = build_string_list (&global_info.included_files, svt_byte);
+      hv_store (hv, "included_files", strlen ("included_files"),
+                newRV_noinc ((SV *) av), 0);
+    }
+
+  build_additional_info (hv, &global_info.other_info, 0, &nr_info);
+
   /* duplicate information with global_commands to avoid needing to use
      global_commands and build tree elements in other codes, for
      information useful for structuring and transformation codes */
@@ -932,8 +965,6 @@ build_global_info (GLOBAL_INFO *global_info_ref,
                 newSVpv (language, 0), 0);
     }
 
-  build_additional_info (hv, &global_info.other_info, 0, &nr_info);
-
   return hv;
 }
 
@@ -1620,29 +1651,6 @@ build_integer_stack (INTEGER_STACK *integer_stack)
   return av;
 }
 
-AV *
-build_string_list (STRING_LIST *strings_list, enum sv_string_type type)
-{
-  AV *av;
-  int i;
-
-  dTHX;
-
-  av = newAV ();
-
-  for (i = 0; i < strings_list->number; i++)
-    {
-      char *value = strings_list->list[i];
-      if (!value)
-        av_push (av, newSV (0));
-      else if (type == svt_char)
-        av_push (av, newSVpv_utf8 (value, 0));
-      else
-        av_push (av, newSVpv_byte (value, 0));
-    }
-  return av;
-}
-
 SV *
 build_filenames (FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
 {
diff --git a/tp/Texinfo/XS/main/document_types.h 
b/tp/Texinfo/XS/main/document_types.h
index c3f9c56622..56cbfd449c 100644
--- a/tp/Texinfo/XS/main/document_types.h
+++ b/tp/Texinfo/XS/main/document_types.h
@@ -57,6 +57,7 @@ typedef struct GLOBAL_INFO {
     ELEMENT_LIST dircategory_direntry; /* an array of elements */
     /* Ignored characters for index sort key */
     IGNORED_CHARS ignored_chars;
+    STRING_LIST included_files;
 
     /* remaining, in general passed to/from perl but not used in C */
     ASSOCIATED_INFO other_info;
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index b2fbe5aeb3..877b242e01 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -1009,6 +1009,7 @@ delete_global_info (GLOBAL_INFO *global_info_ref)
   GLOBAL_INFO global_info = *global_info_ref;
 
   free (global_info.dircategory_direntry.list);
+  free_strings_list (&global_info.included_files);
 
   free (global_info.input_encoding_name);
   free (global_info.input_file_name);
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c 
b/tp/Texinfo/XS/parsetexi/end_line.c
index 4fe9ce94f4..2e949f551b 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -1296,6 +1296,7 @@ end_line_misc_line (ELEMENT *current)
                       include_source_mark = new_source_mark (SM_type_include);
                       include_source_mark->status = SM_status_start;
                       set_input_source_mark (include_source_mark);
+                      add_string (fullpath, &global_info.included_files);
                     }
                   free (fullpath);
                 }
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index e62c218e68..fc5ac03372 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -2599,6 +2599,9 @@ store_document (ELEMENT *root)
   memset (&parser_float_list, 0, sizeof (FLOAT_RECORD_LIST));
 
   forget_internal_xrefs ();
+
+  memset (&global_info.included_files, 0, sizeof (STRING_LIST));
+
   forget_small_strings ();
   forget_errors ();
 



reply via email to

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