texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Common.pm (%default_parser_customiza


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (%default_parser_customization_values) (@variable_other_settables, locate_include_file) (_convert_text_options), tp/Texinfo/Convert/Converter.pm (%all_converters_defaults), tp/Texinfo/Convert/Text.pm (_code_options, convert_to_text) (_convert), tp/Texinfo/ParserNonXS.pm (%parser_state_configuration), tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser), tp/texi2any.pl: turn 'include_directories' to a normal conf variable, renamed as 'INCLUDE_DIRECTORIES'. As a consequence, [...]
Date: Wed, 01 Sep 2021 10:06:33 -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 b2353c2  * tp/Texinfo/Common.pm (%default_parser_customization_values) 
(@variable_other_settables, locate_include_file) (_convert_text_options), 
tp/Texinfo/Convert/Converter.pm (%all_converters_defaults), 
tp/Texinfo/Convert/Text.pm (_code_options, convert_to_text) (_convert), 
tp/Texinfo/ParserNonXS.pm (%parser_state_configuration), 
tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser), tp/texi2any.pl: turn 
'include_directories' to a normal conf variable, renamed as 
'INCLUDE_DIRECTORIES'. [...]
b2353c2 is described below

commit b2353c296ec5baca763badf7b8dde3527dcf55eb
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Sep 1 16:06:24 2021 +0200

    * tp/Texinfo/Common.pm (%default_parser_customization_values)
    (@variable_other_settables, locate_include_file)
    (_convert_text_options),
    tp/Texinfo/Convert/Converter.pm (%all_converters_defaults),
    tp/Texinfo/Convert/Text.pm (_code_options, convert_to_text)
    (_convert), tp/Texinfo/ParserNonXS.pm (%parser_state_configuration),
    tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser), tp/texi2any.pl:
    turn 'include_directories' to a normal conf variable, renamed
    as 'INCLUDE_DIRECTORIES'.  As a consequence, locate_include_file
    now uses get_conf, which means that the $configurations_informations
    need to be blessed.  bless $options in Texinfo::Convert::Text
    convert_to_text() and instead of replacing the $options with
    the _code_options() function, use a state in '_code_options'
    to modify transiently instead of replacing each time code type
    formatting is needed.
    
    * tp/Texinfo/Config.pm (GNUT_load_config, GNUT_initialize_config)
    (_document_warn), tp/texi2any.pl: rename GNUT_load_config() as
    GNUT_initialize_config().  Pass $real_command_name and return
    $options, renamed $init_files_options.
    
    * tp/texi2any.pl (normalize_config, process_config): rename
    normalize_config() as process_config().
    Do not modify $cmdline_options after the first file, copy and
    modify.
---
 ChangeLog                            | 28 +++++++++++++++++
 tp/Texinfo/Common.pm                 | 17 ++++++-----
 tp/Texinfo/Config.pm                 | 59 +++++++++++++++++++++---------------
 tp/Texinfo/Convert/Converter.pm      |  1 -
 tp/Texinfo/Convert/Text.pm           | 58 +++++++++++++++++++++--------------
 tp/Texinfo/ParserNonXS.pm            | 13 +-------
 tp/Texinfo/XS/parsetexi/Parsetexi.pm |  4 +--
 tp/t/nodenormalization.t             |  2 +-
 tp/t/test_utils.pl                   |  4 +--
 tp/texi2any.pl                       | 43 ++++++++++++++------------
 10 files changed, 138 insertions(+), 91 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 205163b..1f7ed62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,33 @@
 2021-09-01  Patrice Dumas  <pertusus@free.fr>
 
