On Sat, Jan 27, 2024 at 06:47:24PM +0000, Gavin Smith wrote: > On Sat, Jan 27, 2024 at 07:20:05PM +0100, Patrice Dumas wrote: > > > I don't know how ffmpeg or other packages are supposed to adapt to the > > > new interface. Perhaps we could put special case code in get_conf to > > > check for "PACKAGE_VERSION" and redirect to the new interface? > > > > That seems complicated. To adapt to the change in name of the variable, > > they can try both PACKAGE_VERSION and PACKAGE_VERSION_OPTION with > > get_conf, that seems ok to me? > > If there is still a customization variable to access for this, then > I don't see why the name has to be changed. I haven't had any new thoughts > on this since my previous emails on the topic, I'm afraid. I remember > that not using PACKAGE_VERSION was mainly due to a clash with a symbol > defined by automake or autoconf, which is an implementation problem that > we could try to work around, rather than changing our public interface. > I'll try to propose a change once I've had time to look at it.
Here's the patch to change it back to PACKAGE_VERSION. I defined macros with the original values using a _CONFIG suffix as you suggested, which is needed in one place in the code (in the argument to bindtextdomain). diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm index 5d271a37c5..a96e353c72 100644 --- a/tp/Texinfo/Convert/Converter.pm +++ b/tp/Texinfo/Convert/Converter.pm @@ -162,9 +162,9 @@ my %common_converters_defaults = ( # values are what is used in tests of the Converters. These variables are # customization options, set in the main program when a converter is # called from the main program. - 'PACKAGE_AND_VERSION_OPTION' => 'texinfo', - 'PACKAGE_VERSION_OPTION' => '', - 'PACKAGE_URL_OPTION' => 'http://www.gnu.org/software/texinfo/', + 'PACKAGE_AND_VERSION' => 'texinfo', + 'PACKAGE_VERSION' => '', + 'PACKAGE_URL' => 'http://www.gnu.org/software/texinfo/', 'PROGRAM' => '', ); diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm index 4153982a41..5688bf9c25 100644 --- a/tp/Texinfo/Convert/HTML.pm +++ b/tp/Texinfo/Convert/HTML.pm @@ -10828,11 +10828,11 @@ sub _default_format_program_string($) my $self = shift; if (defined($self->get_conf('PROGRAM')) and $self->get_conf('PROGRAM') ne '' - and defined($self->get_conf('PACKAGE_URL_OPTION'))) { + and defined($self->get_conf('PACKAGE_URL'))) { return $self->convert_tree( $self->gdt('This document was generated on @emph{@today{}} using @uref{{program_homepage}, @emph{{program}}}.', { 'program_homepage' => {'text' - => $self->get_conf('PACKAGE_URL_OPTION')}, + => $self->get_conf('PACKAGE_URL')}, 'program' => {'text' => $self->get_conf('PROGRAM')} })); } else { return $self->convert_tree( @@ -10974,8 +10974,8 @@ sub _file_header_information($$;$) my $after_body_open = ''; $after_body_open = $self->get_conf('AFTER_BODY_OPEN') if (defined($self->get_conf('AFTER_BODY_OPEN'))); - my $program_and_version = $self->get_conf('PACKAGE_AND_VERSION_OPTION'); - my $program_homepage = $self->get_conf('PACKAGE_URL_OPTION'); + my $program_and_version = $self->get_conf('PACKAGE_AND_VERSION'); + my $program_homepage = $self->get_conf('PACKAGE_URL'); my $program = $self->get_conf('PROGRAM'); my $generator = ''; if (defined($program) and $program ne '') { diff --git a/tp/Texinfo/Convert/Info.pm b/tp/Texinfo/Convert/Info.pm index f26b3397cd..9bface112d 100644 --- a/tp/Texinfo/Convert/Info.pm +++ b/tp/Texinfo/Convert/Info.pm @@ -416,7 +416,7 @@ sub _info_header($$$) # This ensures that spaces in file are kept. $result .= add_next($paragraph, $output_filename); my $program = $self->get_conf('PROGRAM'); - my $version = $self->get_conf('PACKAGE_VERSION_OPTION'); + my $version = $self->get_conf('PACKAGE_VERSION'); if (defined($program) and $program ne '') { $result .= add_text($paragraph, ", produced by $program version $version from "); diff --git a/tp/Texinfo/XS/configure.ac b/tp/Texinfo/XS/configure.ac index 8b5573968f..9e271fda20 100644 --- a/tp/Texinfo/XS/configure.ac +++ b/tp/Texinfo/XS/configure.ac @@ -175,5 +175,16 @@ esac AC_SUBST([perl_conf_CFLAGS], [$perl_conf_CFLAGS]) AC_SUBST([perl_conf_LDFLAGS], [$perl_conf_LDFLAGS]) +# Output these with the _CONFIG suffix as we use the originals as names +# of customization variables. +AC_DEFINE_UNQUOTED([PACKAGE_CONFIG], ["$PACKAGE"], + [autoconf PACKAGE value]) +AC_DEFINE_UNQUOTED([PACKAGE_NAME_CONFIG], ["$PACKAGE_NAME"], + [autoconf PACKAGE_NAME value]) +AC_DEFINE_UNQUOTED([PACKAGE_URL_CONFIG], ["$PACKAGE_URL"], + [autoconf PACKAGE_URL value]) +AC_DEFINE_UNQUOTED([PACKAGE_VERSION_CONFIG], ["$PACKAGE_VERSION"], + [autoconf PACKAGE_VERSION value]) + AC_CONFIG_FILES([Makefile gnulib/lib/Makefile]) AC_OUTPUT diff --git a/tp/Texinfo/XS/convert/convert_html.c b/tp/Texinfo/XS/convert/convert_html.c index 719ce3b4c6..60e29808b1 100644 --- a/tp/Texinfo/XS/convert/convert_html.c +++ b/tp/Texinfo/XS/convert/convert_html.c @@ -6536,14 +6536,14 @@ html_default_format_program_string (CONVERTER *self, TEXT *result) { ELEMENT *tree; if (self->conf->PROGRAM.string && strlen (self->conf->PROGRAM.string) - && self->conf->PACKAGE_URL_OPTION.string) + && self->conf->PACKAGE_URL.string) { ELEMENT *program_homepage = new_element (ET_NONE); ELEMENT *program = new_element (ET_NONE); NAMED_STRING_ELEMENT_LIST *substrings = new_named_string_element_list (); - text_append (&program_homepage->text, self->conf->PACKAGE_URL_OPTION.string); + text_append (&program_homepage->text, self->conf->PACKAGE_URL.string); text_append (&program->text, self->conf->PROGRAM.string); add_element_to_named_string_element_list (substrings, @@ -7152,8 +7152,8 @@ html_default_format_begin_file (CONVERTER *self, const char *filename, text_append_n (&result, "\n", 1); text_printf (&result, "<html%s>\n", begin_info->root_html_element_attributes); text_printf (&result, "<!-- Created by %s, %s -->\n<head>\n", - self->conf->PACKAGE_AND_VERSION_OPTION.string, - self->conf->PACKAGE_URL_OPTION.string); + self->conf->PACKAGE_AND_VERSION.string, + self->conf->PACKAGE_URL.string); if (begin_info->encoding) text_append (&result, begin_info->encoding); text_append_n (&result, "\n", 1); @@ -8198,8 +8198,8 @@ html_default_format_node_redirection_page (CONVERTER *self, text_printf (&result, "<!-- Created by %s, %s -->\n" "<!-- This file redirects to the location of a node or anchor -->\n" "<head>\n", - self->conf->PACKAGE_AND_VERSION_OPTION.string, - self->conf->PACKAGE_URL_OPTION.string); + self->conf->PACKAGE_AND_VERSION.string, + self->conf->PACKAGE_URL.string); if (begin_info->encoding) text_append (&result, begin_info->encoding); text_append_n (&result, "\n", 1); diff --git a/tp/Texinfo/XS/main/build_perl_info.c b/tp/Texinfo/XS/main/build_perl_info.c index e8f64f05f2..9dcc6f7b87 100644 --- a/tp/Texinfo/XS/main/build_perl_info.c +++ b/tp/Texinfo/XS/main/build_perl_info.c @@ -82,9 +82,9 @@ init (int texinfo_uninstalled, char *builddir) /* Note: this uses the installed translations even when running an uninstalled program. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE_CONFIG, LOCALEDIR); - textdomain (PACKAGE); + textdomain (PACKAGE_CONFIG); #else #endif diff --git a/tp/Texinfo/options_data.txt b/tp/Texinfo/options_data.txt index 09046c7201..e972d75f6b 100644 --- a/tp/Texinfo/options_data.txt +++ b/tp/Texinfo/options_data.txt @@ -280,11 +280,11 @@ OUTPUT_CHARACTERS converter_customization undef integer OUTPUT_ENCODING_NAME converter_customization undef char OUTPUT_FILE_NAME_ENCODING converter_customization undef char OUTPUT_PERL_ENCODING converter_customization undef char -PACKAGE_OPTION converter_customization undef char -PACKAGE_AND_VERSION_OPTION converter_customization undef char -PACKAGE_NAME_OPTION converter_customization undef char -PACKAGE_URL_OPTION converter_customization undef char -PACKAGE_VERSION_OPTION converter_customization undef char +PACKAGE converter_customization undef char +PACKAGE_AND_VERSION converter_customization undef char +PACKAGE_NAME converter_customization undef char +PACKAGE_URL converter_customization undef char +PACKAGE_VERSION converter_customization undef char PRE_BODY_CLOSE converter_customization undef char PREFIX converter_customization undef char PROGRAM converter_customization undef char diff --git a/tp/maintain/regenerate_C_options_info.pl b/tp/maintain/regenerate_C_options_info.pl index 3c2d344594..0cb6c82cb7 100755 --- a/tp/maintain/regenerate_C_options_info.pl +++ b/tp/maintain/regenerate_C_options_info.pl @@ -103,6 +103,15 @@ print HEADER "#ifndef OPTIONS_TYPES_H\n#define OPTIONS_TYPES_H\n\n"; print HEADER "#include \"main/option_types.h\"\n\n"; +print HEADER "/* Undefine values set from autoconf as we use these as\n"; +print HEADER " customization variable names. The original values are\n"; +print HEADER " available with a _CONFIG suffix, e.g. PACKAGE_CONFIG for\n"; +print HEADER " PACKAGE. */\n"; +print HEADER "#undef PACKAGE\n"; +print HEADER "#undef PACKAGE_NAME\n"; +print HEADER "#undef PACKAGE_URL\n"; +print HEADER "#undef PACKAGE_VERSION\n\n"; + print HEADER "typedef struct OPTIONS {\n"; foreach my $category (sort(keys(%option_categories))) { diff --git a/tp/t/init/t2h_singular.init b/tp/t/init/t2h_singular.init index 05dab7fcc4..c38b5c7a55 100644 --- a/tp/t/init/t2h_singular.init +++ b/tp/t/init/t2h_singular.init @@ -113,8 +113,8 @@ sub singular_format_end_file($$$) { my $self = shift; my $pre_body_close = $self->get_conf('PRE_BODY_CLOSE'); - my $program_homepage = $self->get_conf('PACKAGE_URL_OPTION'); - my $program_and_version = $self->get_conf('PACKAGE_AND_VERSION_OPTION'); + my $program_homepage = $self->get_conf('PACKAGE_URL'); + my $program_and_version = $self->get_conf('PACKAGE_AND_VERSION'); my $version = $self->get_value('VERSION'); my $version_date = $self->get_value('VERSION_DATE'); $version = 'NO VERSION' if (!defined($version)); @@ -261,8 +261,8 @@ sub singular_format_special_body_about($$$) my $version_date = $self->get_value('VERSION_DATE'); $version = 'NO VERSION' if (!defined($version)); $version_date = 'NO VERSION DATE' if (!defined($version_date)); - my $program_homepage = $self->get_conf('PACKAGE_URL_OPTION'); - my $program_and_version = $self->get_conf('PACKAGE_AND_VERSION_OPTION'); + my $program_homepage = $self->get_conf('PACKAGE_URL'); + my $program_and_version = $self->get_conf('PACKAGE_AND_VERSION'); my $result = ''; $result .= <<EOT; <p> diff --git a/tp/t/layout.t b/tp/t/layout.t index 760efb9230..c6577b67f9 100644 --- a/tp/t/layout.t +++ b/tp/t/layout.t @@ -101,7 +101,7 @@ foreach my $test (@test_cases) { } $test->[3]->{'TEXI2HTML'} = 1; $test->[3]->{'PROGRAM'} = 'texi2any'; - $test->[3]->{'PACKAGE_URL_OPTION'} = 'http://www.gnu.org/software/texinfo/'; + $test->[3]->{'PACKAGE_URL'} = 'http://www.gnu.org/software/texinfo/'; } run_all('layout', [@test_cases]); diff --git a/tp/texi2any.pl b/tp/texi2any.pl index ef9e040148..ee1fbdad9b 100755 --- a/tp/texi2any.pl +++ b/tp/texi2any.pl @@ -345,11 +345,8 @@ foreach my $configured_variable (keys(%$configured_information)) { $configured_information->{$configured_variable}); } -# here set configure information with _OPTION prepended, to mark that -# these are customization variables that may be modified in init files -# or on the command line. foreach my $configured_variable (keys(%$configured_information)) { - $main_program_set_options->{$configured_variable . '_OPTION'} + $main_program_set_options->{$configured_variable} = $configured_information->{$configured_variable}; } @@ -1147,11 +1144,11 @@ if ($cmdline_options->{'HIGHLIGHT_SYNTAX'}) { # For tests, set some strings to values not changing with releases my %test_conf = ( - 'PACKAGE_VERSION_OPTION' => '', - 'PACKAGE_OPTION' => 'texinfo', - 'PACKAGE_NAME_OPTION' => 'texinfo', - 'PACKAGE_AND_VERSION_OPTION' => 'texinfo', - 'PACKAGE_URL_OPTION' => 'http://www.gnu.org/software/texinfo/', + 'PACKAGE_VERSION' => '', + 'PACKAGE' => 'texinfo', + 'PACKAGE_NAME' => 'texinfo', + 'PACKAGE_AND_VERSION' => 'texinfo', + 'PACKAGE_URL' => 'http://www.gnu.org/software/texinfo/', # maybe don't set this? 'PROGRAM' => 'texi2any', );