[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Wed, 2 Oct 2024 06:20:11 -0400 (EDT) |
branch: master
commit 47caf7b2756ec60ab4535bf5dba7cfe0a704cd50
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Jul 31 10:51:45 2024 +0200
* tp/Texinfo/XS/convert/convert_html.c (html_format_setup): preset
unset default_no_arg_commands_formatting for string and preformatted
context for no arg commands only.
* tp/Texinfo/XS/main/converter_types.h (STYLE_COMMAND_CONTEXT_NR)
(NO_ARG_COMMAND_CONTEXT_NR): add STYLE_COMMAND_CONTEXT_NR and
NO_ARG_COMMAND_CONTEXT_NR macros. Use them everywhere to replace
previously used bounds. STYLE_COMMAND_CONTEXT_NR is set to get only
normal and preformatted contexts.
---
ChangeLog | 12 ++++++++
tp/Texinfo/XS/convert/build_html_perl_state.c | 5 ++--
tp/Texinfo/XS/convert/convert_html.c | 43 +++++++++++++++------------
tp/Texinfo/XS/convert/get_html_perl_info.c | 9 ++----
tp/Texinfo/XS/main/converter_types.h | 11 +++----
5 files changed, 47 insertions(+), 33 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dfc42fe92d..d823bfd817 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-07-31 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_format_setup): preset
+ unset default_no_arg_commands_formatting for string and preformatted
+ context for no arg commands only.
+
+ * tp/Texinfo/XS/main/converter_types.h (STYLE_COMMAND_CONTEXT_NR)
+ (NO_ARG_COMMAND_CONTEXT_NR): add STYLE_COMMAND_CONTEXT_NR and
+ NO_ARG_COMMAND_CONTEXT_NR macros. Use them everywhere to replace
+ previously used bounds. STYLE_COMMAND_CONTEXT_NR is set to get only
+ normal and preformatted contexts.
+
2024-07-31 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c (convert_style_command)
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c
b/tp/Texinfo/XS/convert/build_html_perl_state.c
index a5af96854d..0ca5754cb9 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -110,7 +110,7 @@ build_no_arg_commands_formatting (const CONVERTER
*converter)
hv_store (no_arg_commands_formatting_hv, command_name,
strlen (command_name), newRV_noinc ((SV *) context_hv), 0);
- for (cctx = 0; cctx < HCC_type_css_string+1; cctx++)
+ for (cctx = 0; cctx < NO_ARG_COMMAND_CONTEXT_NR; cctx++)
{
const HTML_NO_ARG_COMMAND_CONVERSION *no_arg_format
= &converter->html_no_arg_command_conversion[cmd][cctx];
@@ -608,7 +608,6 @@ build_html_translated_names (HV *hv, CONVERTER *converter)
/* 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 +1;
int j;
HV *no_arg_commands_formatting_hv;
FETCH(no_arg_commands_formatting);
@@ -624,7 +623,7 @@ build_html_translated_names (HV *hv, CONVERTER *converter)
= 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++)
+ for (k = 0; k < NO_ARG_COMMAND_CONTEXT_NR; k++)
{
HTML_NO_ARG_COMMAND_CONVERSION *no_arg_cmd_context
= &converter->html_no_arg_command_conversion[cmd][k];
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 30c2178322..66ec385bfd 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -200,7 +200,8 @@ CMD_VARIETY command_special_unit_variety[] = {
{0, 0},
};
-static HTML_NO_ARG_COMMAND_CONVERSION
default_no_arg_commands_formatting[BUILTIN_CMD_NUMBER][HCC_type_css_string+1];
+static HTML_NO_ARG_COMMAND_CONVERSION default_no_arg_commands_formatting
+ [BUILTIN_CMD_NUMBER][NO_ARG_COMMAND_CONTEXT_NR];
/* used to set flags to non-zero with a flag that does nothing */
#define F_AFT_none 0x0001
@@ -16831,6 +16832,7 @@ html_format_setup (void)
{
int i;
int no_arg_formatted_cmd_nr = 0;
+ int no_arg_formatted_cmd_idx;
int default_commands_args_nr
= sizeof (default_commands_args) / sizeof (default_commands_args[0]);
int max_args = MAX_COMMAND_ARGS_NR;
@@ -16958,15 +16960,7 @@ html_format_setup (void)
initialize_cmd_list (&no_arg_formatted_cmd, no_arg_formatted_cmd_nr,
no_arg_formatted_cmd_nr);
- for (i = 0; i < BUILTIN_CMD_NUMBER; i++)
- {
- enum conversion_context cctx;
- /* set unset for string and preformatted contexts */
- for (cctx = 1; cctx < HCC_type_css_string; cctx++)
- default_no_arg_commands_formatting[i][cctx].unset = 1;
- }
-
- no_arg_formatted_cmd_nr = 0;
+ no_arg_formatted_cmd_idx = 0;
for (i = 0; i < BUILTIN_CMD_NUMBER; i++)
{
if (xml_text_entity_no_arg_commands_formatting[i])
@@ -16976,10 +16970,19 @@ html_format_setup (void)
default_no_arg_commands_formatting[i][HCC_type_normal].text
= (char *)xml_text_entity_no_arg_commands_formatting[i];
- no_arg_formatted_cmd.list[no_arg_formatted_cmd_nr] = i;
- no_arg_formatted_cmd_nr++;
+ no_arg_formatted_cmd.list[no_arg_formatted_cmd_idx] = i;
+ no_arg_formatted_cmd_idx++;
+
+ /* preset unset for string and preformatted contexts */
+ /* css_string coverage is checked when setting css string context
+ values below and unset is set explicitely if needed */
+ default_no_arg_commands_formatting[i][HCC_type_string].unset = 1;
+ default_no_arg_commands_formatting[i][HCC_type_preformatted].unset =
1;
}
}
+ /* modify normal context values and add other contexts values, removing
+ unset. Should only be for commands with normal context already set.
+ */
default_no_arg_commands_formatting[CM_SPACE][HCC_type_normal].text =
" ";
default_no_arg_commands_formatting[CM_TAB][HCC_type_normal].text = " ";
default_no_arg_commands_formatting[CM_NEWLINE][HCC_type_normal].text =
" ";
@@ -17057,7 +17060,8 @@ html_format_setup (void)
"ul.mark-none", "list-style-type: none");
text_init (&css_string_text);
- /* setup default_css_element_class_styles for mark commands based on css
strings */
+ /* setup default_css_element_class_styles for mark commands based on
+ css strings */
for (i = 0; i < no_arg_formatted_cmd_nr; i++)
{
enum command_id cmd = no_arg_formatted_cmd.list[i];
@@ -18198,7 +18202,8 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
/* corresponds with default_no_arg_commands_formatting
+ conf_default_no_arg_commands_formatting_normal in Perl */
HTML_NO_ARG_COMMAND_CONVERSION
-
output_no_arg_commands_formatting[BUILTIN_CMD_NUMBER][HCC_type_css_string+1];
+ output_no_arg_commands_formatting[BUILTIN_CMD_NUMBER]
+ [NO_ARG_COMMAND_CONTEXT_NR];
output_encoding = self->conf->OUTPUT_ENCODING_NAME.o.string;
@@ -18313,7 +18318,7 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
{
enum command_id cmd = no_arg_formatted_cmd.list[i];
enum conversion_context cctx;
- for (cctx = 0; cctx < HCC_type_css_string+1; cctx++)
+ for (cctx = 0; cctx < NO_ARG_COMMAND_CONTEXT_NR; cctx++)
{
HTML_NO_ARG_COMMAND_CONVERSION *customized_no_arg_cmd
= self->customized_no_arg_commands_formatting[cmd][cctx];
@@ -19536,7 +19541,7 @@ html_free_converter (CONVERTER *self)
{
enum command_id cmd = no_arg_formatted_cmd.list[i];
enum conversion_context cctx;
- for (cctx = 0; cctx < HCC_type_css_string+1; cctx++)
+ for (cctx = 0; cctx < NO_ARG_COMMAND_CONTEXT_NR; cctx++)
{
HTML_NO_ARG_COMMAND_CONVERSION *format_spec
= &self->html_no_arg_command_conversion[cmd][cctx];
@@ -19548,7 +19553,7 @@ html_free_converter (CONVERTER *self)
{
enum command_id cmd = no_arg_formatted_cmd.list[i];
enum conversion_context cctx;
- for (cctx = 0; cctx < HCC_type_css_string+1; cctx++)
+ for (cctx = 0; cctx < NO_ARG_COMMAND_CONTEXT_NR; cctx++)
{
HTML_NO_ARG_COMMAND_CONVERSION *format_spec
= self->customized_no_arg_commands_formatting[cmd][cctx];
@@ -19573,7 +19578,7 @@ html_free_converter (CONVERTER *self)
{
enum command_id cmd = self->style_formatted_cmd.list[i];
enum conversion_context cctx;
- for (cctx = 0; cctx < HCC_type_css_string+1; cctx++)
+ for (cctx = 0; cctx < STYLE_COMMAND_CONTEXT_NR; cctx++)
{
HTML_STYLE_COMMAND_CONVERSION *format_spec
= &self->html_style_command_conversion[cmd][cctx];
@@ -19791,7 +19796,7 @@ html_translate_names (CONVERTER *self)
enum command_id cmd = no_arg_formatted_cmd.list[j];
enum conversion_context cctx;
int add_cmd = 0;
- for (cctx = 0; cctx < HCC_type_css_string+1; cctx++)
+ for (cctx = 0; cctx < NO_ARG_COMMAND_CONTEXT_NR; cctx++)
{
HTML_NO_ARG_COMMAND_CONVERSION *format_spec
= &self->html_no_arg_command_conversion[cmd][cctx];
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index b8115b2add..a365f74568 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -777,7 +777,6 @@ html_converter_initialize_sv (SV *converter_sv,
if (style_commands_formatting_sv)
{
- int max_context = HCC_type_string;
I32 hv_number;
I32 i;
@@ -817,7 +816,7 @@ html_converter_initialize_sv (SV *converter_sv,
int context_idx = -1;
SV *format_spec_sv = hv_iternextsv (context_hv,
&context_name, &retlen);
- for (k = 0; k < max_context +1; k++)
+ for (k = 0; k < STYLE_COMMAND_CONTEXT_NR; k++)
{
if (!strcmp (context_name,
html_conversion_context_type_names[k]))
@@ -875,7 +874,6 @@ html_converter_initialize_sv (SV *converter_sv,
FETCH(customized_no_arg_commands_formatting)
if (customized_no_arg_commands_formatting_sv)
{
- int max_context = HCC_type_css_string;
I32 hv_number;
I32 i;
HV *customized_no_arg_commands_formatting_hv
@@ -911,7 +909,7 @@ html_converter_initialize_sv (SV *converter_sv,
int context_idx = -1;
SV *format_spec_sv = hv_iternextsv (context_hv,
&context_name, &retlen);
- for (k = 0; k < max_context +1; k++)
+ for (k = 0; k < NO_ARG_COMMAND_CONTEXT_NR; k++)
{
if (!strcmp (context_name,
html_conversion_context_type_names[k]))
@@ -1281,7 +1279,6 @@ html_conversion_initialization_sv (SV *converter_sv,
CONVERTER *converter)
if (no_arg_commands_formatting_sv)
{
- int max_context = HCC_type_css_string;
I32 hv_number;
I32 i;
@@ -1317,7 +1314,7 @@ html_conversion_initialization_sv (SV *converter_sv,
CONVERTER *converter)
int context_idx = -1;
SV *format_spec_sv = hv_iternextsv (context_hv,
&context_name, &retlen);
- for (k = 0; k < max_context +1; k++)
+ for (k = 0; k < NO_ARG_COMMAND_CONTEXT_NR; k++)
{
if (!strcmp (context_name,
html_conversion_context_type_names[k]))
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index a320acd1b1..db0d55fab8 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -78,6 +78,9 @@ enum conversion_context {
#undef cctx_type
};
+#define STYLE_COMMAND_CONTEXT_NR HCC_type_preformatted +1
+#define NO_ARG_COMMAND_CONTEXT_NR HCC_type_css_string +1
+
enum special_target_type {
ST_footnote_location,
};
@@ -810,13 +813,11 @@ typedef struct CONVERTER {
HTML_DIRECTION_STRING_TRANSLATED
*translated_direction_strings[TDS_TRANSLATED_MAX_NR];
HTML_DIRECTION_STRING_TRANSLATED
**customized_translated_direction_strings[TDS_TRANSLATED_MAX_NR];
HTML_STAGE_HANDLER_INFO_LIST html_stage_handlers[HSHT_type_finish +1];
- HTML_NO_ARG_COMMAND_CONVERSION
*customized_no_arg_commands_formatting[BUILTIN_CMD_NUMBER][HCC_type_css_string+1];
+ HTML_NO_ARG_COMMAND_CONVERSION
*customized_no_arg_commands_formatting[BUILTIN_CMD_NUMBER][NO_ARG_COMMAND_CONTEXT_NR];
char ***customized_directions_strings[(TDS_TYPE_MAX_NR) -
(TDS_TRANSLATED_MAX_NR)];
+ HTML_STYLE_COMMAND_CONVERSION
html_style_command_conversion[BUILTIN_CMD_NUMBER][STYLE_COMMAND_CONTEXT_NR];
/* set for a converter, modified in a document */
- /* Only normal and preformatted HCC_type are actually used for
- style commands */
- HTML_STYLE_COMMAND_CONVERSION
html_style_command_conversion[BUILTIN_CMD_NUMBER][HCC_type_css_string+1];
- HTML_NO_ARG_COMMAND_CONVERSION
html_no_arg_command_conversion[BUILTIN_CMD_NUMBER][HCC_type_css_string+1];
+ HTML_NO_ARG_COMMAND_CONVERSION
html_no_arg_command_conversion[BUILTIN_CMD_NUMBER][NO_ARG_COMMAND_CONTEXT_NR];
char ***directions_strings[TDS_TYPE_MAX_NR];
const char **direction_unit_direction_name;