+       * tp/Texinfo/Common.pm (%default_parser_customization_values)
+       (@variable_other_settables, locate_include_file)
+       (_convert_text_options),
+       tp/Texinfo/Convert/Converter.pm (%all_converters_defaults),
+       tp/Texinfo/Convert/Text.pm (_code_options, convert_to_text)
+       (_convert), tp/Texinfo/ParserNonXS.pm (%parser_state_configuration),
+       tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser), tp/texi2any.pl:
+       turn 'include_directories' to a normal conf variable, renamed
+       as 'INCLUDE_DIRECTORIES'.  As a consequence, locate_include_file
+       now uses get_conf, which means that the $configurations_informations
+       need to be blessed.  bless $options in Texinfo::Convert::Text
+       convert_to_text() and instead of replacing the $options with
+       the _code_options() function, use a state in '_code_options'
+       to modify transiently instead of replacing each time code type
+       formatting is needed.
+
+       * tp/Texinfo/Config.pm (GNUT_load_config, GNUT_initialize_config)
+       (_document_warn), tp/texi2any.pl: rename GNUT_load_config() as
+       GNUT_initialize_config().  Pass $real_command_name and return
+       $options, renamed $init_files_options.
+
+       * tp/texi2any.pl (normalize_config, process_config): rename
+       normalize_config() as process_config().
+       Do not modify $cmdline_options after the first file, copy and
+       modify.
+
+2021-09-01  Patrice Dumas  <pertusus@free.fr>
+
        * tp/Texinfo/Config.pm (texinfo_register_formatting_function),
        tp/Texinfo/Convert/HTML.pm (converter_initialize, run_stage_handlers):
        do not check the validity of texinfo_register_formatting_function()
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 6641830..e941d85 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -103,6 +103,7 @@ sub __p($$) {
 
 # Customization variables obeyed by the parser, and the default values.
 our %default_parser_customization_values = (
+  'INCLUDE_DIRECTORIES' => [ '.' ],
   'documentlanguage' => undef,
   'novalidate' => undef,
   'EXPANDED_FORMATS' => [],
@@ -320,8 +321,9 @@ my @variable_other_settables = (
   'MISC_BUTTONS', 'CHAPTER_BUTTONS', 'BUTTONS_NAME',
   'BUTTONS_EXAMPLE', 'SPECIAL_ELEMENTS_NAME', 'SPECIAL_ELEMENTS_CLASS',
   'ACTIVE_ICONS', 'PASSIVE_ICONS',
-  'CSS_FILES', 'CSS_REFS', 'EXPANDED_FORMATS',
   'GLOBAL_COMMANDS',
+  # set from command line
+  'CSS_FILES', 'CSS_REFS', 'EXPANDED_FORMATS', 'INCLUDE_DIRECTORIES',
 );
 
 my %valid_options;
@@ -1074,7 +1076,7 @@ sub locate_init_file($$$)
 
 sub locate_include_file($$)
 {
-  my $self = shift;
+  my $configuration_informations = shift;
   my $text = shift;
   my $file;
 
@@ -1083,7 +1085,7 @@ sub locate_include_file($$)
   my ($volume, $directories, $filename) = File::Spec->splitpath($text);
   my @directories = File::Spec->splitdir($directories);
 
-  #print STDERR "$self $text @{$self->{'include_directories'}}\n";
+  #print STDERR "$configuration_informations $text 
@{$configuration_informations->get_conf('INCLUDE_DIRECTORIES')}\n";
   # If the path is absolute or begins with . or .., do not search in
   # include directories.
   if (File::Spec->file_name_is_absolute($text)) {
@@ -1104,13 +1106,14 @@ sub locate_include_file($$)
     $file = $text if (-e $text and -r $text);
   } else {
     my @dirs;
-    if ($self and $self->{'include_directories'}) {
-      @dirs = @{$self->{'include_directories'}};
+    if ($configuration_informations
+        and $configuration_informations->get_conf('INCLUDE_DIRECTORIES')) {
+      @dirs = @{$configuration_informations->get_conf('INCLUDE_DIRECTORIES')};
     } else {
       # no object with directory list and not an absolute path, never succeed
       return undef;
     }
-    foreach my $include_dir (@{$self->{'include_directories'}}) {
+    foreach my $include_dir 
(@{$configuration_informations->get_conf('INCLUDE_DIRECTORIES')}) {
       my ($include_volume, $include_directories, $include_filename) 
          = File::Spec->splitpath($include_dir, 1);
       
@@ -1777,7 +1780,7 @@ sub _convert_text_options($)
   $options{'converter'} = $self;
   $options{'expanded_formats_hash'} = $self->{'expanded_formats_hash'};
   # for locate_include_file
-  $options{'include_directories'} = $self->{'include_directories'};
+  $options{'INCLUDE_DIRECTORIES'} = $self->get_conf('INCLUDE_DIRECTORIES');
   # for error registering
   $options{'DEBUG'} = $self->get_conf('DEBUG');
   $options{'PROGRAM'} = $self->get_conf('PROGRAM');
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 45753a8..7be921a 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -25,7 +25,7 @@
 
 package Texinfo::Config;
 
-# for __(
+# for __( and p__(
 use Texinfo::Common;
 
 # for carp
@@ -33,31 +33,42 @@ use Carp;
 
 # not that there is no use strict to avoid warnings for users code
 
+my $real_command_name;
+
+my $cmdline_options;
+my $default_options;
+my $init_files_options = {};
+
+# called from texi2any.pl main program
+sub GNUT_initialize_config($$$) {
+  $real_command_name = shift;
+  $default_options = shift;
+  $cmdline_options = shift;
+  #print STDERR "cmdline_options: ".join('|',keys(%$cmdline_options))."\n";
+  return $init_files_options;
+}
+
+# duplicated from texi2any.pl
+sub _document_warn($) {
+  return if (texinfo_get_conf('NO_WARN'));
+  my $text = shift;
+  chomp ($text);
+  warn(sprintf(__p("program name: warning: warning_message",
+                   "%s: warning: %s\n"), $real_command_name,  $text));
+}
+
+# called from texi2any.pl main program.
 # eval init file in the Texinfo::Config namespace.
 sub GNUT_load_init_file($) {
   my $file = shift;
   eval { require($file) ;};
   my $e = $@;
   if ($e ne '') {
-    main::document_warn(sprintf(__("error loading %s: %s\n"),
+    _document_warn(sprintf(__("error loading %s: %s\n"),
                                  $file, $e));
   }
 }
 
-# used in main program
-our $options = {};
-my $cmdline_options;
-my $default_options;
-
-sub GNUT_load_config($$) {
-  $default_options = shift;
-  $cmdline_options = shift;
-  #print STDERR "cmdline_options: ".join('|',keys(%$cmdline_options))."\n";
-}
-
-# FIXME: maybe use an opaque return status that can be used to retrieve
-# an error message?
-#
 # Called from init files to set configuration options.
 sub texinfo_set_from_init_file($$) {
   my $var = shift;
@@ -65,13 +76,13 @@ sub texinfo_set_from_init_file($$) {
   if (!Texinfo::Common::valid_option($var)) {
     # carp may be better, but infortunately, it points to the routine that 
     # loads the file, and not to the init file.
-    main::document_warn(sprintf(__("%s: unknown variable %s"),
+    _document_warn(sprintf(__("%s: unknown variable %s"),
                                 'texinfo_set_from_init_file', $var));
     return 0;
   }
   return 0 if (defined($cmdline_options->{$var}));
   delete $default_options->{$var};
-  $options->{$var} = $value;
+  $init_files_options->{$var} = $value;
   return 1;
 }
 
@@ -79,11 +90,11 @@ sub texinfo_set_from_init_file($$) {
 sub GNUT_set_from_cmdline($$) {
   my $var = shift;
   my $value = shift;
-  delete $options->{$var};
+  delete $init_files_options->{$var};
   delete $default_options->{$var};
   if (!Texinfo::Common::valid_option($var)) {
-    main::document_warn(sprintf(main::__("%s: unknown variable %s\n"),
-                                'GNUT_set_from_cmdline', $var));
+    _document_warn(sprintf(__("%s: unknown variable %s\n"),
+                          'GNUT_set_from_cmdline', $var));
     return 0;
   }
   $cmdline_options->{$var} = $value;
@@ -97,8 +108,8 @@ sub texinfo_get_conf($) {
   my $var = shift;
   if (exists($cmdline_options->{$var})) {
     return $cmdline_options->{$var};
-  } elsif (exists($options->{$var})) {
-    return $options->{$var};
+  } elsif (exists($init_files_options->{$var})) {
+    return $init_files_options->{$var};
   } elsif (exists($default_options->{$var})) {
     return $default_options->{$var};
   } else {
@@ -106,7 +117,7 @@ sub texinfo_get_conf($) {
   }
 }
 
-# to dynamically add options from init files
+# to dynamically add customization options from init files
 sub texinfo_add_valid_option($)
 {
   my $option = shift;
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 1a4a98d..f9e6712 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -74,7 +74,6 @@ our %all_converters_defaults = (
   'paragraphindent'      => 3,
   'fillcolumn'           => 72,
   'expanded_formats'     => undef,
-  'include_directories'  => undef,
   'structuring'          => undef,
   'IMAGE_LINK_PREFIX'    => undef,
   'NUMBER_SECTIONS'      => 1,
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index cc02fa2..f1d3368 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -318,25 +318,20 @@ sub heading($$$;$$)
   return $result;
 }
 
-sub _code_options($)
-{
-  my $options = shift;
-  my $code_options;
-  if (defined($options)) {
-    $code_options = { %$options };
-  } else {
-    $code_options = {};
-  }
-  $code_options->{'code'} = 1;
-  return $code_options;
-}
-
 sub convert_to_text($;$)
 {
   my $root = shift;
   my $options = shift;
 
   #print STDERR "CONVERT\n";
+  # this is needed for locate_include_file which uses
+  # $configurations_informations->get_conf() and thus requires a blessed 
reference.
+  if (defined($options)) {
+    bless $options;
+    if ($options->{'code'}) {
+      $options->{'_code_options'} = 1;
+    }
+  }
   return _convert($root, $options);
 }
 
@@ -392,7 +387,7 @@ sub _convert($;$)
         if ($options->{'sc'}) {
           $result = uc($result);
         }
-        if (!$options->{'code'}) {
+        if (!$options->{'_code_options'}) {
           $result =~ s/``/"/g;
           $result =~ s/\'\'/"/g;
           $result =~ s/---/\x{1F}/g;
@@ -429,9 +424,14 @@ sub _convert($;$)
                                         $options->{'sc'});
       return $result;
     } elsif ($root->{'cmdname'} eq 'image') {
-      return _convert($root->{'args'}->[0], _code_options($options));
+      $options->{_code_options}++;
+      my $text = _convert($root->{'args'}->[0], $options);
+      $options->{_code_options}--;
+      return $text;
     } elsif ($root->{'cmdname'} eq 'email') {
-      my $mail = _convert($root->{'args'}->[0], _code_options($options));
+      $options->{_code_options}++;
+      my $mail = _convert($root->{'args'}->[0], $options);
+      $options->{_code_options}--;
       my $text;
       $text = _convert($root->{'args'}->[1], $options)
          if (defined($root->{'args'}->[1]));
@@ -445,7 +445,9 @@ sub _convert($;$)
       my $text;
       $text = _convert($root->{'args'}->[1], $options)
         if (defined($root->{'args'}->[1]));
-      my $url = _convert($root->{'args'}->[0], _code_options($options));
+      $options->{_code_options}++;
+      my $url = _convert($root->{'args'}->[0], $options);
+      $options->{_code_options}--;
       if (defined($text) and $text ne '') {
         return "$url ($text)";
       } else {
@@ -477,13 +479,16 @@ sub _convert($;$)
                 and $root->{'args'}->[0]->{'type'} eq 'brace_command_arg')
                 or $Texinfo::Common::math_commands{$root->{'cmdname'}})) {
       my $result;
+      my $in_code;
       if ($root->{'cmdname'} eq 'sc') {
         $options = {%$options, 'sc' => 1};
       } elsif ($Texinfo::Common::code_style_commands{$root->{'cmdname'}}
                or $Texinfo::Common::math_commands{$root->{'cmdname'}}) {
-        $options = _code_options($options);
+        $in_code = 1;
       }
+      $options->{_code_options}++ if ($in_code);
       $result = _convert($root->{'args'}->[0], $options);
+      $options->{_code_options}-- if ($in_code);
       return $result;
     # block commands
     } elsif ($root->{'cmdname'} eq 'quotation'
@@ -555,12 +560,16 @@ sub _convert($;$)
         push @contents, @$arguments;
       }
       push @contents, {'text' => "\n"};
-      $result = _convert({'contents' => \@contents}, _code_options($options));
+      $options->{_code_options}++;
+      $result = _convert({'contents' => \@contents}, $options);
+      $options->{_code_options}--;
     }
   } elsif ($root->{'type'} and $root->{'type'} eq 'menu_entry') {
     foreach my $arg (@{$root->{'args'}}) {
       if ($arg->{'type'} eq 'menu_entry_node') {
-        $result .= _convert($arg, _code_options($options));
+        $options->{_code_options}++;
+        $result .= _convert($arg, $options);
+        $options->{_code_options}--;
       } else {
         $result .= _convert($arg, $options);
       }
@@ -573,19 +582,22 @@ sub _convert($;$)
     }
   }
   if ($root->{'contents'}) {
+    my $in_code;
     if ($root->{'cmdname'} 
         and ($Texinfo::Common::preformatted_code_commands{$root->{'cmdname'}}
              or $Texinfo::Common::math_commands{$root->{'cmdname'}}
              or (defined($Texinfo::Common::block_commands{$root->{'cmdname'}}) 
                  and $Texinfo::Common::block_commands{$root->{'cmdname'}} eq 
'raw'))) {
-      $options = _code_options($options);
+      $in_code = 1;
     }
     if (ref($root->{'contents'}) ne 'ARRAY') {
       cluck "contents not an array($root->{'contents'}).";
     }
+    $options->{_code_options}++ if ($in_code);
     foreach my $content (@{$root->{'contents'}}) {
       $result .= _convert($content, $options);
     }
+    $options->{_code_options}-- if ($in_code);
   }
   $result = '{'.$result.'}' 
      if ($root->{'type'} and $root->{'type'} eq 'bracketed'
@@ -618,7 +630,7 @@ sub converter($)
 
   if ($conf) {
     # some informations are directy passed, in general duplicated
-    # in parser, in particular 'include_directories'.
+    # in parser.
     %{$converter} = %{$conf};
     #print STDERR "CTe ".join("|", sort(keys(%{$conf})))."\n";
   }
@@ -785,7 +797,7 @@ output strings translation or error handling.
 =item $result = convert_to_text($tree, $options)
 
 Convert a Texinfo tree to simple text.  I<$options> is a hash reference of 
-options.  The converter is very simple, and has no internal state besides
+options.  The converter is very simple, and has almost no internal state 
besides
 the options.  It cannot handle as is output strings translation or error 
 storing.
 
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index d94b4f0..1e903c8 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -109,7 +109,6 @@ sub N__($)
 
 # these are the default values for the parser state
 my %parser_state_configuration = (
-  'include_directories' => [ '.' ],
   # these are the user-added indices.  May be an array reference on names
   # or an hash reference in the same format than %index_names below
   'indices' => [],
@@ -5960,7 +5959,7 @@ C<@synindex>).  These options are described below in 
L</Texinfo Parser options>.
 An array reference of the output formats for which C<@ifI<FORMAT>> 
 conditional blocks should be expanded.  Default is empty.
 
-=item include_directories
+=item INCLUDE_DIRECTORIES
 
 An array reference of directories in which C<@include> files should be 
 searched for.  Default contains the working directory, F<.>.
@@ -5989,16 +5988,6 @@ menu-related errors for 'menu'.
 
 Texinfo::Report object reused by the parser to register errors.
 
-=begin :comment
-
-Used by Sectioning only
-=item TOP_NODE_UP
-
-Text for the up node of the Top node.  The default is C<(dir)>.  The
-string may contain @-commands.
-
-=end :comment
-
 =back
 
 =back
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm 
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 83a02fc..76edf14 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -79,8 +79,8 @@ sub parser (;$$)
         $parser->{$key} = $conf->{$key};
       }
 
-      if ($key eq 'include_directories') {
-        foreach my $d (@{$conf->{'include_directories'}}) {
+      if ($key eq 'INCLUDE_DIRECTORIES') {
+        foreach my $d (@{$conf->{'INCLUDE_DIRECTORIES'}}) {
           add_include_directory ($d);
         }
       } elsif ($key eq 'values') {
diff --git a/tp/t/nodenormalization.t b/tp/t/nodenormalization.t
index 4169602..66c9eb5 100644
--- a/tp/t/nodenormalization.t
+++ b/tp/t/nodenormalization.t
@@ -25,7 +25,7 @@ my $strings_textdomain = 'texinfo_document';
 Locale::Messages->select_package ('gettext_pp');
 Locale::Messages::bindtextdomain ('texinfo_document', 't/locales');
 
-my $parser = Texinfo::Parser::parser({'include_directories' => [
+my $parser = Texinfo::Parser::parser({'INCLUDE_DIRECTORIES' => [
                                           $srcdir.'t/include/'],
                                       'EXPANDED_FORMATS' => ['html', 'tex']});
 
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index e2cd0ec..6d970df 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -827,7 +827,7 @@ sub test($$)
     delete $parser_options->{'init_files'};
   }
 
-  my $parser = Texinfo::Parser::parser({'include_directories' => [
+  my $parser = Texinfo::Parser::parser({'INCLUDE_DIRECTORIES' => [
                                           $srcdir.'t/include/'],
                                         'DEBUG' => $self->{'DEBUG'},
                                        %$parser_options});
@@ -948,7 +948,7 @@ sub test($$)
         $format_converter_options->{'OUTFILE'} = '';
       }
       $format_converter_options->{'TEST'} = 1;
-      $format_converter_options->{'include_directories'} = [
+      $format_converter_options->{'INCLUDE_DIRECTORIES'} = [
                                           $srcdir.'t/include/'];
       ($converted_errors{$format}, $converted{$format})
            = &{$formats{$format}}($self, $test_name, $format_type, 
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index df51269..18077fb 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -104,8 +104,10 @@ use Texinfo::Convert::Converter;
 # command line parsing.
 my @css_files = ();
 my @css_refs = ();
+my @include_dirs = ();
 my $cmdline_options = { 'CSS_FILES' => \@css_files,
-                        'CSS_REFS' => \@css_refs };
+                        'CSS_REFS' => \@css_refs,
+                        'INCLUDE_DIRECTORIES' => \@include_dirs };
 
 # determine the path separators
 my $path_separator = $Config{'path_sep'};
@@ -357,11 +359,12 @@ my $format = 'info';
 # corresponding --no-ifformat.
 my $default_expanded_format = [ $format ];
 my @conf_dirs = ();
-my @include_dirs = ();
 my @prepend_dirs = ();
 
 # $cmdline_options are common to main program and Texinfo::Config
-# namespace, set by set_from_cmdline for text values.
+# namespace, set by GNUT_set_from_cmdline for text values, but also
+# manipulated in main program.
+# $init_files_options are managed by Texinfo::Config and available here.
 # There is in addition $parser_options for parser
 # related informations for informations that are not set through
 # set_from_cmdline.  The configuration text values are later on
@@ -372,7 +375,8 @@ my @prepend_dirs = ();
 my $parser_options = {'EXPANDED_FORMATS' => [],
                       'values' => {'txicommandconditionals' => 1}};
 
-Texinfo::Config::GNUT_load_config($converter_default_options, 
$cmdline_options);
+my $init_files_options = Texinfo::Config::GNUT_initialize_config(
+      $real_command_name, $converter_default_options, $cmdline_options);
 
 sub set_expansion($$) {
   my $region = shift;
@@ -524,6 +528,8 @@ sub set_format($;$$)
   return $new_format;
 }
 
+# FIXME used in init/chm.pm main::set_global_format('html'); but this
+# is not a sane interface, should be modified.
 sub set_global_format($)
 {
   my $set_format = shift;
@@ -892,8 +898,8 @@ There is NO WARRANTY, to the extent permitted by law.\n"), 
"2021";
 
 exit 1 if (!$result_options);
 
-# Change some options depending on the settings of other ones
-sub normalize_config {
+# Change some options depending on the settings of other ones set formats
+sub process_config {
   my $conf = shift;
 
   if (defined($conf->{'TEXINFO_OUTPUT_FORMAT'})) {
@@ -907,9 +913,7 @@ sub normalize_config {
   }
 }
 
-$cmdline_options->{'include_directories'} = [@include_dirs];
-
-normalize_config($cmdline_options);
+process_config($cmdline_options);
 
 # FIXME do this here or inside format-specific code?
 my $latex2html_file = 'latex2html.pm';
@@ -1105,15 +1109,13 @@ while(@input_files) {
 
   my $parser_file_options = { %$parser_options };
 
-  $parser_file_options->{'include_directories'} = [@include_dirs];
-
   my @prepended_include_directories = ('.');
   push @prepended_include_directories, $input_directory
       if ($input_directory ne '.');
   @prepended_include_directories =
     (@prepend_dirs, @prepended_include_directories);
 
-  unshift @{$parser_file_options->{'include_directories'}},
+  unshift @{$parser_file_options->{'INCLUDE_DIRECTORIES'}},
           @prepended_include_directories;
 
   my $parser = Texinfo::Parser::parser($parser_file_options);
@@ -1292,23 +1294,26 @@ while(@input_files) {
   if ($format eq 'structure') {
     next;
   }
+  my $file_cmdline_options = { %$cmdline_options };
 
   if ($file_number != 0) {
-    delete $cmdline_options->{'OUTFILE'} if 
exists($cmdline_options->{'OUTFILE'});
-    delete $cmdline_options->{'PREFIX'} if 
exists($cmdline_options->{'PREFIX'});
-    delete $cmdline_options->{'SUBDIR'} 
-      if (exists($cmdline_options->{'SUBDIR'}) and get_conf('SPLIT'));
+    delete $file_cmdline_options->{'OUTFILE'}
+       if exists($file_cmdline_options->{'OUTFILE'});
+    delete $file_cmdline_options->{'PREFIX'}
+       if exists($file_cmdline_options->{'PREFIX'});
+    delete $file_cmdline_options->{'SUBDIR'}
+       if (exists($file_cmdline_options->{'SUBDIR'}) and get_conf('SPLIT'));
   }
   my $converter_options = { %$converter_default_options, 
-                            %$cmdline_options,
-                            %$Texinfo::Config::options };
+                            %$file_cmdline_options,
+                            %$init_files_options };
 
   $converter_options->{'expanded_formats'} = 
$parser_options->{'EXPANDED_FORMATS'};
   $converter_options->{'parser'} = $parser;
   $converter_options->{'structuring'} = $structure_informations;
   $converter_options->{'output_format'} = $format;
   $converter_options->{'language_config_dirs'} = \@language_config_dirs;
-  unshift @{$converter_options->{'include_directories'}},
+  unshift @{$converter_options->{'INCLUDE_DIRECTORIES'}},
           @prepended_include_directories;
 
   my $converter = 
&{$formats_table{$format}->{'converter'}}($converter_options);



reply via email to

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