[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Thu, 3 Oct 2024 15:30:02 -0400 (EDT) |
branch: master
commit 0a4d89860d52f8536d6464d9388486feda123ab1
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Aug 7 18:40:48 2024 +0200
Add a C demonstration program that converts Texinfo to HTML
* tp/Texinfo/XS/Makefile.am (libtexinfo_la_SOURCES)
(libtexinfo_convert_la_SOURCES, libtexinfo_convert_la_CPPFLAGS)
(ConvertXS_la_SOURCES): move structuring_transfo/transformations.c to
libtexinfo and convert_html.c to libtexinfo-convert. Remove
StructuringTransfoXS_la_SOURCES.
* main/replace_perl_api_call.c,
convert/replace_perl_call_html_function.c: add functions to replace
Perl functions call API of main/call_perl_function.h,
main/api_to_perl.h and convert/call_html_perl_function.h by functions
that do not need Perl. The C implementations are noops, that are not
meant to be called, C code equivalent to the Perl code, which can be
called.
* tp/Texinfo/XS/convert/convert_html.c
(set_root_commands_targets_node_files): initialize called to 0.
* tp/Texinfo/XS/convert/convert_html.c (convert_output_unit): use
output_unit_conversion_function to get the final status of conversion
of output units, as should be.
* tp/Texinfo/XS/convert/convert_html.c (html_converter_customize):
initialize converter special_unit_body_formatting to 0.
* tp/Texinfo/XS/convert/convert_html.c (html_initialize_output_state)
(register_special_unit_body_formatting_function)
(html_converter_customize): allow customized_type_dir_strings,
special_unit_body and html_customized_style_commands to be unset if
there is no Perl customization.
* tp/Texinfo/XS/convert/convert_html.c (ignored_types)
(html_converter_customize): set FRS_status_ignored for ignored types.
* tp/Texinfo/XS/convert/convert_html.c (html_converter_customize): if
FORMAT_MENU is not menu, set conversion status to FRS_status_ignored
for menu and detailmenu if they are converted in C.
* tp/Texinfo/XS/convert/convert_html.c (html_translate_string)
(format_*, html_converter_customize): set conversion functions to C
functions if there was no information obtained from Perl, with status
remaining FRS_status_none.
* tp/Texinfo/XS/Makefile.am (noinst_PROGRAMS, teximakehtml_SOURCES)
(teximakehtml_CPPFLAGS, teximakehtml_LDFLAGS, teximakehtml_LDADD),
tp/Texinfo/XS/teximakehtml.c: add the teximakehtml program
demonstrating the use of the parser, structuring and HTML conversion
C code to parser and convert Texinfo to HTML. No customization at
all, the intent is to use the program as a demonstrator of how the C
code could be used separately from Perl.
---
ChangeLog | 54 +++
tp/TODO | 3 +-
tp/Texinfo/XS/Makefile.am | 18 +-
tp/Texinfo/XS/convert/convert_html.c | 237 +++++++++----
.../XS/convert/replace_perl_call_html_function.c | 371 +++++++++++++++++++++
tp/Texinfo/XS/main/replace_perl_api_call.c | 88 +++++
tp/Texinfo/XS/teximakehtml.c | 369 ++++++++++++++++++++
7 files changed, 1062 insertions(+), 78 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6dde7673ba..50a28ddf5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,60 @@
default case as was the case previously. See
https://lists.gnu.org/archive/html/bug-texinfo/2004-02/msg00021.html
+2024-08-07 Patrice Dumas <pertusus@free.fr>
+
+ Add a C demonstration program that converts Texinfo to HTML
+
+ * tp/Texinfo/XS/Makefile.am (libtexinfo_la_SOURCES)
+ (libtexinfo_convert_la_SOURCES, libtexinfo_convert_la_CPPFLAGS)
+ (ConvertXS_la_SOURCES): move structuring_transfo/transformations.c to
+ libtexinfo and convert_html.c to libtexinfo-convert. Remove
+ StructuringTransfoXS_la_SOURCES.
+
+ * main/replace_perl_api_call.c,
+ convert/replace_perl_call_html_function.c: add functions to replace
+ Perl functions call API of main/call_perl_function.h,
+ main/api_to_perl.h and convert/call_html_perl_function.h by functions
+ that do not need Perl. The C implementations are noops, that are not
+ meant to be called, C code equivalent to the Perl code, which can be
+ called.
+
+ * tp/Texinfo/XS/convert/convert_html.c
+ (set_root_commands_targets_node_files): initialize called to 0.
+
+ * tp/Texinfo/XS/convert/convert_html.c (convert_output_unit): use
+ output_unit_conversion_function to get the final status of conversion
+ of output units, as should be.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_converter_customize):
+ initialize converter special_unit_body_formatting to 0.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_initialize_output_state)
+ (register_special_unit_body_formatting_function)
+ (html_converter_customize): allow customized_type_dir_strings,
+ special_unit_body and html_customized_style_commands to be unset if
+ there is no Perl customization.
+
+ * tp/Texinfo/XS/convert/convert_html.c (ignored_types)
+ (html_converter_customize): set FRS_status_ignored for ignored types.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_converter_customize): if
+ FORMAT_MENU is not menu, set conversion status to FRS_status_ignored
+ for menu and detailmenu if they are converted in C.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_translate_string)
+ (format_*, html_converter_customize): set conversion functions to C
+ functions if there was no information obtained from Perl, with status
+ remaining FRS_status_none.
+
+ * tp/Texinfo/XS/Makefile.am (noinst_PROGRAMS, teximakehtml_SOURCES)
+ (teximakehtml_CPPFLAGS, teximakehtml_LDFLAGS, teximakehtml_LDADD),
+ tp/Texinfo/XS/teximakehtml.c: add the teximakehtml program
+ demonstrating the use of the parser, structuring and HTML conversion
+ C code to parser and convert Texinfo to HTML. No customization at
+ all, the intent is to use the program as a demonstrator of how the C
+ code could be used separately from Perl.
+
2024-08-07 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/document.c (initialize_document_options): add
diff --git a/tp/TODO b/tp/TODO
index 41ae1f2675..feab91561b 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -886,7 +886,8 @@ SUM: 98
Setting flags
-our_CFLAGS='-g -Wformat-security -Wstrict-prototypes -Wall -Wno-parentheses
-Wno-missing-braces'
+our_CFLAGS='-g -O0 -Wformat-security -Wstrict-prototypes -Wall
-Wno-parentheses -Wno-missing-braces'
+our_CFLAGS='-g -O0 -Wformat-security -Wstrict-prototypes -Wall
-Wno-parentheses -Wno-missing-braces -fstack-protector-all -Wstack-protector
-fno-omit-frame-pointer'
./configure "CFLAGS=$our_CFLAGS" "PERL_EXT_CFLAGS=$our_CFLAGS"
unset our_CFLAGS
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index b504ecc6a4..63f9742957 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -207,6 +207,8 @@ libtexinfo_la_SOURCES= \
parsetexi/source_marks.h \
structuring_transfo/structuring.c \
structuring_transfo/structuring.h \
+ structuring_transfo/transformations.c \
+ structuring_transfo/transformations.h \
main/api_to_perl.c \
main/api_to_perl.h \
main/call_perl_function.c \
@@ -442,9 +444,6 @@ nodist_StructuringTransfoXS_la_SOURCES = \
structuring_transfo/StructuringTransfoXS.c
CLEANFILES += \
structuring_transfo/StructuringTransfoXS.c
-StructuringTransfoXS_la_SOURCES = \
- structuring_transfo/transformations.c \
- structuring_transfo/transformations.h
EXTRA_DIST += structuring_transfo/StructuringTransfoXS.xs
@@ -497,3 +496,16 @@ ConvertXS_la_LIBADD = libtexinfoxs.la
libtexinfo-convert.la libtexinfo.la $(top_
ConvertXS_la_LDFLAGS = $(XSLIBS_LDFLAGS) $(LTLIBICONV) $(LTLIBUNISTRING)
+############################################### demonstrator of the API
+
+noinst_PROGRAMS = teximakehtml
+
+teximakehtml_SOURCES = teximakehtml.c \
+ main/replace_perl_api_call.c \
+ convert/replace_perl_call_html_function.c
+
+teximakehtml_CPPFLAGS = -I$(srcdir)/parsetexi -I$(srcdir)/convert
-I$(srcdir)/main -I$(srcdir)/structuring_transfo $(AM_CPPFLAGS)
$(GNULIB_CPPFLAGS)
+teximakehtml_LDFLAGS = $(XSLIBS_LDFLAGS)
+teximakehtml_LDADD = libtexinfo.la libtexinfo-convert.la
$(top_builddir)/gnulib/lib/libgnu.la
+
+
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 92ecda0dee..d8fcd43a3e 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -144,6 +144,17 @@ static enum command_id quoted_style_commands[] = {
CM_samp, 0
};
+static enum element_type ignored_types[] = {
+ ET_ignorable_spaces_after_command,
+ ET_postamble_after_end,
+ ET_preamble_before_beginning,
+ ET_preamble_before_setfilename,
+ ET_spaces_at_end,
+ ET_spaces_before_paragraph,
+ ET_spaces_after_close_brace, 0
+};
+
+
const char *count_elements_in_filename_type_names[] = {
"total", "remaining", "current"};
@@ -524,6 +535,7 @@ get_element_root_command_element (CONVERTER *self, const
ELEMENT *command)
/* this number should be safe to use even after targets list has been
reallocated */
+
size_t
find_element_target_number_linear (const HTML_TARGET_LIST *targets,
const ELEMENT *element)
@@ -631,6 +643,7 @@ html_translate_string (CONVERTER *self, const char *string,
it does not hurt to consider it possible */
if (formatting_reference->status
&& formatting_reference->status != FRS_status_ignored
+ && formatting_reference->status != FRS_status_none
/* this function may not be defined in Perl, thus this condition */
&& formatting_reference->sv_reference)
{
@@ -2229,7 +2242,7 @@ set_root_commands_targets_node_files (CONVERTER *self)
int i;
for (i = 0; i < label_targets->number; i++)
{
- int called;
+ int called = 0;
char *target;
char *node_filename;
char *user_node_filename;
@@ -2687,7 +2700,8 @@ format_protect_text (CONVERTER *self, const char *text,
TEXT *result)
{
FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_protect_text];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
(*self->current_format_protect_text) (text, result);
}
@@ -2718,7 +2732,8 @@ format_comment (CONVERTER *self, const char *text)
{
FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_comment];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
return html_default_format_comment (self, text);
}
@@ -6424,7 +6439,8 @@ format_separate_anchor (CONVERTER *self, const char *id,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_separate_anchor];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
html_default_format_separate_anchor (self, id, class, result);
}
@@ -6847,7 +6863,8 @@ format_contents (CONVERTER *self,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_contents];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
return html_default_format_contents (self, cmd, element, filename);
}
@@ -6867,7 +6884,8 @@ format_heading_text (CONVERTER *self, const enum
command_id cmd,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_heading_text];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
html_default_format_heading_text (self, cmd, classes, text,
level, id, element, target, result);
@@ -6938,7 +6956,8 @@ format_single_footnote (CONVERTER *self, const ELEMENT
*element,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_single_footnote];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
html_default_format_single_footnote (self, element, footid,
number_in_doc, footnote_location_href,
@@ -7014,7 +7033,8 @@ format_footnotes_sequence (CONVERTER *self, TEXT *result)
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_footnotes_sequence];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
html_default_format_footnotes_sequence (self, result);
}
@@ -7109,7 +7129,8 @@ format_footnotes_segment (CONVERTER *self, TEXT *result)
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_footnotes_segment];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
default_format_footnotes_segment (self, result);
}
@@ -7172,7 +7193,8 @@ format_program_string (CONVERTER *self, TEXT *result)
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_program_string];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
html_default_format_program_string (self, result);
}
@@ -7282,7 +7304,8 @@ format_end_file (CONVERTER *self, const char *filename,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_end_file];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
return html_default_format_end_file (self, filename, output_unit);
}
@@ -7429,7 +7452,8 @@ format_css_lines (CONVERTER *self, const char *filename,
TEXT *result)
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_css_lines];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
html_default_format_css_lines (self, filename, result);
}
@@ -7847,7 +7871,8 @@ format_begin_file (CONVERTER *self, const char *filename,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_begin_file];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
return html_default_format_begin_file (self, filename, output_unit);
}
@@ -7912,7 +7937,8 @@ format_button_icon_img (CONVERTER *self,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_button_icon_img];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
return html_default_format_button_icon_img (self, button_name,
icon, name);
@@ -8292,7 +8318,8 @@ format_button (CONVERTER *self,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_button];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
return html_default_format_button (self, button, element);
}
@@ -8443,7 +8470,8 @@ format_navigation_panel (CONVERTER *self,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_navigation_panel];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
html_default_format_navigation_panel (self, buttons, cmdname,
element, vertical, result);
@@ -8509,7 +8537,8 @@ format_navigation_header (CONVERTER *self,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_navigation_header];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
html_default_format_navigation_header (self, buttons, cmdname,
element, result);
@@ -8650,7 +8679,8 @@ format_element_header (CONVERTER *self,
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_element_header];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
html_default_format_element_header (self, cmdname, element,
output_unit, result);
@@ -8871,7 +8901,8 @@ format_element_footer (CONVERTER *self,
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_element_footer];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
html_default_format_element_footer (self, unit_type, output_unit,
content, element, result);
@@ -8995,13 +9026,15 @@ html_default_format_node_redirection_page (CONVERTER
*self,
}
/* return string to be freed by the caller */
-char *format_node_redirection_page (CONVERTER *self, const ELEMENT *element,
- const char *filename)
+char *
+format_node_redirection_page (CONVERTER *self, const ELEMENT *element,
+ const char *filename)
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_node_redirection_page];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
return html_default_format_node_redirection_page (self, element,
filename);
@@ -16204,7 +16237,8 @@ format_titlepage (CONVERTER *self)
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_titlepage];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
return html_default_format_titlepage (self);
}
@@ -16245,7 +16279,8 @@ format_title_titlepage (CONVERTER *self)
{
const FORMATTING_REFERENCE *formatting_reference
= &self->current_formatting_references[FR_format_title_titlepage];
- if (formatting_reference->status == FRS_status_default_set)
+ if (formatting_reference->status == FRS_status_default_set
+ || formatting_reference->status == FRS_status_none)
{
return html_default_format_title_titlepage (self);
}
@@ -17295,7 +17330,7 @@ register_special_unit_body_formatting_function
const char *special_unit_variety,
FORMATTING_REFERENCE *formatting_reference)
{
- if (formatting_reference->status > 0)
+ if (formatting_reference && formatting_reference->status > 0)
{
result->status = formatting_reference->status;
if (formatting_reference->status != FRS_status_ignored)
@@ -17638,32 +17673,35 @@ html_converter_customize (CONVERTER *self)
}
}
- for (i = 0; self->html_customized_style_commands[i].cmd; i++)
+ if (self->html_customized_style_commands)
{
- enum conversion_context cctx;
- enum command_id cmd = self->html_customized_style_commands[i].cmd;
- /* should not happen thans to checks in perl
- if (!(html_commands_data[cmd].flags & HF_style_command))
- fprintf (stderr, "ERROR: %s: customized as style command\n",
- builtin_command_name (cmd));
- */
-
- for (cctx = 0; cctx < STYLE_COMMAND_CONTEXT_NR; cctx++)
+ for (i = 0; self->html_customized_style_commands[i].cmd; i++)
{
- if (self->html_customized_style_commands[i].conversion[cctx])
+ enum conversion_context cctx;
+ enum command_id cmd = self->html_customized_style_commands[i].cmd;
+ /* should not happen thanks to checks in perl
+ if (!(html_commands_data[cmd].flags & HF_style_command))
+ fprintf (stderr, "ERROR: %s: customized as style command\n",
+ builtin_command_name (cmd));
+ */
+
+ for (cctx = 0; cctx < STYLE_COMMAND_CONTEXT_NR; cctx++)
{
- HTML_STYLE_COMMAND_CONVERSION *format_spec
- = &self->html_style_command_conversion[cmd][cctx];
- HTML_STYLE_COMMAND_CONVERSION *custom_spec
- = self->html_customized_style_commands[i].conversion[cctx];
+ if (self->html_customized_style_commands[i].conversion[cctx])
+ {
+ HTML_STYLE_COMMAND_CONVERSION *format_spec
+ = &self->html_style_command_conversion[cmd][cctx];
+ HTML_STYLE_COMMAND_CONVERSION *custom_spec
+ = self->html_customized_style_commands[i].conversion[cctx];
- free (format_spec->element);
+ free (format_spec->element);
- if (custom_spec->element)
- format_spec->element = strdup (custom_spec->element);
- else
- format_spec->element = 0;
- format_spec->quote = custom_spec->quote;
+ if (custom_spec->element)
+ format_spec->element = strdup (custom_spec->element);
+ else
+ format_spec->element = 0;
+ format_spec->quote = custom_spec->quote;
+ }
}
}
}
@@ -17780,6 +17818,12 @@ html_converter_customize (CONVERTER *self)
self->command_special_variety_name_index[i].index = number - 1;
}
+ for (i = 0; ignored_types[i]; i++)
+ {
+ enum element_type type = ignored_types[i];
+ self->type_conversion_function[type].status = FRS_status_ignored;
+ }
+
for (i = 0; i < TXI_TREE_TYPES_NUMBER; i++)
{
int status = register_type_conversion_function (
@@ -17822,13 +17866,21 @@ html_converter_customize (CONVERTER *self)
}
self->special_unit_body_formatting = (SPECIAL_UNIT_BODY_FORMATTING *)
- malloc (nr_special_units * sizeof (SPECIAL_UNIT_BODY_FORMATTING));
+ malloc (nr_special_units * sizeof (SPECIAL_UNIT_BODY_FORMATTING));
+ memset (self->special_unit_body_formatting, 0,
+ nr_special_units * sizeof (SPECIAL_UNIT_BODY_FORMATTING));
for (i = 0; i < nr_special_units; i++)
{
- int status = register_special_unit_body_formatting_function
+ int status;
+ FORMATTING_REFERENCE *formatting_reference = 0;
+ if (self->special_unit_body)
+ {
+ formatting_reference = &self->special_unit_body[i];
+ }
+ status = register_special_unit_body_formatting_function
(&self->special_unit_body_formatting[i],
- self->special_unit_varieties.list[i], &self->special_unit_body[i]);
+ self->special_unit_varieties.list[i], formatting_reference);
external_special_unit_body_formatting_function += status;
}
@@ -17867,13 +17919,15 @@ html_converter_customize (CONVERTER *self)
= &self->type_conversion_function[type];
TYPE_CONVERSION_FUNCTION *css_string_type_conversion
= &self->css_string_type_conversion_function[type];
- if (type_conversion->status == FRS_status_default_set)
+ if (type_conversion->status == FRS_status_default_set
+ || type_conversion->status == FRS_status_none)
{
type_conversion->formatting_reference = 0;
type_conversion->status = FRS_status_internal;
type_conversion->type_conversion
= types_internal_conversion_table[i].type_conversion;
- external_type_conversion_function--;
+ if (type_conversion->status == FRS_status_default_set)
+ external_type_conversion_function--;
}
css_string_type_conversion->formatting_reference = 0;
css_string_type_conversion->status = FRS_status_internal;
@@ -17889,13 +17943,15 @@ html_converter_customize (CONVERTER *self)
{
enum element_type type = types_internal_open_table[i].type;
TYPE_OPEN_FUNCTION *type_open = &self->type_open_function[type];
- if (type_open->status == FRS_status_default_set)
+ if (type_open->status == FRS_status_default_set
+ || type_open->status == FRS_status_none)
{
type_open->formatting_reference = 0;
type_open->status = FRS_status_internal;
type_open->type_open
= types_internal_open_table[i].type_open;
- external_type_open_function--;
+ if (type_open->status == FRS_status_default_set)
+ external_type_open_function--;
}
}
@@ -17906,13 +17962,15 @@ html_converter_customize (CONVERTER *self)
= &self->command_conversion_function[cmd];
COMMAND_CONVERSION_FUNCTION *css_string_command_conversion
= &self->css_string_command_conversion_function[cmd];
- if (command_conversion->status == FRS_status_default_set)
+ if (command_conversion->status == FRS_status_default_set
+ || command_conversion->status == FRS_status_none)
{
command_conversion->formatting_reference = 0;
command_conversion->status = FRS_status_internal;
command_conversion->command_conversion
= commands_internal_conversion_table[i].command_conversion;
- external_command_conversion_function--;
+ if (command_conversion->status == FRS_status_default_set)
+ external_command_conversion_function--;
}
css_string_command_conversion->formatting_reference = 0;
css_string_command_conversion->status = FRS_status_internal;
@@ -17920,6 +17978,20 @@ html_converter_customize (CONVERTER *self)
= commands_internal_conversion_table[i].command_conversion;
}
+ if (strcmp (self->conf->FORMAT_MENU.o.string, "menu"))
+ {
+ static enum command_id menu_cmd_list[]
+ = {CM_menu, CM_detailmenu, 0};
+ for (i = 0; menu_cmd_list[i]; i++)
+ {
+ enum command_id cmd = menu_cmd_list[i];
+ COMMAND_CONVERSION_FUNCTION *command_conversion
+ = &self->command_conversion_function[cmd];
+ if (command_conversion->status == FRS_status_internal)
+ command_conversion->status = FRS_status_ignored;
+ }
+ }
+
/* all the no arg formatted commands are implemented in C */
for (i = 0; i < no_arg_formatted_cmd.number; i++)
{
@@ -17928,13 +18000,15 @@ html_converter_customize (CONVERTER *self)
= &self->command_conversion_function[cmd];
COMMAND_CONVERSION_FUNCTION *css_string_command_conversion
= &self->css_string_command_conversion_function[cmd];
- if (command_conversion->status == FRS_status_default_set)
+ if (command_conversion->status == FRS_status_default_set
+ || command_conversion->status == FRS_status_none)
{
command_conversion->formatting_reference = 0;
command_conversion->status = FRS_status_internal;
command_conversion->command_conversion
= &convert_no_arg_command;
- external_command_conversion_function--;
+ if (command_conversion->status == FRS_status_default_set)
+ external_command_conversion_function--;
}
css_string_command_conversion->formatting_reference = 0;
@@ -17953,13 +18027,15 @@ html_converter_customize (CONVERTER *self)
= &self->command_conversion_function[cmd];
COMMAND_CONVERSION_FUNCTION *css_string_command_conversion
= &self->css_string_command_conversion_function[cmd];
- if (command_conversion->status == FRS_status_default_set)
+ if (command_conversion->status == FRS_status_default_set
+ || command_conversion->status == FRS_status_none)
{
command_conversion->formatting_reference = 0;
command_conversion->status = FRS_status_internal;
command_conversion->command_conversion
= &convert_accent_command;
- external_command_conversion_function--;
+ if (command_conversion->status == FRS_status_default_set)
+ external_command_conversion_function--;
}
css_string_command_conversion->formatting_reference = 0;
css_string_command_conversion->status = FRS_status_internal;
@@ -17981,13 +18057,15 @@ html_converter_customize (CONVERTER *self)
COMMAND_CONVERSION_FUNCTION *css_string_command_conversion
= &self->css_string_command_conversion_function[cmd];
- if (command_conversion->status == FRS_status_default_set)
+ if (command_conversion->status == FRS_status_default_set
+ || command_conversion->status == FRS_status_none)
{
command_conversion->formatting_reference = 0;
command_conversion->status = FRS_status_internal;
command_conversion->command_conversion
= &convert_style_command;
- external_command_conversion_function--;
+ if (command_conversion->status == FRS_status_default_set)
+ external_command_conversion_function--;
}
css_string_command_conversion->formatting_reference = 0;
@@ -18008,13 +18086,15 @@ html_converter_customize (CONVERTER *self)
COMMAND_CONVERSION_FUNCTION *css_string_command_conversion
= &self->css_string_command_conversion_function[cmd];
- if (command_conversion->status == FRS_status_default_set)
+ if (command_conversion->status == FRS_status_default_set
+ || command_conversion->status == FRS_status_none)
{
command_conversion->formatting_reference = 0;
command_conversion->status = FRS_status_internal;
command_conversion->command_conversion
= &convert_preformatted_command;
- external_command_conversion_function--;
+ if (command_conversion->status == FRS_status_default_set)
+ external_command_conversion_function--;
}
css_string_command_conversion->formatting_reference = 0;
@@ -18034,13 +18114,15 @@ html_converter_customize (CONVERTER *self)
COMMAND_CONVERSION_FUNCTION *css_string_command_conversion
= &self->css_string_command_conversion_function[cmd];
- if (command_conversion->status == FRS_status_default_set)
+ if (command_conversion->status == FRS_status_default_set
+ || command_conversion->status == FRS_status_none)
{
command_conversion->formatting_reference = 0;
command_conversion->status = FRS_status_internal;
command_conversion->command_conversion
= &convert_def_command;
- external_command_conversion_function--;
+ if (command_conversion->status == FRS_status_default_set)
+ external_command_conversion_function--;
}
css_string_command_conversion->formatting_reference = 0;
@@ -18054,13 +18136,15 @@ html_converter_customize (CONVERTER *self)
{
enum command_id cmd = commands_internal_open_table[i].cmd;
COMMAND_OPEN_FUNCTION *command_open = &self->command_open_function[cmd];
- if (command_open->status == FRS_status_default_set)
+ if (command_open->status == FRS_status_default_set
+ || command_open->status == FRS_status_none)
{
command_open->formatting_reference = 0;
command_open->status = FRS_status_internal;
command_open->command_open
= commands_internal_open_table[i].command_open;
- external_command_open_function--;
+ if (command_open->status == FRS_status_default_set)
+ external_command_open_function--;
}
}
@@ -18071,13 +18155,15 @@ html_converter_customize (CONVERTER *self)
= output_units_internal_conversion_table[i].type;
OUTPUT_UNIT_CONVERSION_FUNCTION *output_unit_conversion
= &self->output_unit_conversion_function[type];
- if (output_unit_conversion->status == FRS_status_default_set)
+ if (output_unit_conversion->status == FRS_status_default_set
+ || output_unit_conversion->status == FRS_status_none)
{
output_unit_conversion->formatting_reference = 0;
output_unit_conversion->status = FRS_status_internal;
output_unit_conversion->output_unit_conversion
= output_units_internal_conversion_table[i].output_unit_conversion;
- external_output_unit_conversion_function--;
+ if (output_unit_conversion->status == FRS_status_default_set)
+ external_output_unit_conversion_function--;
}
}
@@ -18094,13 +18180,15 @@ html_converter_customize (CONVERTER *self)
{
SPECIAL_UNIT_BODY_FORMATTING *body_formatting
= &self->special_unit_body_formatting[j];
- if (body_formatting->status == FRS_status_default_set)
+ if (body_formatting->status == FRS_status_default_set
+ || body_formatting->status == FRS_status_none)
{
body_formatting->formatting_reference = 0;
body_formatting->status = FRS_status_internal;
body_formatting->special_unit_body_formatting
= internal_conversion->special_unit_body_formatting;
- external_special_unit_body_formatting_function--;
+ if (body_formatting->status == FRS_status_default_set)
+ external_special_unit_body_formatting_function--;
}
}
}
@@ -18636,7 +18724,7 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
DS_type - (TDS_TRANSLATED_MAX_NR)];
for (i = 0; i < nr_string_directions; i++)
{
- if (customized_type_dir_strings[i])
+ if (customized_type_dir_strings && customized_type_dir_strings[i])
{
int j;
for (j = 0; j < nr_dir_str_contexts; j++)
@@ -21004,7 +21092,8 @@ convert_output_unit (CONVERTER *self, const OUTPUT_UNIT
*output_unit,
size_t input_result_end = result->end;
enum output_unit_type unit_type = output_unit->unit_type;
- if (self->output_units_conversion[unit_type].status == FRS_status_ignored)
+ if (self->output_unit_conversion_function[unit_type].status
+ == FRS_status_ignored)
{
if (self->conf->DEBUG.o.integer > 0)
{
@@ -21044,7 +21133,7 @@ convert_output_unit (CONVERTER *self, const OUTPUT_UNIT
*output_unit,
}
}
- if (self->output_units_conversion[unit_type].status)
+ if (self->output_unit_conversion_function[unit_type].status)
{
(*(self->output_unit_conversion_function[unit_type].output_unit_conversion))
(self, unit_type, output_unit,
diff --git a/tp/Texinfo/XS/convert/replace_perl_call_html_function.c
b/tp/Texinfo/XS/convert/replace_perl_call_html_function.c
new file mode 100644
index 0000000000..baaabe349e
--- /dev/null
+++ b/tp/Texinfo/XS/convert/replace_perl_call_html_function.c
@@ -0,0 +1,371 @@
+
+#include <config.h>
+
+#include "tree_types.h"
+#include "option_types.h"
+#include "converter_types.h"
+/* for TARGET_CONTENTS_FILENAME FILE_NAME_PATH
+ TARGET_DIRECTORY_FILENAME */
+#include "utils.h"
+#include "translations.h"
+#include "call_html_perl_function.h"
+
+TARGET_FILENAME *
+call_file_id_setting_special_unit_target_file_name
+ (CONVERTER *self,
+ const OUTPUT_UNIT *special_unit, const char *target,
+ const char *default_filename)
+{
+ return 0;
+}
+
+char *
+call_file_id_setting_label_target_name (CONVERTER *self,
+ const char *normalized, const ELEMENT *label_element,
+ const char *target, int *called)
+{
+ return 0;
+}
+
+char *
+call_file_id_setting_node_file_name (CONVERTER *self,
+ const ELEMENT *target_element, const char *node_filename,
+ int *called)
+{
+ return 0;
+}
+
+TARGET_CONTENTS_FILENAME *
+call_file_id_setting_sectioning_command_target_name
+ (CONVERTER *self,
+ const ELEMENT *command, const char *target,
+ const char *target_contents,
+ const char *target_shortcontents, const char *filename)
+{
+ return 0;
+}
+
+FILE_NAME_PATH *
+call_file_id_setting_unit_file_name (CONVERTER *self,
+ const OUTPUT_UNIT *output_unit,
+ const char *filename, const char *filepath)
+{
+ return 0;
+}
+
+TARGET_DIRECTORY_FILENAME *
+call_file_id_setting_external_target_split_name
+ (CONVERTER *self,
+ const char *normalized, const ELEMENT *element,
+ const char *target, const char *directory,
+ const char *file_name)
+{
+ return 0;
+}
+
+TARGET_FILENAME *
+call_file_id_setting_external_target_non_split_name
+ (CONVERTER *self,
+ const char *normalized, const ELEMENT *element,
+ const char *target, const char *file)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_comment (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *text)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_program_string (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_titlepage (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_title_titlepage (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_protect_text (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *text)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_footnotes_segment (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_single_footnote (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const ELEMENT *element, const char *footid,
+ int number_in_doc,
+ const char *footnote_location_href, const char *mark)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_footnotes_sequence (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_css_lines (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *filename)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_end_file (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *filename, const OUTPUT_UNIT *output_unit)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_begin_file (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *filename,
+ const OUTPUT_UNIT *output_unit)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_translate_message (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *message, const char *lang,
+ const char *message_context)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_button_icon_img (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *button_name,
+ const char *icon, const char *name)
+{
+ return 0;
+}
+
+FORMATTED_BUTTON_INFO *
+call_formatting_function_format_button (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const BUTTON_SPECIFICATION *button,
+ const ELEMENT *element)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_navigation_panel (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ BUTTON_SPECIFICATION_LIST *buttons,
+ const char *cmdname, const ELEMENT *element,
+ int vertical)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_navigation_header (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ BUTTON_SPECIFICATION_LIST *buttons,
+ const char *cmdname,
+ const ELEMENT *element)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_heading_text (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *cmdname,
+ const STRING_LIST *classes,
+ const char *text,
+ int level, const char *id,
+ const ELEMENT *element, const char *target)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_contents (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *cmdname, const ELEMENT *command,
+ const char *filename)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_separate_anchor (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *id, const char *class)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_element_header (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *cmdname, const ELEMENT *command,
+ const OUTPUT_UNIT *output_unit)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_element_footer (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const enum output_unit_type unit_type,
+ const OUTPUT_UNIT *output_unit,
+ const char *content, const ELEMENT *command)
+{
+ return 0;
+}
+
+char *
+call_formatting_function_format_node_redirection_page (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const ELEMENT *command, const char *filename)
+
+{
+ return 0;
+}
+
+void
+call_types_conversion (CONVERTER *self, const enum element_type type,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const ELEMENT *element, const char *content,
+ TEXT *result)
+{
+}
+
+void
+call_types_open (CONVERTER *self, const enum element_type type,
+ const ELEMENT *element, TEXT *result)
+{
+}
+
+void
+call_commands_conversion (CONVERTER *self, const enum command_id cmd,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const ELEMENT *element,
+ const HTML_ARGS_FORMATTED *args_formatted,
+ const char *content, TEXT *result)
+{
+}
+
+void
+call_commands_open (CONVERTER *self, const enum command_id cmd,
+ const ELEMENT *element, TEXT *result)
+{
+}
+
+void
+call_output_units_conversion (CONVERTER *self,
+ const enum output_unit_type unit_type,
+ const OUTPUT_UNIT *output_unit, const char *content,
+ TEXT *result)
+{
+}
+
+void
+call_special_unit_body_formatting (CONVERTER *self,
+ const size_t special_unit_number,
+ const char *special_unit_variety,
+ const OUTPUT_UNIT *output_unit,
+ TEXT *result)
+{
+}
+
+
+
+FORMATTED_BUTTON_INFO *
+call_button_simple_function (CONVERTER *self,
+ void *formatting_reference_sv)
+{
+ return 0;
+}
+
+FORMATTED_BUTTON_INFO *
+call_button_direction_function (CONVERTER *self,
+ void *formatting_reference_sv,
+ int direction, const ELEMENT *element)
+{
+ return 0;
+}
+
+
+
+int
+call_stage_handler(CONVERTER *self, void *stage_handler_sv,
+ const char *stage_name)
+{
+ return 0;
+}
+
+
+
+/* Interface without Perl hash map for registered ids */
+void
+init_registered_ids_hv (CONVERTER *self)
+{
+ self->registered_ids = new_string_list ();
+}
+
+int
+is_hv_registered_id (CONVERTER *self, const char *string)
+{
+ return find_string (self->registered_ids, string);
+}
+
+
+void
+hv_register_id (CONVERTER *self, const char *string)
+{
+ add_string (string, self->registered_ids);
+}
+
+void
+clear_registered_ids_hv (CONVERTER *self)
+{
+ clear_strings_list (self->registered_ids);
+}
+
+void
+free_registered_ids_hv (CONVERTER *self)
+{
+ destroy_strings_list (self->registered_ids);
+ self->registered_ids = 0;
+}
+
diff --git a/tp/Texinfo/XS/main/replace_perl_api_call.c
b/tp/Texinfo/XS/main/replace_perl_api_call.c
new file mode 100644
index 0000000000..291cf869f7
--- /dev/null
+++ b/tp/Texinfo/XS/main/replace_perl_api_call.c
@@ -0,0 +1,88 @@
+/* Copyright 2010-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* implement api to Perl and calls to Perl function that are called from
+ pure C code */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "document_types.h"
+#include "utils.h"
+#include "api_to_perl.h"
+#include "call_perl_function.h"
+
+void
+call_switch_to_global_locale (void)
+{
+}
+
+void
+call_sync_locale (void)
+{
+}
+
+void
+unregister_perl_data (void *sv)
+{
+}
+
+void
+register_perl_data (void *sv)
+{
+}
+
+char *
+get_perl_scalar_reference_value (const void *sv_string)
+{
+ return 0;
+}
+
+char *
+call_nodenamenormalization_unicode_to_transliterate (const char *text)
+{
+ int status;
+ /* the encode_string argument cannot be const, but we also want to keep
+ the same prototype as the replaced function, so we drop with a cast */
+ char *result = encode_string ((char *)text, "us-ascii//TRANSLIT", &status,
0);
+ return result;
+}
+
+const void *
+call_setup_collator (int use_unicode_collation, const char *locale_lang)
+{
+ fprintf (stderr, "BUG: no Perl collation\n");
+ return 0;
+}
+
+/* since call_setup_collator return 0, the following function will never
+ get called */
+BYTES_STRING *
+call_collator_getSortKey (const void *collator_sv, const char *string)
+{
+ BYTES_STRING *result;
+ result = (BYTES_STRING *) malloc (sizeof (BYTES_STRING));
+ memset (result, 0, sizeof (BYTES_STRING));
+ return result;
+}
+
+char *
+call_latex_convert_to_latex_math (CONVERTER *self, const ELEMENT *element)
+{
+ return 0;
+}
+
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
new file mode 100644
index 0000000000..dd053af6e5
--- /dev/null
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -0,0 +1,369 @@
+/* teximakehtml.c -- simplistic conversion of Texinfo to HTML
+
+ Copyright 2010-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include <langinfo.h>
+#include <locale.h>
+#ifdef ENABLE_NLS
+#include <libintl.h>
+#endif
+
+#include "text.h"
+#include "document_types.h"
+#include "api.h"
+#include "conf.h"
+#include "errors.h"
+/* parse_file_path */
+#include "utils.h"
+#include "convert_to_texinfo.h"
+#include "document.h"
+#include "transformations.h"
+#include "structuring.h"
+#include "translations.h"
+/* enum converter_format */
+#include "converter.h"
+#include "convert_html.h"
+
+#define LOCALEDIR DATADIR "/locale"
+
+static void
+print_errors (const ERROR_MESSAGE_LIST *error_messages)
+{
+ int i;
+
+ TEXT text;
+ text_init (&text);
+
+ for (i = 0; i < error_messages->number; i++)
+ {
+ const ERROR_MESSAGE *error_msg = &error_messages->list[i];
+ text_reset (&text);
+ if (error_msg->source_info.file_name)
+ {
+ text_append (&text, error_msg->source_info.file_name);
+ text_append_n (&text, ":", 1);
+ }
+ if (error_msg->source_info.line_nr > 0)
+ {
+ text_printf (&text, "%d:", error_msg->source_info.line_nr);
+ }
+
+ if (text.end > 0)
+ text_append_n (&text, " ", 1);
+
+ text_append (&text, error_msg->error_line);
+ fprintf (stderr, "%s", text.text);
+ }
+ free (text.text);
+}
+
+static void
+initialize_option_value (OPTION *option, OPTION **sorted_options,
+ const char *option_name, int int_value,
+ const char *char_value)
+{
+ const OPTION *ref_option = find_option_string (sorted_options, option_name);
+ if (!ref_option)
+ return;
+
+ initialize_option (option, ref_option->type, ref_option->name);
+ option->number = ref_option->number;
+
+ set_conf (option, int_value, char_value);
+}
+
+static void
+add_option_value (OPTIONS_LIST *options_list, OPTION **sorted_options,
+ const char *option_name, int int_value,
+ const char *char_value)
+{
+ OPTION *option = &options_list->list[options_list->number];
+ initialize_option_value (option, sorted_options, option_name, int_value,
+ char_value);
+ options_list->number++;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int status;
+ int i;
+ char *result = 0;
+ size_t document_descriptor = 0;
+ const char *locale_encoding;
+ DOCUMENT *document;
+ const char *input_file_path;
+ char *input_file_name_and_directory[2];
+ char *input_directory;
+ char *program_file_name_and_directory[2];
+ char *program_file;
+ CONST_ELEMENT_LIST *sections_list;
+ CONST_ELEMENT_LIST *nodes_list;
+ CONVERTER_INITIALIZATION_INFO *format_defaults;
+ CONVERTER_INITIALIZATION_INFO *conf;
+ enum converter_format converter_format = COF_html;
+ size_t converter_descriptor;
+ CONVERTER *converter;
+ char *paths[5];
+ const char *output_file;
+ const char *destination_directory;
+ const char *output_filename;
+ const char *document_name;
+
+ /*
+ const char *texinfo_text;
+ */
+
+#ifdef ENABLE_NLS
+ setlocale (LC_ALL, "");
+
+ /* Set the text message domain. */
+ bindtextdomain (PACKAGE_CONFIG, LOCALEDIR);
+ textdomain (PACKAGE_CONFIG);
+
+ /* set the gnulib text message domain. */
+ bindtextdomain (PACKAGE_CONFIG "_tp-gnulib", LOCALEDIR);
+#endif
+
+ configure_output_strings_translations (LOCALEDIR, 0);
+
+ locale_encoding = nl_langinfo (CODESET);
+
+ if (argc <= 1)
+ exit (1);
+
+ converter_setup (0, 0, 0, 0);
+ html_format_setup ();
+
+ parse_file_path (argv[0], program_file_name_and_directory);
+ program_file = program_file_name_and_directory[0];
+ free (program_file_name_and_directory[1]);
+
+
+ /* Texinfo file parsing */
+ input_file_path = argv[1];
+
+ parse_file_path (input_file_path, input_file_name_and_directory);
+ input_directory = input_file_name_and_directory[1];
+ free (input_file_name_and_directory[0]);
+
+ reset_parser (0);
+
+ if (strcmp (input_file_path, "."))
+ {
+ parser_conf_clear_INCLUDE_DIRECTORIES ();
+ parser_conf_add_include_directory (input_directory);
+ parser_conf_add_include_directory (".");
+ }
+ free (input_directory);
+
+ parser_conf_set_LOCALE_ENCODING (locale_encoding);
+ parser_conf_add_expanded_format ("html");
+
+ document_descriptor = parse_file (input_file_path, &status);
+ document = retrieve_document (document_descriptor);
+
+ if (status)
+ {
+ print_errors (&document->parser_error_messages);
+ remove_document_descriptor (document_descriptor);
+ clear_error_message_list (&document->parser_error_messages);
+ exit (1);
+ }
+
+ print_errors (&document->parser_error_messages);
+ clear_error_message_list (&document->parser_error_messages);
+
+ /*
+ texinfo_text = convert_to_texinfo (document->tree);
+ fprintf (stderr, "%s", texinfo_text);
+ free (texinfo_text);
+ */
+
+
+ /* structure and transformations */
+ initialize_document_options (document);
+
+ /* TODO do a function in structuring that does that, with arguments
+ maybe flags in C.
+ relate_index_entries_to_table_items
+ move_index_entries_after_items
+ opt insert_nodes_for_sectioning_commands
+ no_warn_non_empty_parts
+
+ opt complete_tree_nodes_menus
+ opt complete_tree_nodes_missing_menu
+ opt regenerate_master_menu
+ nodes_tree
+ floats
+ setup_index_entries_sort_strings
+ */
+ /* if (relate_index_entries_to_table_items) */
+ relate_index_entries_to_table_items_in_tree (document->tree,
+ &document->indices_info);
+ /* if (move_index_entries_after_items) */
+ move_index_entries_after_items_in_tree (document->tree);
+ associate_internal_references (document);
+ sections_list = sectioning_structure (document);
+ if (sections_list)
+ register_document_sections_list (document, sections_list);
+ /* if (!no_warn_non_empty_parts) */
+ /* warn_non_empty_parts (document) */
+ /* complete_tree_nodes_menus */
+ /* complete_tree_nodes_missing_menu */
+ /* regenerate_master_menu */
+ /* if (nodes_tree) */
+ nodes_list = nodes_tree (document);
+ register_document_nodes_list (document, nodes_list);
+
+ /* if (format_menus) */
+ /* set_menus_node_directions */
+ /* complete_node_tree_with_menus */
+ /* check_nodes_are_referenced */
+
+ /* if (floats) */
+ number_floats (document);
+ /* if (setup_index_entries_sort_strings) */
+ document_indices_sort_strings (document, &document->error_messages,
+ document->options);
+
+ print_errors (&document->error_messages);
+ clear_error_message_list (&document->error_messages);
+
+/*
+ if ($^O eq 'MSWin32') {
+ $main_program_set_options->{'DOC_ENCODING_FOR_INPUT_FILE_NAME'} = 0;
+}
+*/
+
+ /* converter initialization */
+
+ converter_descriptor = new_converter ();
+ converter = retrieve_converter (converter_descriptor);
+
+ format_defaults = new_converter_initialization_info ();
+ format_defaults->converted_format = strdup ("html");
+ format_defaults->output_format = strdup ("html");
+
+ conf = new_converter_initialization_info ();
+ initialize_options_list (&conf->conf, 10);
+ conf->conf.number = 0;
+
+ add_option_value (&conf->conf, converter->sorted_options,
+ /*
+ */
+ "PROGRAM", 0, program_file);
+ /* comment the line above and uncomment below to compare with
+ texi2any output
+ "PROGRAM", 0, "texi2any");
+ add_option_value (&conf->conf, converter->sorted_options,
+ "PACKAGE_AND_VERSION", 0, "Texinfo 7.1.90+dev");
+ */
+ add_option_value (&conf->conf, converter->sorted_options,
+ "COMMAND_LINE_ENCODING", 0, locale_encoding);
+ add_option_value (&conf->conf, converter->sorted_options,
+ "MESSAGE_ENCODING", 0, locale_encoding);
+ add_option_value (&conf->conf, converter->sorted_options,
+ "LOCALE_ENCODING", 0, locale_encoding);
+ add_option_value (&conf->conf, converter->sorted_options,
+ "XS_STRXFRM_COLLATION_LOCALE", 0, "en_US");
+ /*
+ add_option_value (&conf->conf, converter->sorted_options,
+ "DEBUG", 1, 0);
+ */
+
+ set_converter_init_information (converter, converter_format,
+ format_defaults, conf);
+
+ destroy_converter_initialization_info (format_defaults);
+ destroy_converter_initialization_info (conf);
+
+ /* next 3 functions are HTML specific */
+ html_converter_init_special_unit (converter);
+ html_converter_customize (converter);
+
+ html_fill_options_directions (converter->conf, converter);
+
+
+ /* prepare conversion to HTML */
+
+ converter_set_document (converter, document);
+
+ free (program_file);
+
+ html_initialize_output_state (converter, "_output");
+
+ status = html_setup_output (converter, paths);
+
+ if (!status)
+ {
+ memset (paths, 0, 5 * sizeof (char *));
+ goto finalization;
+ }
+
+ output_file = paths[0];
+ destination_directory = paths[1];
+ output_filename = paths[2];
+ document_name = paths[3];
+
+ html_prepare_conversion_units (converter);
+
+ html_prepare_conversion_units_targets (converter, converter->document_name);
+
+ html_translate_names (converter);
+
+ html_prepare_units_directions_files (converter,
+ output_file, destination_directory, output_filename,
+ document_name);
+
+ status = html_prepare_converted_output_info (converter, output_file,
+ output_filename);
+
+ if (!status)
+ goto finalization;
+
+ /* conversion */
+ if (converter->document)
+ {
+ result = html_convert_output (converter, converter->document->tree,
+ output_file, destination_directory, output_filename,
+ document_name);
+ }
+
+ if (!result)
+ goto finalization;
+
+ free (result);
+ result = 0;
+
+ status = html_finish_output (converter, output_file, destination_directory);
+
+ finalization:
+
+ for (i = 0; i < 5; i++)
+ {
+ free (paths[i]);
+ }
+ /* html_conversion_finalization */
+ html_conversion_finalization (converter);
+}