[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 5 Oct 2024 05:36:17 -0400 (EDT) |
branch: master
commit 4b253a18afedd4d4818efeaecb0f997bd239c8d9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Aug 30 08:47:55 2024 +0200
* tp/texi2any.pl ($main_program_set_options, $format)
(set_cmdline_format, set_format): set $format from the
TEXINFO_OUTPUT_FORMAT customization variable. Set
TEXINFO_OUTPUT_FORMAT to 'info' in $main_program_set_options. Add
the set_cmdline_format function to set TEXINFO_OUTPUT_FORMAT from
command line, using directly the texinfoxml format name for xml.
Modify set_format to call Texinfo::Config::texinfo_set_from_init_file
to set TEXINFO_OUTPUT_FORMAT. Call set_format for
TEXINFO_OUTPUT_FORMAT environment variable, for
GNUT_get_format_from_init_file value, but also for
TEXINFO_OUTPUT_FORMAT set from the command line.
---
ChangeLog | 14 ++++++++++
tp/texi2any.pl | 85 +++++++++++++++++++++++++++++++++-------------------------
2 files changed, 63 insertions(+), 36 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 50c7509eba..6b5fb88fe1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-08-30 Patrice Dumas <pertusus@free.fr>
+
+ * tp/texi2any.pl ($main_program_set_options, $format)
+ (set_cmdline_format, set_format): set $format from the
+ TEXINFO_OUTPUT_FORMAT customization variable. Set
+ TEXINFO_OUTPUT_FORMAT to 'info' in $main_program_set_options. Add
+ the set_cmdline_format function to set TEXINFO_OUTPUT_FORMAT from
+ command line, using directly the texinfoxml format name for xml.
+ Modify set_format to call Texinfo::Config::texinfo_set_from_init_file
+ to set TEXINFO_OUTPUT_FORMAT. Call set_format for
+ TEXINFO_OUTPUT_FORMAT environment variable, for
+ GNUT_get_format_from_init_file value, but also for
+ TEXINFO_OUTPUT_FORMAT set from the command line.
+
2024-08-26 Patrice Dumas <pertusus@free.fr>
* README-hacking, tp/Texinfo/XSLoader.pm (init),
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 97bdece316..dfc943898f 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -339,7 +339,9 @@ my $main_program_set_options = {
'TEXINFO_DTD_VERSION' => $texinfo_dtd_version,
'COMMAND_LINE_ENCODING' => $locale_encoding,
'MESSAGE_ENCODING' => $locale_encoding,
- 'LOCALE_ENCODING' => $locale_encoding
+ 'LOCALE_ENCODING' => $locale_encoding,
+ # better than making it the default value independently of the implementation
+ 'TEXINFO_OUTPUT_FORMAT' => 'info',
};
# set configure information as constants
@@ -702,7 +704,6 @@ my $cmdline_options = { 'CSS_FILES' => \@css_files,
=> \@texinfo_language_config_dirs,
'EXPANDED_FORMATS' => \@expanded_formats };
-my $format = 'info';
my @conf_dirs = ();
my @prepend_dirs = ();
@@ -883,14 +884,15 @@ my %formats_table = (
my $call_texi2dvi = 0;
my @texi2dvi_args = ();
-# previous_format should be in argument if there is a possibility of error.
-# as a fallback, the $format global variable is used.
-sub set_format($;$$)
+sub set_cmdline_format($)
+{
+ my $set_format = shift;
+ set_from_cmdline('TEXINFO_OUTPUT_FORMAT', $set_format);
+}
+
+sub set_format($)
{
my $set_format = shift;
- my $previous_format = shift;
- $previous_format = $format if (!defined($previous_format));
- my $do_not_override_command_line = shift;
my $new_output_format;
if ($format_command_line_names{$set_format}) {
@@ -902,16 +904,10 @@ sub set_format($;$$)
document_warn(sprintf(__(
"ignoring unrecognized TEXINFO_OUTPUT_FORMAT value `%s'\n"),
$set_format));
- $new_output_format = $previous_format;
} else {
- if ($format_from_command_line and $do_not_override_command_line) {
- $new_output_format = $previous_format;
- } else {
- $format_from_command_line = 1
- unless ($do_not_override_command_line);
- }
+ Texinfo::Config::texinfo_set_from_init_file('TEXINFO_OUTPUT_FORMAT',
+ $new_output_format);
}
- return $new_output_format;
}
sub _format_expanded_formats($)
@@ -1188,7 +1184,12 @@ There is NO WARRANTY, to the extent permitted by
law.\n"), "2024");
set_from_cmdline('FORMAT_MENU',
'set_format_menu_from_cmdline_header_option');
}
- $format = 'plaintext' if (!$_[1] and $format eq 'info');
},
+ if (!$_[1]
+ and get_conf('TEXINFO_OUTPUT_FORMAT') eq 'info') {
+ set_main_program_default('TEXINFO_OUTPUT_FORMAT',
+ 'plaintext');
+ }
+ },
'output|out|o=s' => sub {
my $var = 'OUTFILE';
if ($_[1] ne '-' and ($_[1] =~ m:/$: or -d $_[1])) {
@@ -1250,7 +1251,21 @@ There is NO WARRANTY, to the extent permitted by
law.\n"), "2024");
if ($value =~ /^undef$/i) {
$value = undef;
}
- set_from_cmdline($var, $value);
+ # TODO verify that it is the best. It is inconsistent with other
+ # customization options that have the same precedence as command
+ # line option when specified on the command line. This is because
+ # in the manual, it is said:
+ # "The customization variable of the same name is also read; if set,
+ # that overrides an environment variable setting, but not a command-line
+ # option."
+ # If read means "read from an init file" then we could change here, but
+ # if it means "read from the command line or an init file" we should
+ # keep it as it is.
+ if ($var eq 'TEXINFO_OUTPUT_FORMAT') {
+ set_format($value);
+ } else {
+ set_from_cmdline($var, $value);
+ }
}
},
'css-include=s' => \@css_files,
@@ -1282,17 +1297,17 @@ There is NO WARRANTY, to the extent permitted by
law.\n"), "2024");
'reference-limit=i' => sub { ;},
'Xopt=s' => sub {push @texi2dvi_args, $_[1]; $Xopt_arg_nr++},
'silent|quiet' => sub { push @texi2dvi_args, '--'.$_[0];},
- 'plaintext' => sub {$format = set_format($_[0].'');},
- 'html' => sub {$format = set_format($_[0].'');},
- 'epub3' => sub {$format = set_format($_[0].'');},
- 'latex' => sub {$format = set_format($_[0].'');},
- 'info' => sub {$format = set_format($_[0].'');},
- 'docbook' => sub {$format = set_format($_[0].'');},
- 'xml' => sub {$format = set_format($_[0].'');},
- 'dvi' => sub {$format = set_format($_[0].'');},
- 'dvipdf' => sub {$format = set_format($_[0].'');},
- 'ps' => sub {$format = set_format($_[0].'');},
- 'pdf' => sub {$format = set_format($_[0].'');},
+ 'plaintext' => sub {set_cmdline_format($_[0].'');},
+ 'html' => sub {set_cmdline_format($_[0].'');},
+ 'epub3' => sub {set_cmdline_format($_[0].'');},
+ 'latex' => sub {set_cmdline_format($_[0].'');},
+ 'info' => sub {set_cmdline_format($_[0].'');},
+ 'docbook' => sub {set_cmdline_format($_[0].'');},
+ 'xml' => sub {set_cmdline_format('texinfoxml');},
+ 'dvi' => sub {set_cmdline_format($_[0].'');},
+ 'dvipdf' => sub {set_cmdline_format($_[0].'');},
+ 'ps' => sub {set_cmdline_format($_[0].'');},
+ 'pdf' => sub {set_cmdline_format($_[0].'');},
'debug=i' => sub {set_from_cmdline('DEBUG', $_[1]);
push @texi2dvi_args, '--'.$_[0]; },
);
@@ -1317,10 +1332,8 @@ if (defined($set_translations_encoding)
sub process_config($) {
my $conf = shift;
- if (defined($conf->{'TEXINFO_OUTPUT_FORMAT'})) {
- $format = set_format($conf->{'TEXINFO_OUTPUT_FORMAT'}, $format, 1);
- } elsif (defined($conf->{'TEXI2HTML'})) {
- $format = set_format('html', $format, 1);
+ if (defined($conf->{'TEXI2HTML'})) {
+ set_format('html');
$parser_options->{'values'}->{'texi2html'} = 1;
}
}
@@ -1384,15 +1397,15 @@ sub format_name($)
my $init_file_format = Texinfo::Config::GNUT_get_format_from_init_file();
if (defined($init_file_format)) {
- $format = set_format($init_file_format, $format, 1);
+ set_format($init_file_format);
}
if (defined($ENV{'TEXINFO_OUTPUT_FORMAT'})
and $ENV{'TEXINFO_OUTPUT_FORMAT'} ne '') {
- $format = set_format(_decode_input($ENV{'TEXINFO_OUTPUT_FORMAT'}),
- $format, 1);
+ set_format(_decode_input($ENV{'TEXINFO_OUTPUT_FORMAT'}));
}
+my $format = get_conf('TEXINFO_OUTPUT_FORMAT');
# for a format setup with an init file
if (defined ($formats_table{$format}->{'init_file'})) {
locate_and_load_extension_file($formats_table{$format}->{'init_file'},
- Prev by Date:
[no subject]
- Next by Date:
branch master updated: * tp/Texinfo/Convert/Converter.pm (%common_converters_defaults) (output_tree), tp/Texinfo/Convert/HTML.pm (_external_node_href) (_setup_output), tp/Texinfo/Convert/IXIN.pm, tp/Texinfo/Convert/Info.pm (output), tp/Texinfo/Convert/LaTeX.pm (output), tp/Texinfo/Convert/Plaintext.pm (output), tp/Texinfo/XS/convert/converter.c (apply_converter_info) (destroy_converter_initialization_info) (copy_converter_initialization_info, free_generic_converter), tp/Texinfo/XS/convert/format_html.c (external [...]
- Previous by thread:
[no subject]
- Next by thread:
branch master updated: * tp/Texinfo/Convert/Converter.pm (%common_converters_defaults) (output_tree), tp/Texinfo/Convert/HTML.pm (_external_node_href) (_setup_output), tp/Texinfo/Convert/IXIN.pm, tp/Texinfo/Convert/Info.pm (output), tp/Texinfo/Convert/LaTeX.pm (output), tp/Texinfo/Convert/Plaintext.pm (output), tp/Texinfo/XS/convert/converter.c (apply_converter_info) (destroy_converter_initialization_info) (copy_converter_initialization_info, free_generic_converter), tp/Texinfo/XS/convert/format_html.c (external [...]
- Index(es):