[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Thu, 3 Oct 2024 13:43:01 -0400 (EDT) |
branch: master
commit 379190e46d6b3ccdbad4540ee3b2b791e82770ea
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Aug 5 21:29:18 2024 +0200
* tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_customize),
tp/Texinfo/XS/convert/convert_html.c (html_converter_customize):
rename html_converter_initialize as html_converter_customize.
* tp/Texinfo/XS/convert/converter.c (converter_format_data)
(set_converter_init_information), tp/Texinfo/XS/convert/converter.h
(CONVERTER_FORMAT_DATA): add a converter_initialize function reference
field in CONVERTER_FORMAT_DATA and call it in
set_converter_init_information.
* tp/Texinfo/Convert/HTML.pm (converter_initialize),
tp/Texinfo/XS/convert/converter.c (converter_format_data),
tp/Texinfo/XS/convert/html_converter_init_options.c
(html_converter_initialize): add html_converter_initialize with
code in Perl converter_initialize function that does not need
customization information from Perl. set html_converter_initialize in
converter_format_data. Separate code in Perl converter_initialize
that is already called in html_converter_initialize and put it in a
conditional at the beginning of the function.
---
ChangeLog | 22 +++++++
tp/Texinfo/Convert/HTML.pm | 71 ++++++++++++----------
tp/Texinfo/XS/convert/ConvertXS.xs | 2 +-
tp/Texinfo/XS/convert/convert_html.c | 11 ++--
tp/Texinfo/XS/convert/convert_html.h | 2 +-
tp/Texinfo/XS/convert/converter.c | 12 +++-
tp/Texinfo/XS/convert/converter.h | 1 +
.../XS/convert/html_converter_init_options.c | 47 +++++++++++++-
.../XS/convert/html_converter_init_options.h | 2 +
9 files changed, 127 insertions(+), 43 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 53e8f32621..af7344079c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-08-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_customize),
+ tp/Texinfo/XS/convert/convert_html.c (html_converter_customize):
+ rename html_converter_initialize as html_converter_customize.
+
+ * tp/Texinfo/XS/convert/converter.c (converter_format_data)
+ (set_converter_init_information), tp/Texinfo/XS/convert/converter.h
+ (CONVERTER_FORMAT_DATA): add a converter_initialize function reference
+ field in CONVERTER_FORMAT_DATA and call it in
+ set_converter_init_information.
+
+ * tp/Texinfo/Convert/HTML.pm (converter_initialize),
+ tp/Texinfo/XS/convert/converter.c (converter_format_data),
+ tp/Texinfo/XS/convert/html_converter_init_options.c
+ (html_converter_initialize): add html_converter_initialize with
+ code in Perl converter_initialize function that does not need
+ customization information from Perl. set html_converter_initialize in
+ converter_format_data. Separate code in Perl converter_initialize
+ that is already called in html_converter_initialize and put it in a
+ conditional at the beginning of the function.
+
2024-08-05 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/Makefile.am (libtexinfo_convert_la_SOURCES): rename
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index a6f7ec1b91..c1450a2924 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -8699,6 +8699,44 @@ sub converter_initialize($)
{
my $self = shift;
+ if (!($self->{'converter_descriptor'} and $XS_convert)) {
+ # initializatin done either in Perl or XS
+
+ # used in initialization. Set if undef
+ if (!defined($self->get_conf('FORMAT_MENU'))) {
+ $self->force_conf('FORMAT_MENU', '');
+ }
+
+ # NOTE we reset silently if the split specification is not one known.
+ # The main program warns if the specific command line option value is
+ # not known. We could add a warning here to catch mistakes in init
+ # files. Wait for user reports.
+ my $split = $self->get_conf('SPLIT');
+ if ($split and $split ne 'chapter'
+ and $split ne 'section'
+ and $split ne 'node') {
+ $self->force_conf('SPLIT', 'node');
+ }
+
+ my $max_header_level = $self->get_conf('MAX_HEADER_LEVEL');
+ if (!defined($max_header_level)) {
+ $self->force_conf('MAX_HEADER_LEVEL', $defaults{'MAX_HEADER_LEVEL'});
+ } elsif ($max_header_level < 1) {
+ $self->force_conf('MAX_HEADER_LEVEL', 1);
+ }
+
+ # For CONTENTS_OUTPUT_LOCATION
+ # should lead to contents not output, but if not, it is not an issue,
+ # the way to set contents to be output or not should be through the
+ # contents and shortcontents @-commands and customization options.
+ foreach my $conf ('CONTENTS_OUTPUT_LOCATION', 'INDEX_ENTRY_COLON',
+ 'MENU_ENTRY_COLON') {
+ if (!defined($self->get_conf($conf))) {
+ $self->force_conf($conf, '');
+ }
+ }
+ }
+
_load_htmlxref_files($self);
$self->{'output_units_conversion'} = {};
@@ -8769,11 +8807,6 @@ sub converter_initialize($)
= $customized_upper_case_commands->{$command};
}
- # used just below. Set if undef
- if (!defined($self->get_conf('FORMAT_MENU'))) {
- $self->force_conf('FORMAT_MENU', '');
- }
-
$self->{'commands_conversion'} = {};
my $customized_commands_conversion
= Texinfo::Config::GNUT_get_commands_conversion();
@@ -9049,34 +9082,6 @@ sub converter_initialize($)
$self->{'stage_handlers'} = Texinfo::Config::GNUT_get_stage_handlers();
- # NOTE we reset silently if the split specification is not one known.
- # The main program warns if the specific command line option value is
- # not known. We could add a warning here to catch mistakes in init
- # files. Wait for user reports.
- my $split = $self->get_conf('SPLIT');
- if ($split and $split ne 'chapter'
- and $split ne 'section'
- and $split ne 'node') {
- $self->force_conf('SPLIT', 'node');
- }
-
- my $max_header_level = $self->get_conf('MAX_HEADER_LEVEL');
- if (!defined($max_header_level)) {
- $self->force_conf('MAX_HEADER_LEVEL', $defaults{'MAX_HEADER_LEVEL'});
- } elsif ($max_header_level < 1) {
- $self->force_conf('MAX_HEADER_LEVEL', 1);
- }
-
- # For CONTENTS_OUTPUT_LOCATION
- # should lead to contents not output, but if not, it is not an issue,
- # the way to set contents to be output or not should be through the
- # contents and shortcontents @-commands and customization options.
- foreach my $conf ('CONTENTS_OUTPUT_LOCATION', 'INDEX_ENTRY_COLON',
- 'MENU_ENTRY_COLON') {
- if (!defined($self->get_conf($conf))) {
- $self->force_conf($conf, '');
- }
- }
# XS parser initialization
if ($self->{'converter_descriptor'} and $XS_convert) {
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 0d3cae2bf2..745654aed1 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -637,7 +637,7 @@ html_converter_initialize_sv (SV *converter_in, SV
*default_formatting_reference
customized_no_arg_commands_formatting,
customized_direction_strings);
- html_converter_initialize (self);
+ html_converter_customize (self);
/* at that point, the format specific informations, in particular the
direction names is available, such that the directions can be set
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index e6dec48477..080acb6109 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -17499,12 +17499,13 @@ determine_non_default_special_unit_directions (const
CONVERTER *self)
return non_default_special_unit_directions;
}
-/* most of the initialization is done by html_converter_initialize_sv
- in get_perl_info, the initialization that do not require information
- directly from perl data is done here. This is called after information
- from perl has been gathered */
+/* When initializing from Perl, html_converter_initialize_sv is called first
+ to set customization information based on Perl data. Then this function
+ is called for the remainder of initialization that requires customization
+ information.
+ */
void
-html_converter_initialize (CONVERTER *self)
+html_converter_customize (CONVERTER *self)
{
int i;
enum direction_string_type DS_type;
diff --git a/tp/Texinfo/XS/convert/convert_html.h
b/tp/Texinfo/XS/convert/convert_html.h
index f7b796a125..ac1b3d5cfb 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -44,7 +44,7 @@ extern COMMAND_ID_LIST no_arg_formatted_cmd;
void html_format_setup (void);
void html_converter_init_special_unit (CONVERTER *self);
-void html_converter_initialize (CONVERTER *self);
+void html_converter_customize (CONVERTER *self);
void html_initialize_output_state (CONVERTER *self, const char *context);
void init_conversion_after_setup_handler (CONVERTER *self);
diff --git a/tp/Texinfo/XS/convert/converter.c
b/tp/Texinfo/XS/convert/converter.c
index 62ad61a449..379688c9d0 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -61,7 +61,7 @@
#include "converter.h"
CONVERTER_FORMAT_DATA converter_format_data[] = {
- {"html", "Texinfo::Convert::HTML", &html_converter_defaults},
+ {"html", "Texinfo::Convert::HTML", &html_converter_defaults,
&html_converter_initialize},
};
/* associate lower case no brace accent command to the upper case
@@ -245,6 +245,7 @@ new_converter (void)
return converter_index +1;
}
+/* apply initialization information from one source */
static void
apply_converter_info (CONVERTER *converter,
CONVERTER_INITIALIZATION_INFO *init_info, int set_configured)
@@ -271,6 +272,8 @@ apply_converter_info (CONVERTER *converter,
}
}
+/* apply format_defaults and user_conf initialization information and call
+ format specific options setting and initialization functions */
void
set_converter_init_information (CONVERTER *converter,
enum converter_format converter_format,
@@ -307,6 +310,13 @@ set_converter_init_information (CONVERTER *converter,
converter->converted_format);
*/
+ if (converter_format != COF_none
+ && converter_format_data[converter_format].converter_initialize)
+ {
+ void (* converter_initialize) (CONVERTER *self)
+ = converter_format_data[converter_format].converter_initialize;
+ converter_initialize (converter);
+ }
}
CONVERTER_INITIALIZATION_INFO *
diff --git a/tp/Texinfo/XS/convert/converter.h
b/tp/Texinfo/XS/convert/converter.h
index a5062cb365..29876712e7 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -100,6 +100,7 @@ typedef struct CONVERTER_FORMAT_DATA {
const char *perl_converter_class;
void (* converter_defaults) (CONVERTER *self,
CONVERTER_INITIALIZATION_INFO *conf);
+ void (* converter_initialize) (CONVERTER *self);
} CONVERTER_FORMAT_DATA;
extern enum command_id no_brace_command_accent_upper_case[][2];
diff --git a/tp/Texinfo/XS/convert/html_converter_init_options.c
b/tp/Texinfo/XS/convert/html_converter_init_options.c
index 2a9b37c098..9892052349 100644
--- a/tp/Texinfo/XS/convert/html_converter_init_options.c
+++ b/tp/Texinfo/XS/convert/html_converter_init_options.c
@@ -17,16 +17,20 @@
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
+#include <stddef.h>
#include "tree_types.h"
#include "option_types.h"
#include "converter_types.h"
#include "converters_defaults.h"
#include "utils.h"
+#include "converter.h"
#include "html_converter_init_options.h"
-/* code for converters options setting. Not with format specific converter
- code, since this code is called from generic converter code. */
+/* HTML converter options setting and initialization. Not with format
+ specific converter code, since this code is called from generic
+ converter code. */
/* should be consistent with enum BUTTON_special_unit_directions. See
the comment there */
@@ -362,3 +366,42 @@ html_converter_defaults (CONVERTER *self,
}
}
}
+
+/* this code corresponds to the Perl converter_initialize code, only for
+ code to be called before Perl customization setup information is passed */
+void
+html_converter_initialize (CONVERTER *self)
+{
+ const char *split = self->conf->SPLIT.o.string;
+ int max_header_level = self->conf->MAX_HEADER_LEVEL.o.integer;
+
+ if (!self->conf->FORMAT_MENU.o.string)
+ force_conf (&self->conf->FORMAT_MENU, 0, "");
+
+ /* NOTE we reset silently if the split specification is not one known.
+ The main program warns if the specific command line option value is
+ not known. We could add a warning here to catch mistakes in init
+ files. Wait for user reports.
+ */
+ if (split && strlen (split) && strcmp (split, "chapter")
+ && strcmp (split, "section") && strcmp (split, "node"))
+ force_conf (&self->conf->SPLIT, 0, "node");
+
+ if (max_header_level < 0)
+ force_conf (&self->conf->MAX_HEADER_LEVEL, 4, 0);
+ else if (max_header_level < 1)
+ force_conf (&self->conf->MAX_HEADER_LEVEL, 1, 0);
+
+ /* For CONTENTS_OUTPUT_LOCATION
+ should lead to contents not output, but if not, it is not an issue,
+ the way to set contents to be output or not should be through the
+ contents and shortcontents @-commands and customization options.
+ */
+
+ if (!self->conf->CONTENTS_OUTPUT_LOCATION.o.string)
+ force_conf (&self->conf->CONTENTS_OUTPUT_LOCATION, 0, "");
+ if (!self->conf->INDEX_ENTRY_COLON.o.string)
+ force_conf (&self->conf->INDEX_ENTRY_COLON, 0, "");
+ if (!self->conf->MENU_ENTRY_COLON.o.string)
+ force_conf (&self->conf->MENU_ENTRY_COLON, 0, "");
+}
diff --git a/tp/Texinfo/XS/convert/html_converter_init_options.h
b/tp/Texinfo/XS/convert/html_converter_init_options.h
index 39006663ed..6bce290011 100644
--- a/tp/Texinfo/XS/convert/html_converter_init_options.h
+++ b/tp/Texinfo/XS/convert/html_converter_init_options.h
@@ -15,4 +15,6 @@ enum BUTTON_special_unit_directions {
void html_converter_defaults (CONVERTER *self,
CONVERTER_INITIALIZATION_INFO *format_defaults);
+
+void html_converter_initialize (CONVERTER *self);
#endif