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 de861425b2445cc2f85075c7fee70ce2bf95c64c
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Mar 10 09:01:02 2024 +0100

    Add setfilename value to global_info
    
    * tp/Texinfo/Convert/Converter.pm (determine_files_and_directory),
    tp/Texinfo/Convert/Text.pm (output), tp/Texinfo/ParserNonXS.pm
    (get_parser_info), tp/Texinfo/XS/main/build_perl_info.c
    (build_global_info): add the setfilename text argument to global_info
    as it is used to determine output file name.
---
 ChangeLog                            | 10 ++++++++++
 tp/TODO                              |  4 ----
 tp/Texinfo/Convert/Converter.pm      |  8 ++------
 tp/Texinfo/Convert/Text.pm           | 10 +++-------
 tp/Texinfo/ParserNonXS.pm            | 17 ++++++++++++++---
 tp/Texinfo/XS/main/build_perl_info.c |  9 +++++++++
 6 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a37371ae34..de5bfbc57c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-03-10  Patrice Dumas  <pertusus@free.fr>
+
+       Add setfilename value to global_info
+
+       * tp/Texinfo/Convert/Converter.pm (determine_files_and_directory),
+       tp/Texinfo/Convert/Text.pm (output), tp/Texinfo/ParserNonXS.pm
+       (get_parser_info), tp/Texinfo/XS/main/build_perl_info.c
+       (build_global_info): add the setfilename text argument to global_info
+       as it is used to determine output file name.
+
 2024-03-09  Patrice Dumas  <pertusus@free.fr>
 
        Do not call rebuild_document
diff --git a/tp/TODO b/tp/TODO
index bbec7977bb..d86dacc9a7 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -12,10 +12,6 @@ Before next release
 
 Check if LABEL identifier should be const
 
-Add setfilename
-$global_commands->{'setfilename'}->{'extra'}->{'text_arg'}
-to global_info / build_global_info
-
 Bugs
 ====
 
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index a68f1e7b37..e348538f32 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -695,12 +695,8 @@ sub determine_files_and_directory($$)
   my $setfilename;
   if (defined($self->get_conf('setfilename'))) {
     $setfilename = $self->get_conf('setfilename');
-  } elsif ($global_commands
-           and $global_commands->{'setfilename'}
-           and $global_commands->{'setfilename'}->{'extra'}
-           and 
defined($global_commands->{'setfilename'}->{'extra'}->{'text_arg'})) {
-    $setfilename
-      = $global_commands->{'setfilename'}->{'extra'}->{'text_arg'};
+  } elsif ($document_info and defined($document_info->{'setfilename'})) {
+    $setfilename = $document_info->{'setfilename'};
   }
 
   my $input_basename_for_outfile = $input_basename;
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 0075d9c823..a332da7f8e 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -911,13 +911,9 @@ sub output($$)
   $input_basename =~ s/\.te?x(i|info)?$//;
 
   my $setfilename;
-  $setfilename
-   = $global_commands->{'setfilename'}->{'extra'}->{'text_arg'}
-    if ($global_commands
-        and $global_commands->{'setfilename'}
-        and $global_commands->{'setfilename'}->{'extra'}
-        and defined($global_commands->{'setfilename'}
-                                              ->{'extra'}->{'text_arg'}));
+  if ($document_info and defined($document_info->{'setfilename'})) {
+    $setfilename = $document_info->{'setfilename'};
+  }
   my $outfile;
   if (!defined($self->{'OUTFILE'})) {
     if (defined($setfilename)) {
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 2d9038d89b..e3ed92419c 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -887,7 +887,21 @@ sub get_parser_info($)
   } else {
     $self->{'global_info'}->{'input_encoding_name'} = 'utf-8';
   }
+
   my $global_commands = $self->{'commands_info'};
+
+  # information based on commands commonly needed.
+  if ($global_commands->{'novalidate'}) {
+    $self->{'global_info'}->{'novalidate'} = 1;
+  }
+
+  if ($global_commands->{'setfilename'}
+      and $global_commands->{'setfilename'}->{'extra'}
+      and defined($global_commands->{'setfilename'}->{'extra'}->{'text_arg'})) 
{
+    $self->{'global_info'}->{'setfilename'}
+      = $global_commands->{'setfilename'}->{'extra'}->{'text_arg'};
+  }
+
   my $document_language
     = Texinfo::Common::get_global_document_command($global_commands,
                                                    'documentlanguage',
@@ -896,9 +910,6 @@ sub get_parser_info($)
     $self->{'global_info'}->{'documentlanguage'}
       = Texinfo::Common::informative_command_value($document_language);
   }
-  if ($global_commands->{'novalidate'}) {
-    $self->{'global_info'}->{'novalidate'} = 1;
-  }
 }
 
 # parse a texi file
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index ca73595169..46b95ca194 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1012,6 +1012,15 @@ build_global_info (GLOBAL_INFO *global_info_ref,
     hv_store (hv, "novalidate", strlen ("novalidate"),
               newSViv (1), 0);
 
+  if (global_commands.setfilename)
+    {
+      char *setfilename_text
+        = informative_command_value (global_commands.setfilename);
+      if (setfilename_text)
+      hv_store (hv, "setfilename", strlen ("setfilename"),
+                newSVpv_utf8 (setfilename_text, 0), 0);
+    }
+
   document_language = get_global_document_command (global_commands_ref,
                                        CM_documentlanguage, CL_preamble);
   if (document_language)



reply via email to

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