texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Config.pm Texinfo::MainConfig (new,


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Config.pm Texinfo::MainConfig (new, get_conf, set_conf) (register_XS_document_main_configuration), tp/t/test_sort.t: remove the 'standalone' case, now that it is not used anymore. Simplify the Texinfo::MainConfig object structure.
Date: Sun, 07 Apr 2024 19:36:37 -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 e0c04573b4 * tp/Texinfo/Config.pm Texinfo::MainConfig (new, get_conf, 
set_conf) (register_XS_document_main_configuration), tp/t/test_sort.t: remove 
the 'standalone' case, now that it is not used anymore.  Simplify the 
Texinfo::MainConfig object structure.
e0c04573b4 is described below

commit e0c04573b45c959aafc0fd1fe97fe529a8411396
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Apr 8 01:36:27 2024 +0200

    * tp/Texinfo/Config.pm Texinfo::MainConfig (new, get_conf, set_conf)
    (register_XS_document_main_configuration), tp/t/test_sort.t: remove
    the 'standalone' case, now that it is not used anymore.  Simplify the
    Texinfo::MainConfig object structure.
---
 ChangeLog            |  7 +++++
 tp/Texinfo/Config.pm | 76 +++++++++++++++++-----------------------------------
 tp/t/test_sort.t     |  2 +-
 tp/t/test_utils.pl   |  3 ++-
 4 files changed, 35 insertions(+), 53 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0a1d80f478..fb3991379e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-04-07  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Config.pm Texinfo::MainConfig (new, get_conf, set_conf)
+       (register_XS_document_main_configuration), tp/t/test_sort.t: remove
+       the 'standalone' case, now that it is not used anymore.  Simplify the
+       Texinfo::MainConfig object structure.
+
 2024-04-07  Patrice Dumas  <pertusus@free.fr>
 
        * tp/t/test_utils.pl (test): set main_configuration as in the main
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index bdd8e64c76..0e6f5fe201 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -832,31 +832,17 @@ sub GNUT_reinitialize_init_files()
 #####################################################################
 # the objective of this small package is to be in another
 # scope than init files and setup blessed objects that can call
-# get_conf() and set_conf() methods like a parser or a converter.
+# get_conf() and set_conf() methods.
 #
-# For the main program, there is also the need to have
-# access to configuration options in order to have get_conf()
-# return the same as Texinfo::Config::texinfo_get_conf().
-# This is obtained by calling new() without argument.
-#
-# In tests the situation is different as nothing from the
-# Texinfo::Config space is used, it is assumed that the
-# configuration is available as a hash reference key
-# value.  This is obtained by calling new() with an hash
-# reference argument.
+# There is also the need to have access to configuration options
+# in order to have get_conf() return the same as
+# Texinfo::Config::texinfo_get_conf().
 package Texinfo::MainConfig;
 
-sub new(;$)
+sub new()
 {
-  my $options = shift;
-  my $config;
-  if (defined($options)) {
-    # creates a new object based on input hash reference
-    $config = {'standalone' => 1, 'config' => {%$options}};
-  } else {
-    # use Texinfo::Config
-    $config = {'standalone' => 0, 'config' => {}};
-  }
+  # setup additional config to be used with other Texinfo::Config information.
+  my $config = {};
   bless $config;
   return $config;
 }
@@ -866,22 +852,16 @@ sub get_conf($$)
   my $self = shift;
   my $var = shift;
 
-  if ($self->{'standalone'}) {
-    if (defined($self->{'config'}->{$var})) {
-      return $self->{'config'}->{$var};
-    }
-  } else {
-    # as get_conf, but with self having precedence on
-    # main program defaults
-    if (exists($cmdline_options->{$var})) {
-      return $cmdline_options->{$var};
-    } elsif (exists($init_files_options->{$var})) {
-      return $init_files_options->{$var};
-    } elsif (exists($self->{'config'}->{$var})) {
-      return $self->{'config'}->{$var};
-    } elsif (exists($main_program_default_options->{$var})) {
-      return $main_program_default_options->{$var};
-    }
+  # as get_conf, but with self having precedence on
+  # main program defaults
+  if (exists($cmdline_options->{$var})) {
+    return $cmdline_options->{$var};
+  } elsif (exists($init_files_options->{$var})) {
+    return $init_files_options->{$var};
+  } elsif (exists($self->{$var})) {
+    return $self->{$var};
+  } elsif (exists($main_program_default_options->{$var})) {
+    return $main_program_default_options->{$var};
   }
   return undef;
 }
@@ -891,7 +871,7 @@ sub set_conf($$$)
   my $self = shift;
   my $var = shift;
   my $val = shift;
-  $self->{'config'}->{$var} = $val;
+  $self->{$var} = $val;
 
   return 1;
 }
@@ -906,21 +886,15 @@ sub register_XS_document_main_configuration($$)
 
   return if (!$document->document_descriptor());
 
-  my $options;
-  if ($self->{'standalone'}) {
-    #print STDERR "STDALONE: ".join('|', 
sort(keys(%{$self->{'config'}})))."\n";
-    $options = $self->{'config'};
-  } else {
-    my %options = %{$main_program_default_options};
-    foreach my $config ($self->{'config'}, $init_files_options, 
$cmdline_options) {
-      foreach my $option (keys(%$config)) {
-        $options{$option} = $config->{$option};
-      }
+  my %options = %{$main_program_default_options};
+  foreach my $config ($self, $init_files_options, $cmdline_options) {
+    foreach my $option (keys(%$config)) {
+      $options{$option} = $config->{$option};
     }
-    #print STDERR "MAIN: ".join('|', sort(keys(%options)))."\n";
-    $options = \%options;
   }
-  Texinfo::Common::set_document_options($options, $document);
+  #print STDERR "MAIN: ".join('|', sort(keys(%options)))."\n";
+
+  Texinfo::Common::set_document_options(\%options, $document);
 }
 
 1;
diff --git a/tp/t/test_sort.t b/tp/t/test_sort.t
index 8338957ef2..c64e8e1485 100644
--- a/tp/t/test_sort.t
+++ b/tp/t/test_sort.t
@@ -43,7 +43,7 @@ my $document = $parser->parse_texi_text('@node Top
 @cindex @l{}
 ');
 
-my $main_configuration = Texinfo::MainConfig::new({});
+my $main_configuration = Texinfo::MainConfig::new();
 
 # To set $indices_sort_strings, calling
 # Texinfo::Document::indices_sort_strings is more natural, but we want
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 742dadf669..21b9d5a9eb 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -982,7 +982,7 @@ sub test($$)
     delete $parser_options->{'init_files'};
   }
 
-  # Setup main configuration options defaults at this point to remove
+  # Setup main configuration options at this point to remove
   # structuring options from parser options.
   my $main_configuration_options = {};
   # gather options for structuring.
@@ -1050,6 +1050,7 @@ sub test($$)
 
   my ($errors, $error_nrs) = $parser->errors();
 
+  # Setup main configuration options, used for structuring.
   my $document_information = $document->global_information();
 
   foreach my $parser_and_structuring_option ('FORMAT_MENU', 'DEBUG') {



reply via email to

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