[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Con
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/DocBook.pm, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm, tp/Texinfo/Convert/TexinfoMarkup.pm, tp/Texinfo/Convert/Text.pm, tp/Texinfo/Convert/TextContent.pm, tp/t/test_utils.pl: rename expanded_formats_hash as expanded_formats. |
Date: |
Sat, 28 Oct 2023 16:34:48 -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 ab688270ce * tp/Texinfo/Convert/Converter.pm,
tp/Texinfo/Convert/DocBook.pm, tp/Texinfo/Convert/HTML.pm,
tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
tp/Texinfo/Convert/TexinfoMarkup.pm, tp/Texinfo/Convert/Text.pm,
tp/Texinfo/Convert/TextContent.pm, tp/t/test_utils.pl: rename
expanded_formats_hash as expanded_formats.
ab688270ce is described below
commit ab688270cea5cc90df2c41d7fb894b4233a1e113
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Oct 28 22:32:50 2023 +0200
* tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/DocBook.pm,
tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/LaTeX.pm,
tp/Texinfo/Convert/Plaintext.pm, tp/Texinfo/Convert/TexinfoMarkup.pm,
tp/Texinfo/Convert/Text.pm, tp/Texinfo/Convert/TextContent.pm,
tp/t/test_utils.pl: rename expanded_formats_hash as expanded_formats.
* tp/Texinfo/XS/main/utils.h (EXPANDED_FORMAT): set typedef for struct
expanded_format. Update all code using this type.
* tp/Texinfo/Convert/Converter.pm (encode_converter_document),
tp/Texinfo/XS/main/get_perl_info.c (get_expanded_formats)
(copy_sv_options_for_convert_text, html_converter_initialize_sv):
pass expanded_formats to converter.
* tp/Texinfo/XS/convert/ConvertXS.xs (html_translate_names)
(html_convert_convert): if self->modified_state, rebuild formatting
state after calling the C function.
* tp/Texinfo/XS/convert/convert_html.c (COMMAND_ID_ARGS_SPECIFICATION)
(COMMAND_ARGS_SPECIFICATION, html_converter_initialize)
(convert_to_html_internal): use systematically unsigned long for flags
and correctly multiply by the size when copying.
* tp/Texinfo/XS/main/convert_to_text.c
(TEXT_INDICATOR_CONVERTER_OPTIONS, copy_options_for_convert_text),
tp/Texinfo/XS/main/convert_to_text.h (TEXT_OPTIONS),
tp/Texinfo/XS/main/get_perl_info.c (copy_sv_options_for_convert_text):
add copy_options_for_convert_text to be called from converters.
Upper-case TEXT_OPTIONS fields common with OPTIONS.
* tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal):
set convert_to_text formatted args.
* tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal):
free command_type.text.
---
ChangeLog | 38 ++++++++++++
tp/Texinfo/Convert/Converter.pm | 10 +--
tp/Texinfo/Convert/DocBook.pm | 8 +--
tp/Texinfo/Convert/HTML.pm | 6 +-
tp/Texinfo/Convert/LaTeX.pm | 6 +-
tp/Texinfo/Convert/Plaintext.pm | 6 +-
tp/Texinfo/Convert/TexinfoMarkup.pm | 8 +--
tp/Texinfo/Convert/Text.pm | 28 ++++-----
tp/Texinfo/Convert/TextContent.pm | 6 +-
tp/Texinfo/XS/convert/ConvertXS.xs | 12 ++++
tp/Texinfo/XS/convert/convert_html.c | 100 +++++++++++++++++-------------
tp/Texinfo/XS/main/build_perl_info.c | 1 -
tp/Texinfo/XS/main/convert_to_text.c | 48 ++++++++++++--
tp/Texinfo/XS/main/convert_to_text.h | 11 ++--
tp/Texinfo/XS/main/get_perl_info.c | 58 ++++++++++-------
tp/Texinfo/XS/main/utils.c | 12 ++--
tp/Texinfo/XS/main/utils.h | 13 ++--
tp/Texinfo/XS/parsetexi/handle_commands.c | 2 +-
tp/Texinfo/XS/parsetexi/parser.c | 2 +-
tp/t/test_utils.pl | 6 +-
20 files changed, 251 insertions(+), 130 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0f7903f663..ab30582d09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,44 @@
unnecessarily on users' systems (report from Rafael Fontenelle).
It was only added for the sake of the test.
+2023-10-28 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/DocBook.pm,
+ tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/LaTeX.pm,
+ tp/Texinfo/Convert/Plaintext.pm, tp/Texinfo/Convert/TexinfoMarkup.pm,
+ tp/Texinfo/Convert/Text.pm, tp/Texinfo/Convert/TextContent.pm,
+ tp/t/test_utils.pl: rename expanded_formats_hash as expanded_formats.
+
+ * tp/Texinfo/XS/main/utils.h (EXPANDED_FORMAT): set typedef for struct
+ expanded_format. Update all code using this type.
+
+ * tp/Texinfo/Convert/Converter.pm (encode_converter_document),
+ tp/Texinfo/XS/main/get_perl_info.c (get_expanded_formats)
+ (copy_sv_options_for_convert_text, html_converter_initialize_sv):
+ pass expanded_formats to converter.
+
+ * tp/Texinfo/XS/convert/ConvertXS.xs (html_translate_names)
+ (html_convert_convert): if self->modified_state, rebuild formatting
+ state after calling the C function.
+
+ * tp/Texinfo/XS/convert/convert_html.c (COMMAND_ID_ARGS_SPECIFICATION)
+ (COMMAND_ARGS_SPECIFICATION, html_converter_initialize)
+ (convert_to_html_internal): use systematically unsigned long for flags
+ and correctly multiply by the size when copying.
+
+ * tp/Texinfo/XS/main/convert_to_text.c
+ (TEXT_INDICATOR_CONVERTER_OPTIONS, copy_options_for_convert_text),
+ tp/Texinfo/XS/main/convert_to_text.h (TEXT_OPTIONS),
+ tp/Texinfo/XS/main/get_perl_info.c (copy_sv_options_for_convert_text):
+ add copy_options_for_convert_text to be called from converters.
+ Upper-case TEXT_OPTIONS fields common with OPTIONS.
+
+ * tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal):
+ set convert_to_text formatted args.
+
+ * tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal):
+ free command_type.text.
+
2023-10-28 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize):
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 59e53a960e..e634282d20 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -230,13 +230,12 @@ sub converter($;$)
Texinfo::Common::set_output_encodings($converter,
$converter->{'document_info'});
- # turn the array to a hash for speed. Not sure it really matters for such
- # a small array.
+ # turn the array to a hash.
my $expanded_formats = $converter->get_conf('EXPANDED_FORMATS');
- $converter->{'expanded_formats_hash'} = {};
+ $converter->{'expanded_formats'} = {};
if (defined($expanded_formats)) {
foreach my $expanded_format (@{$converter->get_conf('EXPANDED_FORMATS')}) {
- $converter->{'expanded_formats_hash'}->{$expanded_format} = 1;
+ $converter->{'expanded_formats'}->{$expanded_format} = 1;
}
}
@@ -442,7 +441,8 @@ sub encode_converter_document($)
# and set converter_descriptor
'document_descriptor' => $self->{'document_descriptor'}};
- foreach my $variable ('style_commands_formatting', 'formatting_function',
+ foreach my $variable ('expanded_formats', 'style_commands_formatting',
+ 'formatting_function',
'types_open', 'types_conversion', 'commands_open', 'commands_conversion',
'output_units_conversion', 'code_types', 'pre_class_types') {
if ($self->{$variable}) {
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index 963af22700..c14180980c 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -288,7 +288,7 @@ sub converter_initialize($)
foreach my $raw (grep {$Texinfo::Commands::block_commands{$_} eq
'format_raw'}
keys(%Texinfo::Commands::block_commands)) {
$self->{'context_block_commands'}->{$raw} = 1
- if $self->{'expanded_formats_hash'}->{$raw};
+ if $self->{'expanded_formats'}->{$raw};
}
}
@@ -1446,7 +1446,7 @@ sub _convert($$;$)
if ($Texinfo::Commands::inline_format_commands{$element->{'cmdname'}})
{
if ($element->{'cmdname'} eq 'inlinefmtifelse'
or ($element->{'extra'} and $element->{'extra'}->{'format'}
- and
$self->{'expanded_formats_hash'}->{$element->{'extra'}->{'format'}})) {
+ and
$self->{'expanded_formats'}->{$element->{'extra'}->{'format'}})) {
$expand = 1;
}
} elsif (defined($element->{'extra'}->{'expand_index'})) {
@@ -1458,7 +1458,7 @@ sub _convert($$;$)
$self->_new_document_context();
$self->{'document_context'}->[-1]->{'raw'} = 1;
} elsif ($element->{'cmdname'} eq 'inlinefmtifelse'
- and !
$self->{'expanded_formats_hash'}->{$element->{'extra'}->{'format'}}) {
+ and !
$self->{'expanded_formats'}->{$element->{'extra'}->{'format'}}) {
$arg_index = 2;
}
if (scalar(@{$element->{'args'}}) > $arg_index
@@ -1608,7 +1608,7 @@ sub _convert($$;$)
}
}
} elsif ($Texinfo::Commands::block_commands{$element->{'cmdname'}} eq
'format_raw') {
- return '' if
(!$self->{'expanded_formats_hash'}->{$element->{'cmdname'}});
+ return '' if (!$self->{'expanded_formats'}->{$element->{'cmdname'}});
# the context is here only for the command, so this is forgotten
# once all the raw internal text has been formatted
$self->{'document_context'}->[-1]->{'raw'} = 1;
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 1a01f8b9e1..64bc6a6dd5 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -659,7 +659,7 @@ sub is_format_expanded($$)
my $self = shift;
my $format = shift;
- return $self->{'expanded_formats_hash'}->{$format};
+ return $self->{'expanded_formats'}->{$format};
}
# the main data structure of the element target API is a hash reference, called
@@ -8189,7 +8189,7 @@ sub converter_initialize($)
and ($command eq 'menu' or $command eq 'detailmenu')) {
$self->{'commands_conversion'}->{$command} = undef;
} elsif ($format_raw_commands{$command}
- and !$self->{'expanded_formats_hash'}->{$command}) {
+ and !$self->{'expanded_formats'}->{$command}) {
$self->{'commands_conversion'}->{$command} = undef;
} elsif (exists($default_commands_conversion{$command})) {
$self->{'commands_conversion'}->{$command}
@@ -11109,7 +11109,7 @@ sub convert($$)
# and SHOW_TITLE set, with the default formatting function.
if ($self->{'converter_descriptor'}) {
# FIXME distinguish failure and no title? Could actually use
- # unddef for failurre, as without title, return an empty string.
+ # undef for failure, as without title, return an empty string.
my $title_titlepage =
_XS_html_convert_init($encoded_converter);
$self->{'title_titlepage'} = $title_titlepage;
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 24aa706344..571a361454 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -839,7 +839,7 @@ sub converter_initialize($)
foreach my $format (keys(%format_raw_commands)) {
$self->{'ignored_commands'}->{$format} = 1
- unless ($self->{'expanded_formats_hash'}->{$format});
+ unless ($self->{'expanded_formats'}->{$format});
}
%{$self->{'quotes_map'}} = %quotes_map;
@@ -2616,7 +2616,7 @@ sub _convert($$)
and $cmdname ne 'inlinefmtifelse'
and (($inline_format_commands{$cmdname}
and (!$element->{'extra'}->{'format'}
- or !$self->{'expanded_formats_hash'}
+ or !$self->{'expanded_formats'}
->{$element->{'extra'}->{'format'}}))
or (!$inline_format_commands{$cmdname}
and
!defined($element->{'extra'}->{'expand_index'}))))))) {
@@ -3451,7 +3451,7 @@ sub _convert($$)
my $arg_index = 1;
if ($cmdname eq 'inlinefmtifelse'
and (!$element->{'extra'}->{'format'}
- or !$self->{'expanded_formats_hash'}
+ or !$self->{'expanded_formats'}
->{$element->{'extra'}->{'format'}})) {
$arg_index = 2;
}
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 517efbee61..c9d0a75ed0 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -432,7 +432,7 @@ sub converter_initialize($)
foreach my $format (keys(%format_raw_commands)) {
$self->{'ignored_commands'}->{$format} = 1
- unless ($self->{'expanded_formats_hash'}->{$format});
+ unless ($self->{'expanded_formats'}->{$format});
}
if ($self->get_conf('ASCII_PUNCTUATION')) {
@@ -1764,7 +1764,7 @@ sub _convert($$)
and $command ne 'inlinefmtifelse'
and (($inline_format_commands{$command}
and (!$element->{'extra'}->{'format'}
- or !$self->{'expanded_formats_hash'}
+ or !$self->{'expanded_formats'}
->{$element->{'extra'}->{'format'}}))
or (!$inline_format_commands{$command}
and
!defined($element->{'extra'}->{'expand_index'}))))))) {
@@ -2553,7 +2553,7 @@ sub _convert($$)
my $arg_index = 1;
if ($command eq 'inlinefmtifelse'
and (!$element->{'extra'}->{'format'}
- or !$self->{'expanded_formats_hash'}
+ or !$self->{'expanded_formats'}
->{$element->{'extra'}->{'format'}})) {
$arg_index = 2;
}
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index e78362d7ef..3a4be63f7e 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -275,7 +275,7 @@ sub converter_initialize($)
foreach my $raw (grep {$Texinfo::Commands::block_commands{$_} eq
'format_raw'}
keys(%Texinfo::Commands::block_commands)) {
$self->{'context_block_commands'}->{$raw} = 1
- if $self->{'expanded_formats_hash'}->{$raw};
+ if $self->{'expanded_formats'}->{$raw};
}
}
@@ -1041,7 +1041,7 @@ sub _convert($$;$)
if ($Texinfo::Commands::inline_format_commands{$element->{'cmdname'}}
and $element->{'extra'} and $element->{'extra'}->{'format'}
- and
$self->{'expanded_formats_hash'}->{$element->{'extra'}->{'format'}}) {
+ and $self->{'expanded_formats'}->{$element->{'extra'}->{'format'}}) {
if ($element->{'cmdname'} eq 'inlineraw') {
push @{$self->{'document_context'}}, {'monospace' => [0]};
$self->{'document_context'}->[-1]->{'raw'} = 1;
@@ -1292,7 +1292,7 @@ sub _convert($$;$)
}
push @$attribute, $self->_arg_line($element);
}
- if ($self->{'expanded_formats_hash'}->{$element->{'cmdname'}}) {
+ if ($self->{'expanded_formats'}->{$element->{'cmdname'}}) {
$self->{'document_context'}->[-1]->{'raw'} = 1;
} else {
my @end_command_spaces;
@@ -1587,7 +1587,7 @@ sub _convert($$;$)
}
if ($element->{'cmdname'}
and exists($Texinfo::Commands::block_commands{$element->{'cmdname'}})) {
- if ($self->{'expanded_formats_hash'}->{$element->{'cmdname'}}) {
+ if ($self->{'expanded_formats'}->{$element->{'cmdname'}}) {
} else {
if ($element->{'contents'} and scalar(@{$element->{'contents'}}) > 0
and $element->{'contents'}->[-1]->{'cmdname'}
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 47cadc141a..143832ec19 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -366,6 +366,8 @@ sub text_heading($$$;$$)
}
my @text_indicator_converter_options = ('NUMBER_SECTIONS', 'ASCII_GLYPH',
'TEST',
+ # FIXME not used directly in the module code. It is unlikely for that
variable
+ # to be used elsewhere from text options and not converter options.
# for error registering,
'DEBUG');
@@ -397,11 +399,9 @@ sub copy_options_for_convert_text($;$)
$options{$option} = 0;
}
}
- $options{'expanded_formats_hash'} = $self->{'expanded_formats_hash'};
+ $options{'expanded_formats'} = $self->{'expanded_formats'};
# for locate_include_file
$options{'INCLUDE_DIRECTORIES'} = $self->get_conf('INCLUDE_DIRECTORIES');
- # FIXME remove
- $options{'PROGRAM'} = $self->get_conf('PROGRAM');
$options{'converter'} = $self;
return %options;
@@ -431,9 +431,9 @@ sub encode_text_options($)
}
}
- if (defined($options->{'expanded_formats_hash'})) {
+ if (defined($options->{'expanded_formats'})) {
my $expanded_formats = [];
- foreach my $format (keys(%{$options->{'expanded_formats_hash'}})) {
+ foreach my $format (keys(%{$options->{'expanded_formats'}})) {
push @$expanded_formats, Encode::encode("UTF-8", $format);
}
$encoded_options->{'expanded_formats'} = $expanded_formats;
@@ -528,8 +528,8 @@ sub _convert($;$)
and ($ignored_brace_commands{$element->{'cmdname'}}
or $ignored_block_commands{$element->{'cmdname'}}
or ($ignored_format_raw_commands{$element->{'cmdname'}}
- and !(defined($options->{'expanded_formats_hash'})
- and $options->{'expanded_formats_hash'}
+ and !(defined($options->{'expanded_formats'})
+ and $options->{'expanded_formats'}
->{$element->{'cmdname'}}))
or ($Texinfo::Commands::brace_commands{$element->{'cmdname'}}
and $Texinfo::Commands::brace_commands{
@@ -538,8 +538,8 @@ sub _convert($;$)
and (($Texinfo::Commands::inline_format_commands{
$element->{'cmdname'}}
and (!$element->{'extra'}->{'format'}
- or !$options->{'expanded_formats_hash'}
- or !$options->{'expanded_formats_hash'}
+ or !$options->{'expanded_formats'}
+ or !$options->{'expanded_formats'}
->{$element->{'extra'}->{'format'}}))
or (!$Texinfo::Commands::inline_format_commands{
$element->{'cmdname'}}
@@ -663,8 +663,8 @@ sub _convert($;$)
my $arg_index = 1;
if ($element->{'cmdname'} eq 'inlinefmtifelse'
and (!$element->{'extra'}->{'format'}
- or !$options->{'expanded_formats_hash'}
- or !$options->{'expanded_formats_hash'}
+ or !$options->{'expanded_formats'}
+ or !$options->{'expanded_formats'}
->{$element->{'extra'}->{'format'}})) {
$arg_index = 2;
}
@@ -858,9 +858,9 @@ sub converter($;$)
delete $converter->{'document'};
}
if ($expanded_formats) {
- $converter->{'expanded_formats_hash'} = {};
+ $converter->{'expanded_formats'} = {};
foreach my $expanded_format(@$expanded_formats) {
- $converter->{'expanded_formats_hash'}->{$expanded_format} = 1;
+ $converter->{'expanded_formats'}->{$expanded_format} = 1;
}
}
@@ -1145,7 +1145,7 @@ object may be used during conversion. Mostly error
reporting and strings
translation, as the converter object is also supposed to be a
L<Texinfo::Report> objet. See also L<Texinfo::Convert::Converter>.
-=item expanded_formats_hash
+=item expanded_formats
A reference on a hash. The keys should be format names (like C<html>,
C<tex>), and if the corresponding value is set, the format is expanded.
diff --git a/tp/Texinfo/Convert/TextContent.pm
b/tp/Texinfo/Convert/TextContent.pm
index dd5590a82d..cd6848f6a3 100644
--- a/tp/Texinfo/Convert/TextContent.pm
+++ b/tp/Texinfo/Convert/TextContent.pm
@@ -112,11 +112,11 @@ sub _convert($$)
or ($element->{'cmdname'}
and ($ignored_brace_commands{$element->{'cmdname'}}
or ($ignored_block_commands{$element->{'cmdname'}}
- and !(defined($self->{'expanded_formats_hash'})
- and
$self->{'expanded_formats_hash'}->{$element->{'cmdname'}}))
+ and !(defined($self->{'expanded_formats'})
+ and
$self->{'expanded_formats'}->{$element->{'cmdname'}}))
or
($Texinfo::Commands::inline_format_commands{$element->{'cmdname'}}
and (!$element->{'extra'}->{'format'}
- or
!$self->{'expanded_formats_hash'}->{$element->{'extra'}->{'format'}}))
+ or
!$self->{'expanded_formats'}->{$element->{'extra'}->{'format'}}))
or ($element->{'cmdname'} eq 'menu' and
$self->get_conf('FORMAT_MENU') eq 'nomenu')
# here ignore most of the line commands
or ($element->{'args'} and $element->{'args'}->[0]
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 9bd182c8b5..30104d0a80 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -315,6 +315,13 @@ html_translate_names (SV *converter_in)
html_translate_names (self);
+ if (self->modified_state)
+ {
+ build_html_formatting_state (self);
+ self->modified_state = 0;
+ }
+
+
SV *
html_convert_init (SV *converter_in)
PREINIT:
@@ -355,6 +362,11 @@ html_convert_convert (SV *converter_in, SV *tree_in, SV
*output_units_in, SV *sp
result = html_convert_convert (self, document->tree,
output_units_descriptor,
special_units_descriptor);
+ if (self->modified_state)
+ {
+ build_html_formatting_state (self);
+ self->modified_state = 0;
+ }
RETVAL = newSVpv_utf8 (result, 0);
free (result);
OUTPUT:
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 653d67185d..5f6266398d 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -75,7 +75,7 @@ static HTML_COMMAND_STRUCT
html_commands_data[BUILTIN_CMD_NUMBER];
typedef struct COMMAND_ID_ARGS_SPECIFICATION {
enum command_id cmd;
- int flags[MAX_COMMAND_ARGS_NR];
+ unsigned long flags[MAX_COMMAND_ARGS_NR];
} COMMAND_ID_ARGS_SPECIFICATION;
static COMMAND_ID_ARGS_SPECIFICATION default_commands_args[] = {
@@ -106,7 +106,7 @@ static COMMAND_ID_ARGS_SPECIFICATION
default_commands_args[] = {
typedef struct COMMAND_ARGS_SPECIFICATION {
int status;
- int flags [MAX_COMMAND_ARGS_NR];
+ unsigned long flags[MAX_COMMAND_ARGS_NR];
} COMMAND_ARGS_SPECIFICATION;
static COMMAND_ARGS_SPECIFICATION command_args_flags[BUILTIN_CMD_NUMBER];
@@ -2211,7 +2211,7 @@ html_converter_initialize (CONVERTER *self)
enum command_id cmd = default_commands_args[i].cmd;
command_args_flags[cmd].status = 1;
memcpy (&command_args_flags[cmd].flags, &default_commands_args[i].flags,
- max_args);
+ max_args * sizeof (unsigned long));
}
for (i = 0; small_block_associated_command[i][0]; i++)
@@ -2706,7 +2706,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
{
fprintf (stderr, "IGNORED %s\n", command_type.text);
}
- return;
+ goto out;
}
/* Process text */
@@ -2748,7 +2748,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
ADD(text_result.text);
free (text_result.text);
- return;
+ goto out;
}
if (element->cmd
@@ -2939,6 +2939,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
for (arg_idx = 0; arg_idx < element->args.number; arg_idx++)
{
char *explanation;
+ unsigned long arg_flags = 0;
ELEMENT *arg = element->args.list[arg_idx];
HTML_ARG_FORMATTED *arg_formatted
= &args_formatted->args[arg_idx];
@@ -2951,7 +2952,6 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
{
continue;
}
- int arg_flags = 0;
if (arg_idx < MAX_COMMAND_ARGS_NR
/* could check command_args_flags[cmd].status,
but it is probably faster not to */
@@ -3044,41 +3044,47 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
}
if (arg_flags & F_AFT_monospacetext)
{
- /*
- $arg_formatted->{$arg_type}
- = Texinfo::Convert::Text::convert_to_text($arg,
- {'code' => 1,
-
Texinfo::Convert::Text::copy_options_for_convert_text($self)});
- */
+ char *text;
+ TEXT_OPTIONS *text_conv_options
+ = copy_options_for_convert_text (self, 0);
+ text_conv_options->code_state = 1;
+
+ text = convert_to_text (arg, text_conv_options);
+
+ free (text_conv_options);
+
arg_formatted->formatted[AFT_type_monospacetext]
- = strdup ("");
+ = text;
}
if (arg_flags & F_AFT_filenametext)
{
- /*
- # Always use encoded characters for file names
- $arg_formatted->{$arg_type}
- = Texinfo::Convert::Text::convert_to_text($arg,
- {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self,
1)});
- */
- arg_formatted->formatted[AFT_type_filenametext]
- = strdup ("");
+ char *text;
+ /* Always use encoded characters for file names */
+ TEXT_OPTIONS *text_conv_options
+ = copy_options_for_convert_text (self, 1);
+ text_conv_options->code_state = 1;
+
+ text = convert_to_text (arg, text_conv_options);
+
+ free (text_conv_options);
+
+ arg_formatted->formatted[AFT_type_filenametext] =
text;
}
if (arg_flags & F_AFT_url)
{
- /*
- # set the encoding to UTF-8 to always have a string that is
suitable
- # for percent encoding.
- my $text_conversion_options = {'code' => 1,
- Texinfo::Convert::Text::copy_options_for_convert_text($self,
1)};
- $text_conversion_options->{'enabled_encoding'} = 'utf-8';
- $arg_formatted->{$arg_type}
- = Texinfo::Convert::Text::convert_to_text($arg,
- $text_conversion_options);
- */
- arg_formatted->formatted[AFT_type_url]
- = strdup ("");
+ char *text;
+ /* set the encoding to UTF-8 to always have a string that is
suitable
+ for percent encoding. */
+ TEXT_OPTIONS *text_conv_options
+ = copy_options_for_convert_text (self, 1);
+ text_conv_options->code_state = 1;
+ text_conv_options->encoding = "utf-8";
+
+ text = convert_to_text (arg, text_conv_options);
+
+ free (text_conv_options);
+
+ arg_formatted->formatted[AFT_type_url] = text;
}
if (arg_flags & F_AFT_raw)
{
@@ -3094,7 +3100,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
top_document_ctx->raw_ctx--;
self->modified_state++;
arg_formatted->formatted[AFT_type_raw]
- = strdup (formatted_arg.text);
+ = strdup (formatted_arg.text);
}
}
free (formatted_arg.text);
@@ -3202,7 +3208,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
free (content_formatted.text);
- return;
+ goto out;
}
else
{
@@ -3213,7 +3219,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
self->current_root_command = 0;
self->modified_state++;
}
- return;
+ goto out;
}
if (builtin_command_data[data_cmd].flags & CF_root)
@@ -3345,7 +3351,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
ADD(type_result.text);
free (type_result.text);
- return;
+ goto out;
}
else if (element->contents.number > 0)
{
@@ -3372,7 +3378,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
if (self->conf->DEBUG > 0)
fprintf (stderr, "UNNAMED HOLDER => `%s'\n", content_formatted.text);
ADD(content_formatted.text);
- return;
+ goto out;
}
else
{
@@ -3381,16 +3387,24 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
if (self->types_conversion[0].status
&& self->types_conversion[0].status != FRS_status_ignored)
{
- /*
- return &{$self->{'types_conversion'}->{''}} ($self, $element);
- */
+ char *conversion_result
+ = type_conversion (self, 0, element, "");
+ if (conversion_result)
+ {
+ ADD(conversion_result);
+ free (conversion_result);
+ }
+ goto out;
}
else
- return;
+ goto out;
}
debug_str = print_element_debug (element, 0);
fprintf (stderr, "DEBUG: HERE!(%p:%s)\n", element, debug_str);
free (debug_str);
+
+ out:
+ free (command_type.text);
}
static char *
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 4140f2a64e..2d06695cba 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1983,7 +1983,6 @@ build_html_formatting_state (CONVERTER *converter)
*/
}
-
#undef STORE
return newRV_noinc ((SV *) hv);
diff --git a/tp/Texinfo/XS/main/convert_to_text.c
b/tp/Texinfo/XS/main/convert_to_text.c
index 1fb0dc0119..e3694f7d09 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -106,7 +106,7 @@ new_text_options (void)
TEXT_OPTIONS *options = malloc (sizeof (TEXT_OPTIONS));
memset (options, 0, sizeof (TEXT_OPTIONS));
options->expanded_formats = new_expanded_formats (0);
- options->number_sections = -1;
+ options->NUMBER_SECTIONS = -1;
memset (&options->include_directories, 0, sizeof (STRING_LIST));
return options;
}
@@ -130,6 +130,46 @@ destroy_text_options (TEXT_OPTIONS *text_options)
free (text_options);
}
+#define TEXT_INDICATOR_CONVERTER_OPTIONS \
+ tico_option_name(NUMBER_SECTIONS) \
+ tico_option_name(ASCII_GLYPH) \
+ tico_option_name(TEST)
+
+/* note that nothing is copied */
+TEXT_OPTIONS *
+copy_options_for_convert_text (CONVERTER *self,
+ int enable_encoding_if_not_ascii)
+{
+ TEXT_OPTIONS *options = new_text_options ();
+ int text_indicator_option;
+
+ if ((self->conf->ENABLE_ENCODING > 0
+ && self->conf->OUTPUT_ENCODING_NAME)
+ || (enable_encoding_if_not_ascii
+ && self->conf->OUTPUT_ENCODING_NAME
+ && strcmp (self->conf->OUTPUT_ENCODING_NAME, "us-ascii")))
+ {
+ options->encoding = self->conf->OUTPUT_ENCODING_NAME;
+ }
+
+ #define tico_option_name(name) \
+ text_indicator_option = self->conf->name; \
+ if (text_indicator_option > 0) { options->name = 1; } \
+ else if (text_indicator_option >= 0) { options->name = 0; }
+ TEXT_INDICATOR_CONVERTER_OPTIONS
+ #undef tico_option_name
+
+ free (options->expanded_formats);
+ options->expanded_formats = self->expanded_formats;
+
+ memcpy (&options->include_directories, &self->conf->INCLUDE_DIRECTORIES,
+ sizeof (STRING_LIST));
+
+ options->other_converter_options = self->conf;
+
+ return options;
+}
+
/* format an accent command and nested accents within as Text. */
char *
text_accents (ELEMENT *accent, char *encoding, int set_case)
@@ -183,7 +223,7 @@ brace_no_arg_command (ELEMENT *e, TEXT_OPTIONS *options)
}
}
- if (!(options->ascii_glyph)
+ if (!(options->ASCII_GLYPH)
|| !(unicode_character_brace_no_arg_commands[cmd].is_extra > 0))
{
char *brace_no_arg_unicode = unicode_brace_no_arg_command (cmd,
encoding);
@@ -482,7 +522,7 @@ convert_to_text_internal (ELEMENT *element, TEXT_OPTIONS
*text_options,
$options);
}
*/
- else if (text_options->test)
+ else if (text_options->TEST)
{
ADD("a sunny day");
return;
@@ -718,7 +758,7 @@ convert_to_text_internal (ELEMENT *element, TEXT_OPTIONS
*text_options,
char *heading
= text_heading (element, text.text,
text_options->other_converter_options,
- text_options->number_sections, 0);
+ text_options->NUMBER_SECTIONS, 0);
ADD(heading);
free (heading);
}
diff --git a/tp/Texinfo/XS/main/convert_to_text.h
b/tp/Texinfo/XS/main/convert_to_text.h
index 3c62f1fe71..9dc258863e 100644
--- a/tp/Texinfo/XS/main/convert_to_text.h
+++ b/tp/Texinfo/XS/main/convert_to_text.h
@@ -4,6 +4,7 @@
#include "options_types.h"
#include "tree_types.h"
+#include "utils.h"
typedef struct TEXT_OPTIONS {
int set_case; /* sc and lc */
@@ -11,10 +12,10 @@ typedef struct TEXT_OPTIONS {
int code_state; /* code */
int raw_state;
int sort_string;
- int ascii_glyph; /* ASCII_GLYPH */
- int test; /* TEST */
- int number_sections; /* NUMBER_SECTIONS */
- struct expanded_format *expanded_formats; /* expanded_formats_hash */
+ int ASCII_GLYPH;
+ int TEST;
+ int NUMBER_SECTIONS;
+ EXPANDED_FORMAT *expanded_formats;
STRING_LIST include_directories;
OPTIONS *other_converter_options; /* corresponds to converter passed
to convert_to_text text options */
@@ -26,5 +27,7 @@ typedef struct TEXT_OPTIONS {
char *convert_to_text (ELEMENT *root, TEXT_OPTIONS *text_options);
TEXT_OPTIONS *new_text_options (void);
void destroy_text_options (TEXT_OPTIONS *text_options);
+TEXT_OPTIONS *copy_options_for_convert_text (CONVERTER *self,
+ int enable_encoding_if_not_ascii);
#endif
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index 36ed271594..07c6391ad5 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -201,6 +201,38 @@ copy_sv_options (SV *sv_in)
return options;
}
+void
+get_expanded_formats (HV *hv, EXPANDED_FORMAT **expanded_formats)
+{
+ SV **expanded_formats_sv;
+
+ dTHX;
+
+ expanded_formats_sv = hv_fetch (hv, "expanded_formats",
+ strlen ("expanded_formats"), 0);
+ if (expanded_formats_sv)
+ {
+ int i;
+ SSize_t formats_nr;
+
+ if (!*expanded_formats)
+ *expanded_formats = new_expanded_formats (0);
+
+ AV *av = (AV *)SvRV (*expanded_formats_sv);
+
+ formats_nr = av_top_index (av) +1;
+ for (i = 0; i < formats_nr; i++)
+ {
+ SV** string_sv = av_fetch (av, i, 0);
+ if (string_sv)
+ {
+ char *string = SvPVbyte_nolen (*string_sv);
+ add_expanded_format (*expanded_formats, string);
+ }
+ }
+ }
+}
+
/* map hash reference of Convert::Text options to TEXT_OPTIONS */
/* TODO more to do */
TEXT_OPTIONS *
@@ -209,7 +241,6 @@ copy_sv_options_for_convert_text (SV *sv_in)
HV *hv_in;
SV **test_option_sv;
SV **include_directories_sv;
- SV **expanded_formats_sv;
SV **other_converter_options_sv;
SV **self_converter_options_sv;
SV **enabled_encoding_sv;
@@ -222,7 +253,7 @@ copy_sv_options_for_convert_text (SV *sv_in)
test_option_sv = hv_fetch (hv_in, "TEST", strlen ("TEST"), 0);
if (test_option_sv)
- text_options->test = SvIV (*test_option_sv);
+ text_options->TEST = SvIV (*test_option_sv);
sort_string_option_sv = hv_fetch (hv_in, "sort_string",
strlen ("sort_string"), 0);
@@ -240,26 +271,7 @@ copy_sv_options_for_convert_text (SV *sv_in)
add_svav_to_string_list (include_directories_sv,
&text_options->include_directories, 1);
- expanded_formats_sv = hv_fetch (hv_in, "expanded_formats",
- strlen ("expanded_formats"), 0);
- if (expanded_formats_sv)
- {
- int i;
- SSize_t formats_nr;
-
- AV *av = (AV *)SvRV (*expanded_formats_sv);
-
- formats_nr = av_top_index (av) +1;
- for (i = 0; i < formats_nr; i++)
- {
- SV** string_sv = av_fetch (av, i, 0);
- if (string_sv)
- {
- char *string = SvPVbyte_nolen (*string_sv);
- add_expanded_format (text_options->expanded_formats, string);
- }
- }
- }
+ get_expanded_formats (hv_in, &text_options->expanded_formats);
other_converter_options_sv = hv_fetch (hv_in, "other_converter_options",
strlen ("other_converter_options"),
0);
@@ -498,6 +510,8 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
set_translated_commands (converter, hv_in);
+ get_expanded_formats (hv_in, &converter->expanded_formats);
+
/* HTML specific */
html_converter_initialize (converter);
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index d79174f3f1..ced84acddd 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -106,7 +106,7 @@ const char *command_location_names[]
= {"before", "last", "preamble", "preamble_or_first"};
/* duplicated when creating a new expanded_formats */
-struct expanded_format expanded_formats[] = {
+EXPANDED_FORMAT expanded_formats[] = {
"html", 0,
"docbook", 0,
"plaintext", 0,
@@ -440,7 +440,7 @@ encode_string (char *input_string, char *encoding, int
*status,
}
void
-clear_expanded_formats (struct expanded_format *formats)
+clear_expanded_formats (EXPANDED_FORMAT *formats)
{
int i;
for (i = 0; i < sizeof (expanded_formats)/sizeof (*expanded_formats);
@@ -451,7 +451,7 @@ clear_expanded_formats (struct expanded_format *formats)
}
void
-add_expanded_format (struct expanded_format *formats, char *format)
+add_expanded_format (EXPANDED_FORMAT *formats, char *format)
{
int i;
for (i = 0; i < sizeof (expanded_formats)/sizeof (*expanded_formats);
@@ -469,10 +469,10 @@ add_expanded_format (struct expanded_format *formats,
char *format)
/* FORMAT is an optional argument, to set a format at the expanded_format
structure creation */
-struct expanded_format *
+EXPANDED_FORMAT *
new_expanded_formats (char *format)
{
- struct expanded_format *formats;
+ EXPANDED_FORMAT *formats;
formats = malloc (sizeof (expanded_formats));
memcpy (formats, expanded_formats, sizeof (expanded_formats));
@@ -484,7 +484,7 @@ new_expanded_formats (char *format)
}
int
-format_expanded_p (struct expanded_format *formats, char *format)
+format_expanded_p (EXPANDED_FORMAT *formats, char *format)
{
int i;
for (i = 0; i < sizeof (expanded_formats)/sizeof (*expanded_formats);
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 4af980ca5a..647d0af50d 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -78,10 +78,10 @@ typedef struct {
extern ENCODING_CONVERSION_LIST output_conversions;
extern ENCODING_CONVERSION_LIST input_conversions;
-struct expanded_format {
+typedef struct expanded_format {
char *format;
int expandedp;
-};
+} EXPANDED_FORMAT;
typedef struct GLOBAL_INFO {
char *input_file_name;
@@ -420,6 +420,7 @@ typedef struct CONVERTER {
MERGED_INDEX **index_entries;
INDEX_SORTED_BY_LETTER **index_entries_by_letter;
TRANSLATED_COMMAND **translated_commands;
+ EXPANDED_FORMAT *expanded_formats;
/* output unit files API */
FILE_NAME_PATH_COUNTER_LIST *output_unit_files;
@@ -604,10 +605,10 @@ char *decode_string (char *input_string, char *encoding,
int *status,
char *encode_string (char *input_string, char *encoding, int *status,
SOURCE_INFO *source_info);
-struct expanded_format *new_expanded_formats (char *format);
-void clear_expanded_formats (struct expanded_format *formats);
-void add_expanded_format (struct expanded_format *formats, char *format);
-int format_expanded_p (struct expanded_format *formats, char *format);
+EXPANDED_FORMAT *new_expanded_formats (char *format);
+void clear_expanded_formats (EXPANDED_FORMAT *formats);
+void add_expanded_format (EXPANDED_FORMAT *formats, char *format);
+int format_expanded_p (EXPANDED_FORMAT *formats, char *format);
ELEMENT *trim_spaces_comment_from_content (ELEMENT *element);
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 69f26c6b24..0b43813555 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -974,7 +974,7 @@ funexit:
return current;
}
-struct expanded_format parser_expanded_formats[] = {
+EXPANDED_FORMAT parser_expanded_formats[] = {
"html", 0,
"docbook", 0,
"plaintext", 1,
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index ea542f0107..2b1120d00a 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -2623,7 +2623,7 @@ parse_texi (ELEMENT *root_elt, ELEMENT *current_elt)
{
ELEMENT *e;
int n;
-
+
if (check_line_directive (line))
continue;
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 29fdc521b9..6e367cfd0e 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1129,15 +1129,15 @@ sub test($$)
# and also to avoid having @inline* and raw output format @-commands
# with elided contents especially parsed because they are ignored
# and appearing as raw content in the tree in the output.
- my %expanded_formats_hash;
+ my %expanded_formats;
if ($parser_options->{'EXPANDED_FORMATS'}) {
foreach my $expanded_format (@{$parser_options->{'EXPANDED_FORMATS'}}) {
- $expanded_formats_hash{$expanded_format} = 1;
+ $expanded_formats{$expanded_format} = 1;
}
}
my $converted_text
= Texinfo::Convert::Text::convert_to_text($tree, {'TEST' => 1,
- 'expanded_formats_hash' => \%expanded_formats_hash});
+ 'expanded_formats' => \%expanded_formats});
my %converted;
my %converted_errors;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/DocBook.pm, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm, tp/Texinfo/Convert/TexinfoMarkup.pm, tp/Texinfo/Convert/Text.pm, tp/Texinfo/Convert/TextContent.pm, tp/t/test_utils.pl: rename expanded_formats_hash as expanded_formats.,
Patrice Dumas <=