texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sun, 10 Mar 2024 04:51:21 -0400 (EDT)

branch: master
commit 5bb3dcb93b2e73f73f632382ef557b1c1de7efaf
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Mar 10 09:48:50 2024 +0100

    Put dircategory_direntry in global_commands
    
    * tp/Texinfo/ParserNonXS.pm (_register_global_command)
    (_handle_block_command), tp/Texinfo/XS/main/document_types.h,
    tp/Texinfo/XS/main/utils.c (delete_global_info)
    (delete_global_commands), tp/Texinfo/XS/parsetexi/handle_commands.c
    (handle_line_command, handle_block_command),
    tp/Texinfo/XS/parsetexi/parser.c (store_document),
    tp/Texinfo/XS/main/command_data.awk, tp/Texinfo/Convert/IXIN.pm,
    tp/Texinfo/Convert/Info.pm (_info_header): put dircategory_direntry
    in global_commands.
    
    * tp/Texinfo/XS/main/DocumentXS.xs (document_global_information),
    tp/Texinfo/Document.pm (global_information),
    tp/Texinfo/XS/main/build_perl_info.c (build_global_commands)
    (document_global_information): remove optional argument of
    global_information.  Remove build_global_info_tree_info.  Update
    callers.
---
 ChangeLog                                 | 21 +++++++++++
 tp/Texinfo/Convert/IXIN.pm                | 10 +++---
 tp/Texinfo/Convert/Info.pm                |  6 ++--
 tp/Texinfo/Document.pm                    | 21 +++++++----
 tp/Texinfo/ParserNonXS.pm                 |  4 +--
 tp/Texinfo/XS/main/DocumentXS.xs          |  2 +-
 tp/Texinfo/XS/main/build_perl_info.c      | 60 ++++++++-----------------------
 tp/Texinfo/XS/main/build_perl_info.h      |  2 +-
 tp/Texinfo/XS/main/command_data.awk       |  1 +
 tp/Texinfo/XS/main/document_types.h       |  1 -
 tp/Texinfo/XS/main/utils.c                |  3 +-
 tp/Texinfo/XS/parsetexi/handle_commands.c |  4 +--
 tp/Texinfo/XS/parsetexi/parser.c          |  4 +--
 tp/t/test_utils.pl                        |  2 +-
 tp/texi2any.pl                            |  2 +-
 15 files changed, 69 insertions(+), 74 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index de5bfbc57c..d2556701f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2024-03-10  Patrice Dumas  <pertusus@free.fr>
+
+       Put dircategory_direntry in global_commands
+
+       * tp/Texinfo/ParserNonXS.pm (_register_global_command)
+       (_handle_block_command), tp/Texinfo/XS/main/document_types.h,
+       tp/Texinfo/XS/main/utils.c (delete_global_info)
+       (delete_global_commands), tp/Texinfo/XS/parsetexi/handle_commands.c
+       (handle_line_command, handle_block_command),
+       tp/Texinfo/XS/parsetexi/parser.c (store_document),
+       tp/Texinfo/XS/main/command_data.awk, tp/Texinfo/Convert/IXIN.pm,
+       tp/Texinfo/Convert/Info.pm (_info_header): put dircategory_direntry
+       in global_commands.
+
+       * tp/Texinfo/XS/main/DocumentXS.xs (document_global_information),
+       tp/Texinfo/Document.pm (global_information),
+       tp/Texinfo/XS/main/build_perl_info.c (build_global_commands)
+       (document_global_information): remove optional argument of
+       global_information.  Remove build_global_info_tree_info.  Update
+       callers.
+
 2024-03-10  Patrice Dumas  <pertusus@free.fr>
 
        Add setfilename value to global_info
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index 2df145528c..0c8a2b5836 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -383,18 +383,20 @@ sub output_ixin($$)
   my $sections_list;
   my $identifiers_target;
   my $indices_information;
+  my $global_commands;
   if ($self->{'document'}) {
     $document_info = $self->{'document'}->global_information();
     $floats = $self->{'document'}->floats_information();
     $sections_list = $self->{'document'}->sections_list();
     $identifiers_target = $self->{'document'}->labels_information();
     $indices_information = $self->{'document'}->indices_information();
+    $global_commands = $self->{'document'}->global_commands_information();
   }
 
