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, 28 Jan 2024 16:46:03 -0500 (EST)

branch: master
commit 3aa24ebda4d28e84f2d4ecd2ff4f0703e216ca09
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 28 22:43:55 2024 +0100

    * tp/texi2any.pl, tp/t/init/redefine_need.init (my_need_formatting),
    doc/texi2any_api.texi (Getting Build Constants), tp/Texinfo/Common.pm
    b/tp/Texinfo/Common.pm (%build_constants, set_build_constant)
    (get_build_constant): rename get_constant as get_build_constant and
    set_constant as set_buikd_constant (Gavin).
---
 ChangeLog                    |  8 ++++++++
 doc/texi2any_api.texi        | 36 +++++++++++++++++++++++-------------
 tp/Texinfo/Common.pm         | 37 +++++++++++++++++++++++++++----------
 tp/t/init/redefine_need.init |  4 ++--
 tp/texi2any.pl               |  4 ++--
 5 files changed, 62 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 538ad8175f..f3ebcee995 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,14 @@
        USE_UNICODE_COLLATION is false, use the Texinfo::CollateStub
        module instead of Unicode::Collate.
 
+2024-01-28  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/texi2any.pl, tp/t/init/redefine_need.init (my_need_formatting),
+       doc/texi2any_api.texi (Getting Build Constants), tp/Texinfo/Common.pm
+       b/tp/Texinfo/Common.pm (%build_constants, set_build_constant)
+       (get_build_constant): rename get_constant as get_build_constant and
+       set_constant as set_buikd_constant (Gavin).
+
 2024-01-28  Patrice Dumas  <pertusus@free.fr>
 
        * tp/texi2any.pl: set also PACKAGE*_CONFIG to have the same symbols
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index 02940cd463..0bf8b2c78c 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -223,32 +223,42 @@ instead it is passed to functions defined in init files 
that are registered as
 functions to be called from the converter. @xref{User Defined Functions}.
 
 
-@node Getting Constants
-@section Getting Constants
+@node Getting Build Constants
+@section Getting Build Constants
 
 @cindex Constants
 
-Some constants are set independently of the output format.  They are available
-through @code{Texinfo::Common::get_constant}:
+Some constants are set independently of the output format for a Texinfo build.
+They are available through @code{Texinfo::Common::get_build_constant}:
 
-@deftypefun {@var{$value} =} Texinfo::Common::get_constant (@var{$name})
-Retrieve constant @var{$name} value.
+@deftypefun {@var{$value} =} Texinfo::Common::get_build_constant (@var{$name})
+Retrieve build constant @var{$name} value.
 @end deftypefun
 
-Available constants:
+Defined build constants:
 
 @vtable @code
 @item PACKAGE
+@itemx PACKAGE_CONFIG
 @itemx PACKAGE_AND_VERSION
+@itemx PACKAGE_AND_VERSION_CONFIG
 @itemx PACKAGE_NAME
+@itemx PACKAGE_NAME_CONFIG
 @itemx PACKAGE_VERSION
+@itemx PACKAGE_VERSION_CONFIG
 @itemx PACKAGE_URL
