[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/utils.h (TRANSLATED_SUI_ASSO
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/utils.h (TRANSLATED_SUI_ASSOCIATION), tp/Texinfo/XS/convert/convert_html.c: move TRANSLATED_SUI_ASSOCIATION from convert_html.c to utils.h. |
Date: |
Sun, 29 Oct 2023 20:12:05 -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 92380a55c4 * tp/Texinfo/XS/main/utils.h (TRANSLATED_SUI_ASSOCIATION),
tp/Texinfo/XS/convert/convert_html.c: move TRANSLATED_SUI_ASSOCIATION from
convert_html.c to utils.h.
92380a55c4 is described below
commit 92380a55c430273f3f2e27b4644b2559cc8dbee5
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Oct 30 01:12:06 2023 +0100
* tp/Texinfo/XS/main/utils.h (TRANSLATED_SUI_ASSOCIATION),
tp/Texinfo/XS/convert/convert_html.c: move TRANSLATED_SUI_ASSOCIATION
from convert_html.c to utils.h.
* tp/Texinfo/XS/main/utils.c (special_unit_info_type_names)
(translated_special_unit_info), tp/Texinfo/XS/main/get_perl_info.c: move
special_unit_info_type_names and translated_special_unit_info from
get_perl_info.c to utils.c.
* tp/Texinfo/XS/convert/convert_html.c (html_pop_document_context):
free preformatted_classes.
* tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize),
tp/Texinfo/XS/main/get_perl_info.c (html_converter_initialize_sv):
call html_converter_initialize at the end of
html_converter_initialize_sv and move code initializing
global_units_directions to html_converter_initialize.
* tp/Texinfo/XS/convert/convert_html.c
(reset_unset_no_arg_commands_formatting_context): free and strdup
no_arg_command_context->text). Correctly set self->modified_state
with flags.
* tp/Texinfo/XS/main/converter_types.h (CONVERTER): have
no_arg_formatted_cmd directly in converter, not a pointer to it.
Update code referring to no_arg_formatted_cmd.
* tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize)
(html_translate_names), tp/Texinfo/XS/main/build_perl_info.c
(build_html_translated_names, build_html_formatting_state),
tp/Texinfo/XS/main/converter_types.h (CONVERTER): in
html_translate_names, collect information on commands that will need
to be reset or that are translated to pass to perl, and mark that
formatting state translations have to be set for perl. Reset perl
converter data and pass translated data in
build_html_translated_names.
* tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal):
call destroy_args_formatted to free args_formatted.
---
ChangeLog | 42 ++++++++++
tp/Texinfo/Convert/HTML.pm | 1 +
tp/Texinfo/XS/convert/convert_html.c | 86 +++++++++++++-------
tp/Texinfo/XS/main/build_perl_info.c | 149 +++++++++++++++++++++++++++++++++++
tp/Texinfo/XS/main/converter_types.h | 10 ++-
tp/Texinfo/XS/main/get_perl_info.c | 34 ++------
tp/Texinfo/XS/main/utils.c | 12 +++
tp/Texinfo/XS/main/utils.h | 9 +++
8 files changed, 285 insertions(+), 58 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3cafa9a9e1..a2925ffe81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,45 @@
+2023-10-29 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/utils.h (TRANSLATED_SUI_ASSOCIATION),
+ tp/Texinfo/XS/convert/convert_html.c: move TRANSLATED_SUI_ASSOCIATION
+ from convert_html.c to utils.h.
+
+ * tp/Texinfo/XS/main/utils.c (special_unit_info_type_names)
+ (translated_special_unit_info), tp/Texinfo/XS/main/get_perl_info.c: move
+ special_unit_info_type_names and translated_special_unit_info from
+ get_perl_info.c to utils.c.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_pop_document_context):
+ free preformatted_classes.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize),
+ tp/Texinfo/XS/main/get_perl_info.c (html_converter_initialize_sv):
+ call html_converter_initialize at the end of
+ html_converter_initialize_sv and move code initializing
+ global_units_directions to html_converter_initialize.
+
+ * tp/Texinfo/XS/convert/convert_html.c
+ (reset_unset_no_arg_commands_formatting_context): free and strdup
+ no_arg_command_context->text). Correctly set self->modified_state
+ with flags.
+
+ * tp/Texinfo/XS/main/converter_types.h (CONVERTER): have
+ no_arg_formatted_cmd directly in converter, not a pointer to it.
+ Update code referring to no_arg_formatted_cmd.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize)
+ (html_translate_names), tp/Texinfo/XS/main/build_perl_info.c
+ (build_html_translated_names, build_html_formatting_state),
+ tp/Texinfo/XS/main/converter_types.h (CONVERTER): in
+ html_translate_names, collect information on commands that will need
+ to be reset or that are translated to pass to perl, and mark that
+ formatting state translations have to be set for perl. Reset perl
+ converter data and pass translated data in
+ build_html_translated_names.
+
+ * tp/Texinfo/XS/convert/convert_html.c (convert_to_html_internal):
+ call destroy_args_formatted to free args_formatted.
+
2023-10-29 Gavin Smith <gavinsmith0123@gmail.com>
* po_document/no.po, po_document/nb.po:
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 17e42108f8..741ca55d96 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -8420,6 +8420,7 @@ sub converter_initialize($)
if ($self->{'document_descriptor'}) {
my $encoded_converter = $self->encode_converter_document();
+ #print STDERR "AAA ".\%default_formatting_references."
".\%default_css_string_formatting_references." ".\%default_commands_open." ".
\%default_commands_conversion." ".\%default_types_open."
".\%default_types_conversion." ".\%default_output_units_conversion."\n";
_XS_converter_initialize($encoded_converter,
\%default_formatting_references,
\%default_css_string_formatting_references,
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 961c4cd05c..afb38de3ea 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -239,16 +239,6 @@ html_get_tree_root_element (CONVERTER *self, ELEMENT
*command,
}
}
-typedef struct TRANSLATED_SUI_ASSOCIATION {
- int tree_type;
- int string_type;
-} TRANSLATED_SUI_ASSOCIATION;
-
-static TRANSLATED_SUI_ASSOCIATION translated_special_unit_info[] = {
- {SUIT_type_heading, SUI_type_heading},
- {-1, -1},
-};
-
HTML_TARGET *
find_element_target (HTML_TARGET_LIST *targets, ELEMENT *element)
{
@@ -2161,6 +2151,7 @@ html_pop_document_context (CONVERTER *self)
free (document_ctx->context);
free (document_ctx->monospace.stack);
free (document_ctx->composition_context.stack);
+ free (document_ctx->preformatted_classes.stack);
if (document_ctx->block_commands.top > 0)
pop_command (&document_ctx->block_commands);
free (document_ctx->block_commands.stack);
@@ -2178,14 +2169,20 @@ html_pop_document_context (CONVERTER *self)
/* most of the initialization is done by html_converter_initialize_sv
in get_perl_info, the initialization that do not require information
- from perl is done here */
+ from perl is done here. This is called after information from perl
+ has been gathered */
void
html_converter_initialize (CONVERTER *self)
{
int i;
+ int nr_special_units;
int nr_default_commands
= sizeof (default_commands_args) / sizeof (default_commands_args[0]);
int max_args = MAX_COMMAND_ARGS_NR;
+
+ /* first set information thta is fully independent from information
+ coming from perl */
+
for (i = 0; i < nr_default_commands; i++)
{
/* we file the status for specified commands, to distinguish them
@@ -2244,6 +2241,27 @@ html_converter_initialize (CONVERTER *self)
html_commands_data[CM_sc].flags |= HF_upper_case;
html_new_document_context (self, "_toplevel_context", 0, 0);
+
+ /* initialization needing some information from perl */
+
+ nr_special_units = self->special_unit_varieties->number;
+
+ self->global_units_directions
+ = (OUTPUT_UNIT **) malloc ((D_Last + nr_special_units+1)
+ * sizeof (OUTPUT_UNIT));
+ memset (self->global_units_directions, 0,
+ (D_Last + nr_special_units+1) * sizeof (OUTPUT_UNIT));
+
+ /* note that we allocate the same size as no_arg_formatted_cmd
+ even though in general there are much less translated commands,
+ for simplicity */
+ if (self->no_arg_formatted_cmd.number)
+ {
+ self->no_arg_formatted_cmd_translated.list = (enum command_id *)
+ malloc (self->no_arg_formatted_cmd.number * sizeof (enum command_id));
+ memset (self->no_arg_formatted_cmd_translated.list, 0,
+ self->no_arg_formatted_cmd.number * sizeof (enum command_id));
+ }
}
void
@@ -2364,7 +2382,10 @@ reset_unset_no_arg_commands_formatting_context
(CONVERTER *self,
/* TODO memory leaks possible for the other char * fields */
if (no_arg_ref->text)
- no_arg_command_context->text = no_arg_ref->text;
+ {
+ free (no_arg_command_context->text);
+ no_arg_command_context->text = strdup (no_arg_ref->text);
+ }
if (no_arg_ref->tree)
no_arg_command_context->tree = no_arg_ref->tree;
if (no_arg_ref->translated_converted)
@@ -2417,7 +2438,7 @@ reset_unset_no_arg_commands_formatting_context (CONVERTER
*self,
/* should not be needed for at commands no brace translation strings */
push_string_stack_string (&top_document_ctx->preformatted_classes,
html_commands_data[preformated_cmd].pre_class);
- self->modified_state++;
+ self->modified_state |= HMSF_document_context;
xasprintf (&explanation, "no arg %s translated",
builtin_command_data[cmd].cmdname);
@@ -2427,7 +2448,7 @@ reset_unset_no_arg_commands_formatting_context (CONVERTER
*self,
pop_command_or_type (&top_document_ctx->composition_context);
pop_string_stack (&top_document_ctx->preformatted_classes);
html_pop_document_context (self);
- self->modified_state++;
+ self->modified_state |= HMSF_document_context;
}
else if (reset_context == HCC_type_string)
{
@@ -2441,12 +2462,12 @@ reset_unset_no_arg_commands_formatting_context
(CONVERTER *self,
top_document_ctx = top_document_context (self);
top_document_ctx->string_ctx++;
- self->modified_state++;
+ self->modified_state |= HMSF_document_context;
translation_result = convert_tree (self, translated_tree,
context_name);
free (context_name);
html_pop_document_context (self);
- self->modified_state++;
+ self->modified_state |= HMSF_document_context;
}
else if (reset_context == HCC_type_css_string)
{
@@ -2481,6 +2502,7 @@ html_translate_names (CONVERTER *self)
{
int j;
STRING_LIST *special_unit_varieties = self->special_unit_varieties;
+
if (self->conf->DEBUG > 0)
{
fprintf (stderr, "\nTRANSLATE_NAMES encoding_name: "
@@ -2502,6 +2524,7 @@ html_translate_names (CONVERTER *self)
/* delete the tree and formatted results for special elements
such that they are redone with the new tree when needed. */
+ self->reset_target_commands.number = 0;
for (j = 0; j < special_unit_varieties->number; j++)
{
char *special_unit_variety = special_unit_varieties->list[j];
@@ -2523,25 +2546,29 @@ html_translate_names (CONVERTER *self)
target->tree = 0;
target->string = 0;
target->text = 0;
+ /* gather elements to pass information to perl */
+ add_to_element_list (&self->reset_target_commands,
+ command);
}
}
}
}
}
- if (self->no_arg_formatted_cmd)
+ /* self->no_arg_formatted_cmd_translated is used here to hold the translated
+ commands, and the information is kept as it is also used to pass
+ translated commands results to perl */
+ if (self->no_arg_formatted_cmd.number)
{
int translated_nr = 0;
- /* this is overkill, but simpler */
- enum command_id *translated_cmds = (enum command_id *)
- malloc ((self->no_arg_formatted_cmd->number +1)
- * sizeof (enum command_id));
- memset (translated_cmds, 0, (self->no_arg_formatted_cmd->number +1)
+ COMMAND_ID_LIST *translated_cmds =
&self->no_arg_formatted_cmd_translated;
+ if (translated_cmds->number)
+ memset (translated_cmds->list, 0, translated_cmds->number
* sizeof (enum command_id));
- for (j = 0; j < self->no_arg_formatted_cmd->number; j++)
+ for (j = 0; j < self->no_arg_formatted_cmd.number; j++)
{
- enum command_id cmd = self->no_arg_formatted_cmd->list[j];
+ enum command_id cmd = self->no_arg_formatted_cmd.list[j];
int i;
int add_cmd = 0;
for (i = 0; i < HCC_type_css_string+1; i++)
@@ -2578,22 +2605,23 @@ html_translate_names (CONVERTER *self)
}
if (add_cmd)
{
- translated_cmds[translated_nr] = cmd;
+ translated_cmds->list[translated_nr] = cmd;
translated_nr++;
}
}
+ translated_cmds->number = translated_nr;
for (j = 0; j < translated_nr; j++)
{
- enum command_id cmd = translated_cmds[j];
+ enum command_id cmd = translated_cmds->list[j];
complete_no_arg_commands_formatting (self, cmd, 1);
}
-
- free (translated_cmds);
}
if (self->conf->DEBUG > 0)
fprintf (stderr, "END TRANSLATE_NAMES\n\n");
+
+ self->modified_state |= HMSF_translations;
}
@@ -3184,6 +3212,8 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
else if (args_formatted)
fprintf (stderr, "No command_conversion for %s\n",
command_name);
+ if (args_formatted)
+ destroy_args_formatted (args_formatted);
if (cmd == CM_documentlanguage)
html_translate_names (self);
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 4a8ff6a678..7d6272198b 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1832,6 +1832,152 @@ build_out_filepaths (FILE_NAME_PATH_COUNTER_LIST
*output_unit_files)
return newRV_noinc ((SV *) hv);
}
+void
+build_html_translated_names (HV *hv, CONVERTER *converter)
+{
+ int j;
+ SV **directions_strings_sv;
+ HV *directions_strings_hv;
+ SV **special_unit_info_sv;
+ HV *special_unit_info_hv;
+ SV **targets_sv;
+ SV **no_arg_commands_formatting_sv;
+ HV *direction_string_hv;
+
+ dTHX;
+
+ /* reset with empty hash */
+#define FETCH(key) key##_sv = hv_fetch (hv, #key, strlen (#key), 0);
+ FETCH(directions_strings);
+ directions_strings_hv = (HV *) SvRV (*directions_strings_sv);
+#define tds_type(name) \
+ direction_string_hv = newHV (); \
+ hv_store (directions_strings_hv, #name, strlen (#name), \
+ newRV_noinc ((SV *) direction_string_hv), 0);
+ TDS_TRANSLATED_TYPES_LIST
+#undef tds_type
+
+ FETCH(special_unit_info);
+ special_unit_info_hv = (HV *) SvRV (*special_unit_info_sv);
+
+ /* reset with empty hash */
+ for (j = 0; translated_special_unit_info[j].tree_type >= 0; j++)
+ {
+ int tree_type = translated_special_unit_info[j].string_type;
+ const char *type_name = special_unit_info_type_names[tree_type];
+ char *key;
+ HV *special_unit_hv = newHV ();
+ xasprintf (&key, "%s_tree", type_name);
+ hv_store (special_unit_info_hv, key, strlen (key),
+ newRV_noinc ((SV *) special_unit_hv), 0);
+ free (key);
+ }
+
+ /* remove some info that will be redone on demand */
+ if (converter->reset_target_commands.number > 0)
+ {
+ int j;
+ HV *targets_hv;
+ FETCH(targets);
+ targets_hv = (HV *) SvRV (*targets_sv);
+
+ for (j = 0; j < converter->reset_target_commands.number; j++)
+ {
+ ELEMENT *command = converter->reset_target_commands.list[j];
+ SV *command_sv = newRV_noinc ((SV *) command->hv);
+ HE *target_he = hv_fetch_ent (targets_hv, command_sv, 0, 0);
+ if (!target_he)
+ {
+ char *element_str = print_element_debug (command, 0);
+ fprintf (stderr, "BUG: cannot retrieve target %d %s\n",
+ j, element_str);
+ free (element_str);
+ }
+ else
+ {
+ SV *target_sv = HeVAL (target_he);
+ HV *target_hv = (HV *) SvRV (target_sv);
+ if (hv_exists (target_hv, "text", strlen ("text")))
+ hv_delete (target_hv, "text", strlen ("text"), G_DISCARD);
+ if (hv_exists (target_hv, "string", strlen ("string")))
+ hv_delete (target_hv, "string", strlen ("string"), G_DISCARD);
+ if (hv_exists (target_hv, "tree", strlen ("tree")))
+ hv_delete (target_hv, "tree", strlen ("tree"), G_DISCARD);
+ }
+ }
+ converter->reset_target_commands.number = 0;
+ }
+
+ /* pass all the information for each context for translated commands */
+ if (converter->no_arg_formatted_cmd_translated.number)
+ {
+ int max_context = HCC_type_css_string;
+ int j;
+ HV *no_arg_commands_formatting_hv;
+ FETCH(no_arg_commands_formatting);
+ no_arg_commands_formatting_hv
+ = (HV *) SvRV (*no_arg_commands_formatting_sv);
+ for (j = 0; j < converter->no_arg_formatted_cmd_translated.number; j++)
+ {
+ int k;
+ enum command_id cmd
+ = converter->no_arg_formatted_cmd_translated.list[j];
+ HTML_COMMAND_CONVERSION **conversion_contexts
+ = converter->html_command_conversion[cmd];
+ char *cmdname = builtin_command_data[cmd].cmdname;
+ SV **no_arg_command_sv
+ = hv_fetch (no_arg_commands_formatting_hv,
+ cmdname, strlen (cmdname), 0);
+ HV *no_arg_command_hv = (HV *) SvRV (*no_arg_command_sv);
+ for (k = 0; k < max_context; k++)
+ {
+ if (conversion_contexts[k])
+ {
+ HTML_COMMAND_CONVERSION *no_arg_cmd_context
+ = conversion_contexts[k];
+
+ char *context_name = html_conversion_context_type_names[k];
+ SV **context_sv = hv_fetch (no_arg_command_hv,
+ context_name, strlen (context_name), 0);
+ HV *context_hv = (HV *) SvRV (*context_sv);
+
+ #define REPLACE_STR(key) \
+ if (no_arg_cmd_context->key) \
+ { \
+ hv_store (context_hv, #key, strlen (#key), \
+ newSVpv_utf8 (no_arg_cmd_context->key, 0), 0);
\
+ } \
+ else if (hv_exists (context_hv, #key, strlen (#key))) \
+ hv_delete (context_hv, #key, strlen (#key), G_DISCARD);
+
+ REPLACE_STR(text)
+ REPLACE_STR(translated_converted)
+ REPLACE_STR(translated_to_convert)
+ #undef REPLACE_STR
+
+ if (no_arg_cmd_context->tree)
+ {
+ if (!no_arg_cmd_context->tree->hv)
+ element_to_perl_hash (no_arg_cmd_context->tree);
+ hv_store (context_hv, "tree", strlen ("tree"),
+ newRV_inc ((SV *) no_arg_cmd_context->tree->hv),
0);
+ }
+ else if (hv_exists (context_hv, "tree", strlen ("tree")))
+ hv_delete (context_hv, "tree", strlen ("tree"), G_DISCARD);
+ }
+ }
+ }
+
+ memset (converter->no_arg_formatted_cmd_translated.list, 0,
+ converter->no_arg_formatted_cmd_translated.number
+ * sizeof (enum command_id));
+ converter->no_arg_formatted_cmd_translated.number = 0;
+ }
+
+#undef FETCH
+
+}
+
void
build_html_formatting_context_ctx (HV *hv,
HTML_FORMATTING_CONTEXT *formatting_context)
@@ -2232,6 +2378,9 @@ build_html_formatting_state (CONVERTER *converter,
unsigned long flags)
#undef STORE
+ if (flags & HMSF_translations)
+ build_html_translated_names (hv, converter);
+
return newRV_noinc ((SV *) hv);
}
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index f12c37b2e8..447be5e5b5 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -147,13 +147,13 @@ typedef struct {
typedef struct {
COMMAND_OR_TYPE *stack;
- size_t top; /* One above last pushed command. */
+ size_t top; /* One above last pushed. */
size_t space;
} COMMAND_OR_TYPE_STACK;
typedef struct {
char **stack;
- size_t top; /* One above last pushed command. */
+ size_t top; /* One above last pushed. */
size_t space;
} STRING_STACK;
@@ -378,7 +378,7 @@ typedef struct CONVERTER {
HTML_TARGET_LIST *html_special_targets[ST_footnote_location+1];
char **directions_strings[TDS_type_rel+1];
HTML_COMMAND_CONVERSION **html_command_conversion[BUILTIN_CMD_NUMBER];
- COMMAND_ID_LIST *no_arg_formatted_cmd;
+ COMMAND_ID_LIST no_arg_formatted_cmd;
int code_types[ET_special_unit_element+1];
char *pre_class_types[ET_special_unit_element+1];
FORMATTING_REFERENCE
@@ -395,6 +395,10 @@ typedef struct CONVERTER {
unsigned long modified_state; /* to determine if perl data should be
rebuilt */
ELEMENT *tree_to_build; /* C tree that needs to be built to perl before
calling perl functions on it */
+ COMMAND_ID_LIST no_arg_formatted_cmd_translated; /* list of commands that
were
+ translated that need to be passed back to perl
*/
+ ELEMENT_LIST reset_target_commands; /* element targets that should have
their texts
+ reset after language change */
/* state common with perl converter */
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index 07c6391ad5..73b1e7e950 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -325,14 +325,6 @@ get_sv_converter (SV *sv_in, char *warn_string)
return converter;
}
-static char *special_unit_info_type_names[SUI_type_heading + 1] =
-{
- /* #define sui_type(name) [SUI_type_ ## name] = #name, */
- #define sui_type(name) #name,
- SUI_TYPES_LIST
- #undef sui_type
-};
-
int
compare_ints (const void *a, const void *b)
{
@@ -480,7 +472,6 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
CONVERTER *converter = new_converter ();
int converter_descriptor = 0;
DOCUMENT *document;
- int nr_special_units = 0;
dTHX;
@@ -514,8 +505,6 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
/* HTML specific */
- html_converter_initialize (converter);
-
FETCH(formatting_function);
/* no need to check if it exists */
@@ -663,8 +652,6 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
add_svav_to_string_list (sorted_special_unit_varieties_sv,
special_unit_varieties, 0);
- nr_special_units = special_unit_varieties->number;
-
/* allocate space for translated tree types, but do not
get from perl, it will be created for the conversion */
for (j = 0; j < SUIT_type_heading+1; j++)
@@ -685,7 +672,7 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
for (j = 0; j < SUI_type_heading+1; j++)
{
SV **special_unit_info_type_sv;
- char *sui_type = special_unit_info_type_names[j];
+ const char *sui_type = special_unit_info_type_names[j];
special_unit_info_type_sv = hv_fetch (special_unit_info_hv,
sui_type, strlen (sui_type),
0);
if (special_unit_info_type_sv)
@@ -746,12 +733,6 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
converter->varieties_direction_index[j] = 0;
}
- converter->global_units_directions
- = (OUTPUT_UNIT **) malloc ((D_Last + nr_special_units+1)
- * sizeof (OUTPUT_UNIT));
- memset (converter->global_units_directions, 0,
- (D_Last + nr_special_units+1) * sizeof (OUTPUT_UNIT));
-
FETCH(code_types)
if (code_types_sv)
@@ -843,7 +824,6 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
}
-
FETCH(no_arg_commands_formatting)
if (no_arg_commands_formatting_sv)
@@ -857,11 +837,9 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
hv_number = hv_iterinit (no_arg_commands_formatting_hv);
- converter->no_arg_formatted_cmd = (COMMAND_ID_LIST *)
- malloc (sizeof (COMMAND_ID_LIST));
- converter->no_arg_formatted_cmd->list = (enum command_id *)
+ converter->no_arg_formatted_cmd.list = (enum command_id *)
malloc (hv_number * sizeof (enum command_id));
- converter->no_arg_formatted_cmd->number = hv_number;
+ converter->no_arg_formatted_cmd.number = hv_number;
for (i = 0; i < hv_number; i++)
{
@@ -874,7 +852,7 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
HV *context_hv = (HV *)SvRV (context_sv);
enum command_id cmd = lookup_builtin_command (cmdname);
- converter->no_arg_formatted_cmd->list[i] = cmd;
+ converter->no_arg_formatted_cmd.list[i] = cmd;
if (!cmd)
fprintf (stderr, "ERROR: %s: no no arg command\n", cmdname);
@@ -971,7 +949,7 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
}
}
}
- qsort (converter->no_arg_formatted_cmd->list, hv_number,
+ qsort (converter->no_arg_formatted_cmd.list, hv_number,
sizeof (enum command_id), compare_ints);
}
@@ -1076,6 +1054,8 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
#undef FETCH
+ html_converter_initialize (converter);
+
converter_descriptor = register_converter (converter);
/* a fresh converter, registered */
converter = retrieve_converter (converter_descriptor);
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index fc4a4f4a42..5b462bf921 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -98,6 +98,18 @@ const char *html_argument_formatting_type_names[] = {
#undef html_aft_type
};
+const char *special_unit_info_type_names[SUI_type_heading + 1] =
+{
+ #define sui_type(name) #name,
+ SUI_TYPES_LIST
+ #undef sui_type
+};
+
+TRANSLATED_SUI_ASSOCIATION translated_special_unit_info[] = {
+ {SUIT_type_heading, SUI_type_heading},
+ {-1, -1},
+};
+
ENCODING_CONVERSION_LIST output_conversions = {0, 0, 0, -1};
ENCODING_CONVERSION_LIST input_conversions = {0, 0, 0, 1};
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index aef863fb44..2e74f009c5 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -165,10 +165,19 @@ enum conversion_context {
#define HMSF_current_filename 0x0800
#define HMSF_converter_state 0x1000
#define HMSF_multiple_pass 0x2000
+#define HMSF_translations 0x4000
/* down here because it requires error data from before */
#include "document.h"
+typedef struct TRANSLATED_SUI_ASSOCIATION {
+ int tree_type;
+ int string_type;
+} TRANSLATED_SUI_ASSOCIATION;
+
+extern TRANSLATED_SUI_ASSOCIATION translated_special_unit_info[];
+extern const char *special_unit_info_type_names[SUI_type_heading + 1];
+
typedef struct TARGET_FILENAME {
char *target;
char *filename;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/utils.h (TRANSLATED_SUI_ASSOCIATION), tp/Texinfo/XS/convert/convert_html.c: move TRANSLATED_SUI_ASSOCIATION from convert_html.c to utils.h.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/XS/Makefile.am (libtexinfo_la_SOURCES), tp/Texinfo/XS/main/converter_types.h: move definitions of types related to document and converter to a separate file, converter_types.h, to avoid issues with include order.
- Next by Date:
branch master updated: * tp/Texinfo/Convert/HTML.pm (_prepare_conversion_units, convert) (output): set contents and shortcontents early in convert and output, where other configurations options are set, and not in _prepare_conversion_units.
- Previous by thread:
branch master updated: * tp/Texinfo/XS/Makefile.am (libtexinfo_la_SOURCES), tp/Texinfo/XS/main/converter_types.h: move definitions of types related to document and converter to a separate file, converter_types.h, to avoid issues with include order.
- Next by thread:
branch master updated: * tp/Texinfo/Convert/HTML.pm (_prepare_conversion_units, convert) (output): set contents and shortcontents early in convert and output, where other configurations options are set, and not in _prepare_conversion_units.
- Index(es):