-  if ($document_info and $document_info->{'dircategory_direntry'}) {
+  if ($global_commands and $global_commands->{'dircategory_direntry'}) {
     my $current_category;
     foreach my $dircategory_direntry
-                  (@{$document_info->{'dircategory_direntry'}}) {
+                  (@{$global_commands->{'dircategory_direntry'}}) {
       if ($dircategory_direntry->{'cmdname'}
           and $dircategory_direntry->{'cmdname'} eq 'dircategory') {
         if ($current_category) {
@@ -426,10 +428,6 @@ sub output_ixin($$)
   my %setting_commands_defaults;
   # FIXME this code is unclear and probably needs to be fixed if developemnt
   # resumes.  Maybe could be replaced by set_global_document_commands.
-  my $global_commands;
-  if ($self->{'document'}) {
-    $global_commands = $self->{'document'}->global_commands_information();
-  }
   foreach my $global_command (keys(%{$global_commands})) {
     if ((($Texinfo::Commands::line_commands{$global_command}
           and $Texinfo::Commands::line_commands{$global_command} eq 'specific')
diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm
index add6d4c844..a2e5039073 100644
--- a/tp/Texinfo/Convert/Info.pm
+++ b/tp/Texinfo/Convert/Info.pm
@@ -433,10 +433,8 @@ sub _info_header($$$)
   $self->_stream_output($result, $paragraph);
 
   my $global_commands;
-  my $document_info;
   if ($self->{'document'}) {
     $global_commands = $self->{'document'}->global_commands_information();
-    $document_info = $self->{'document'}->global_information();
   }
   # format @copying using the last value of the preamble.
   my @informative_global_commands = $self->get_informative_global_commands();
@@ -451,9 +449,9 @@ sub _info_header($$$)
   }
   $self->set_global_document_commands('before', \@informative_global_commands);
 
-  if ($document_info->{'dircategory_direntry'}) {
+  if ($global_commands->{'dircategory_direntry'}) {
     $self->{'ignored_commands'}->{'direntry'} = 0;
-    foreach my $command (@{$document_info->{'dircategory_direntry'}}) {
+    foreach my $command (@{$global_commands->{'dircategory_direntry'}}) {
       if ($command->{'cmdname'} eq 'dircategory') {
         if ($command->{'args'} and @{$command->{'args'}}
             and defined($command->{'args'}->[0]->{'contents'})) {
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index 0653219976..15622323f1 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -195,7 +195,7 @@ sub global_commands_information($)
   return $self->{'commands_info'};
 }
 
-sub global_information($;$)
+sub global_information($)
 {
   my $self = shift;
   return $self->{'global_info'};
@@ -503,10 +503,11 @@ Texinfo::Document - Texinfo document tree and information
   my $identifier_target = $document->labels_information();
   # A hash reference, keys are @-command names, value is an
   # array reference holding all the corresponding @-commands.
+  # Also contains dircategory and direntry list.
   my $global_commands_information
                  = $document->global_commands_information();
   # a hash reference on document information (encodings,
-  # input file name, dircategory and direntry list, for example).
+  # input file name, for example).
   my $global_information = $document->global_information();
 
 =head1 NOTES
@@ -557,11 +558,6 @@ The I<$info> returned is a hash reference.  The possible 
keys are
 
 =over
 
-=item dircategory_direntry
-
-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
@@ -601,6 +597,17 @@ I<$commands> is an hash reference.  The keys are @-command 
names.  The
 associated values are array references containing all the corresponding
 tree elements.
 
+The following list of commands is also available as a key:
+
+=over
+
+=item dircategory_direntry
+
+An array of successive C<@dircategory> and C<@direntry> as they appear
+in the document.
+
+=back
+
 =back
 
 All the @-commands that have an associated label (so can be the
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index e3ed92419c..1a2129591e 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -5797,7 +5797,7 @@ sub _handle_line_command($$$$$$)
   _register_global_command($self, $command_e, $source_info)
     if $command_e;
   if ($command eq 'dircategory') {
-    push @{$self->{'global_info'}->{'dircategory_direntry'}}, $command_e;
+    push @{$self->{'global_commands'}->{'dircategory_direntry'}}, $command_e;
   }
   return ($current, $line, $retval, $command_e);
 }
@@ -5885,7 +5885,7 @@ sub _handle_block_command($$$$$)
     }
     if ($block_commands{$command} eq 'menu') {
       $self->_push_context('ct_preformatted', $command);
-      push @{$self->{'global_info'}->{'dircategory_direntry'}}, $block
+      push @{$self->{'global_commands'}->{'dircategory_direntry'}}, $block
         if ($command eq 'direntry');
       if ($self->{'current_node'}) {
         if ($command eq 'direntry') {
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index ae443e8926..7dfc1c114b 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -221,7 +221,7 @@ document_tree (SV *document_in, int handler_only=0)
         RETVAL
 
 SV *
-document_global_information (SV *document_in, int simple_info=0)
+document_global_information (SV *document_in)
 
 SV *
 document_indices_information (SV *document_in)
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 46b95ca194..b2bcf592e8 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1033,30 +1033,6 @@ build_global_info (GLOBAL_INFO *global_info_ref,
   return hv;
 }
 
-/* global info that requires a built tree */
-void
-build_global_info_tree_info (HV *hv, GLOBAL_INFO *global_info_ref)
-{
-  int i;
-  ELEMENT *e;
-  GLOBAL_INFO global_info = *global_info_ref;
-
-  dTHX;
-
-  if (global_info.dircategory_direntry.number > 0)
-    {
-      AV *av = newAV ();
-      hv_store (hv, "dircategory_direntry", strlen ("dircategory_direntry"),
-                newRV_noinc ((SV *) av), 0);
-      for (i = 0; i < global_info.dircategory_direntry.number; i++)
-        {
-          e = global_info.dircategory_direntry.list[i];
-          if (e->hv)
-            av_push (av, newRV_inc ((SV *) e->hv));
-        }
-    }
-}
-
 /* Return object to be used as 'commands_info', which holds references
    to tree elements. */
 HV *
@@ -1087,6 +1063,20 @@ build_global_commands (GLOBAL_COMMANDS 
*global_commands_ref)
 
 #undef GLOBAL_UNIQUE_CASE
 
+  /* list of direntry and dircategory */
+  if (global_commands.dircategory_direntry.number > 0)
+    {
+      AV *av = newAV ();
+      hv_store (hv, "dircategory_direntry", strlen ("dircategory_direntry"),
+                newRV_noinc ((SV *) av), 0);
+      for (i = 0; i < global_commands.dircategory_direntry.number; i++)
+        {
+          e = global_commands.dircategory_direntry.list[i];
+          if (e->hv)
+            av_push (av, newRV_inc ((SV *) e->hv));
+        }
+    }
+
   /* The following are arrays of elements. */
 
   if (global_commands.footnotes.number > 0)
@@ -1430,7 +1420,6 @@ fill_document_hv (HV *hv, size_t document_descriptor, int 
no_store)
 
   hv_info = build_global_info (document->global_info,
                                document->global_commands);
-  build_global_info_tree_info (hv_info, document->global_info);
 
   hv_commands_info = build_global_commands (document->global_commands);
 
@@ -1699,11 +1688,8 @@ 
BUILD_PERL_DOCUMENT_LIST(labels_list,labels_list,labels_list,build_target_elemen
 
 #undef BUILD_PERL_DOCUMENT_LIST
 
-/* if SIMPLE_INFO is set, do not return information that requires buildin
-   the Perl tree and add information on few commands such that commands
-   information needs not to be called */
 SV *
-document_global_information (SV *document_in, int simple_info)
+document_global_information (SV *document_in)
 {
   HV *document_hv;
   SV *result_sv = 0;
@@ -1715,28 +1701,12 @@ document_global_information (SV *document_in, int 
simple_info)
 
   DOCUMENT *document = get_sv_document_document (document_in,
                                      "document_global_information");
-  if (simple_info)
-    { /* no caching in that case, but no need of building the
-         full document.  Should only be called with this argument
-         from the main program */
-      if (document)
-        {
-          HV *result_hv = build_global_info (document->global_info,
-                                             document->global_commands);
-          return newRV_inc ((SV *) result_hv);
-        }
-      else
-        return newSV (0);
-    }
-
   if (document)
     {
-      store_texinfo_tree (document, document_hv);
       if (document->modified_information & F_DOCM_global_info)
         {
           HV *result_hv = build_global_info (document->global_info,
                                              document->global_commands);
-          build_global_info_tree_info (result_hv, document->global_info);
           result_sv = newRV_inc ((SV *) result_hv);
           hv_store (document_hv, key, strlen (key), result_sv, 0);
           document->modified_information &= ~F_DOCM_global_info;
diff --git a/tp/Texinfo/XS/main/build_perl_info.h 
b/tp/Texinfo/XS/main/build_perl_info.h
index 7de78707a4..80d881513f 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -59,7 +59,7 @@ SV *document_floats_information (SV *document_in);
 SV *document_internal_references_information (SV *document_in);
 SV *document_labels_list (SV *document_in);
 
-SV *document_global_information (SV *document_in, int simple_info);
+SV *document_global_information (SV *document_in);
 
 void pass_document_parser_errors_to_registrar (int document_descriptor,
                                                SV *parser_sv);
diff --git a/tp/Texinfo/XS/main/command_data.awk 
b/tp/Texinfo/XS/main/command_data.awk
index f5e7f29c47..04c7ef7e66 100644
--- a/tp/Texinfo/XS/main/command_data.awk
+++ b/tp/Texinfo/XS/main/command_data.awk
@@ -267,6 +267,7 @@ END {
 
     print global_unique_commands_struct_str   > GCT
     print "   /* Arrays of elements */"       > GCT
+    print "   ELEMENT_LIST dircategory_direntry;\n" > GCT
     print "   ELEMENT_LIST floats;"                > GCT
     print "   ELEMENT_LIST footnotes;\n"           > GCT
     print global_multi_commands_struct_str    > GCT
diff --git a/tp/Texinfo/XS/main/document_types.h 
b/tp/Texinfo/XS/main/document_types.h
index 2817aff9cb..49f05e2b1d 100644
--- a/tp/Texinfo/XS/main/document_types.h
+++ b/tp/Texinfo/XS/main/document_types.h
@@ -69,7 +69,6 @@ typedef struct GLOBAL_INFO {
     char *input_directory;
     char *input_encoding_name;
     int sections_level_modifier;
-    ELEMENT_LIST dircategory_direntry; /* an array of elements */
     /* Ignored characters for index sort key */
     IGNORED_CHARS ignored_chars;
     STRING_LIST included_files;
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 1a7aa133c1..86bcb2817f 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -1058,7 +1058,6 @@ 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);
@@ -1076,6 +1075,8 @@ delete_global_commands (GLOBAL_COMMANDS 
*global_commands_ref)
 {
   GLOBAL_COMMANDS global_commands = *global_commands_ref;
 
+  free (global_commands.dircategory_direntry.list);
+
 #define GLOBAL_CASE(cmx) \
   free (global_commands.cmx.list)
 
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c 
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 43ac2391df..d83bff3067 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -967,7 +967,7 @@ handle_line_command (ELEMENT *current, char **line_inout,
   if (command_e)
     register_global_command (command_e);
   if (cmd == CM_dircategory)
-    add_to_element_list (&global_info.dircategory_direntry, command_e);
+    add_to_element_list (&global_commands.dircategory_direntry, command_e);
 
 funexit:
   *line_inout = line;
@@ -1102,7 +1102,7 @@ handle_block_command (ELEMENT *current, char **line_inout,
           push_context (ct_preformatted, cmd);
 
           if (cmd == CM_direntry)
-            add_to_element_list (&global_info.dircategory_direntry,
+            add_to_element_list (&global_commands.dircategory_direntry,
                                  block);
 
           if (current_node)
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index a84aafe584..1bf72bb757 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -2569,10 +2569,10 @@ store_document (ELEMENT *root)
           add_to_element_list (&doc_global_##type->cmd, e);        \
         }                                                               \
     }
-  COPY_GLOBAL_ARRAY(info,dircategory_direntry);
-
   memcpy (doc_global_commands, &global_commands, sizeof (GLOBAL_COMMANDS));
 
+  COPY_GLOBAL_ARRAY(commands,dircategory_direntry);
+
   #define GLOBAL_CASE(cmd) \
    COPY_GLOBAL_ARRAY(commands,cmd)
 
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 67fd32c4d2..a5ac8a1a10 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1049,7 +1049,7 @@ sub test($$)
     Texinfo::Transformations::fill_gaps_in_sectioning($tree);
   }
 
-  my $document_information = $document->global_information(1);
+  my $document_information = $document->global_information();
 
   Texinfo::Common::set_output_encodings($main_configuration,
                                         $document);
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index f8600004ba..7f6327f504 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1511,7 +1511,7 @@ while(@input_files) {
     goto NEXT;
   }
 
-  my $document_information = $document->global_information(1);
+  my $document_information = $document->global_information();
   if (get_conf('TRACE_INCLUDES')) {
     handle_errors($parser->errors(), $error_count, \@opened_files);
     my $included_file_paths = $document_information->{'included_files'};



reply via email to

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