-
-Texinfo package name and versions. Values set by configure.
-
-Similar customization variables exist with @samp{_OPTION} prepended
-to their name and the same value set in the default case from the
-main program, with values that can be modified.
+@itemx PACKAGE_URL_CONFIG
+
+Texinfo package name and versions.  Values of build constants without
+@samp{_CONFIG} appended are set by configure.  Similar customization variables
+exist with the same value set in the default case from the main program, with
+values that can be modified.
+
+The values of the build constants with @samp{_CONFIG} appended are duplicate of
+the values of the build constants without @samp{_CONFIG}@footnote{They are
+set to correspond to macro set in the C code.  In the C code there are no
+macros with the names without @samp{_CONFIG} appended as they would clash with
+the names of the customization options.}.
 @end vtable
 
 
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 1623f6c872..fe876a718c 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -294,21 +294,21 @@ foreach my $output_format_command ('info', 'plaintext',
 
 
 # constants.  Set by the main program.
-my %constants;
+my %build_constants;
 
-sub set_constant($$)
+sub set_build_constant($$)
 {
   my $key = shift;
   my $value = shift;
 
-  $constants{$key} = $value;
+  $build_constants{$key} = $value;
 }
 
-sub get_constant($)
+sub get_build_constant($)
 {
   my $key = shift;
 
-  return $constants{$key};
+  return $build_constants{$key};
 }
 
 
@@ -2745,7 +2745,8 @@ Texinfo::Common - Texinfo modules common data and 
miscellaneous methods
     = Texinfo::Common::collect_commands_in_tree($document_root,
                                              \@commands_to_collect);
 
-  my $package_version = Texinfo::Common::get_constant('PACKAGE_AND_VERSION');
+  my $package_version
+    = Texinfo::Common::get_build_constant('PACKAGE_AND_VERSION');
 
 =head1 NOTES
 
@@ -2763,27 +2764,43 @@ methods.
 Hashes are defined as C<our> variables, and are therefore available
 outside of the module.
 
-Constants are available by calling C<get_constant>:
+Values defined for a Texinfo build independently of any document or
+output format are available by calling C<get_build_constant>:
 
 =over
 
-=item $value = get_constant($name)
+=item $value = get_build_constant($name)
 
-The following constants are available:
+The following build constants are available:
 
 =over
 
 =item PACKAGE
 
+=item PACKAGE_CONFIG
+
 =item PACKAGE_AND_VERSION
 
+=item PACKAGE_AND_VERSION_CONFIG
+
 =item PACKAGE_NAME
 
+=item PACKAGE_NAME_CONFIG
+
 =item PACKAGE_VERSION
 
+=item PACKAGE_VERSION_CONFIG
+
 =item PACKAGE_URL
 
-Texinfo package name and versions.  Values set by configure.
+=item PACKAGE_URL_CONFIG
+
+Texinfo package name and versions.  Values of build constants without
+C<_CONFIG> appended are set by configure.  For each variable set by
+configure there is another one with C<_CONFIG> appended
+to the name set to the same value, to match the name of the macros set in
+C.  So, for example C<PACKAGE_VERSION_CONFIG> value is the same as
+C<PACKAGE_VERSION>, set to the C<PACKAGE_VERSION> value set by configure.
 
 =back
 
diff --git a/tp/t/init/redefine_need.init b/tp/t/init/redefine_need.init
index 891d9f1722..3297c116f3 100644
--- a/tp/t/init/redefine_need.init
+++ b/tp/t/init/redefine_need.init
@@ -11,9 +11,9 @@ sub my_need_formatting($$$)
   my $cmdname = shift;
   my $command = shift;
 
-  my $package = Texinfo::Common::get_constant('PACKAGE');
+  my $package = Texinfo::Common::get_build_constant('PACKAGE');
   $package = '' if (!defined($package));
-  my $package_config = Texinfo::Common::get_constant('PACKAGE_CONFIG');
+  my $package_config = Texinfo::Common::get_build_constant('PACKAGE_CONFIG');
   $package_config = '' if (!defined($package_config));
 
   if ($command->{'extra'} and $command->{'extra'}->{'misc_args'}
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index f558094eb2..95001a9c52 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -341,10 +341,10 @@ my $main_program_set_options = {
 
 # set configure information as constants
 foreach my $configured_variable (keys(%$configured_information)) {
-  Texinfo::Common::set_constant($configured_variable,
+  Texinfo::Common::set_build_constant($configured_variable,
                        $configured_information->{$configured_variable});
   # set also with _CONFIG prepended, as in C code.
-  Texinfo::Common::set_constant($configured_variable.'_CONFIG',
+  Texinfo::Common::set_build_constant($configured_variable.'_CONFIG',
                        $configured_information->{$configured_variable});
 }
 



reply via email to

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