[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/convert/texinfo.c (txi_converter)
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/convert/texinfo.c (txi_converter), tp/Texinfo/XS/teximakehtml.c (main): create converter before txi_converter such that it may be used to get sorted options. |
Date: |
Fri, 04 Oct 2024 03:28:25 -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 b2120caeb1 * tp/Texinfo/XS/convert/texinfo.c (txi_converter),
tp/Texinfo/XS/teximakehtml.c (main): create converter before txi_converter such
that it may be used to get sorted options.
b2120caeb1 is described below
commit b2120caeb19c0e5d5902e05b71ea3252f8d73368
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 10 12:34:34 2024 +0200
* tp/Texinfo/XS/convert/texinfo.c (txi_converter),
tp/Texinfo/XS/teximakehtml.c (main): create converter before
txi_converter such that it may be used to get sorted options.
* tp/Texinfo/XS/main/utils.c (options_list_add_option): rename
list_add_option as options_list_add_option.
* tp/Texinfo/XS/teximakehtml.c (main, add_button_option): demonstrate
passing button and other options to txi_converter.
---
ChangeLog | 12 +++++++++++
tp/Texinfo/XS/convert/texinfo.c | 15 ++++----------
tp/Texinfo/XS/convert/texinfo.h | 5 +++--
tp/Texinfo/XS/main/utils.c | 8 ++++----
tp/Texinfo/XS/main/utils.h | 1 +
tp/Texinfo/XS/teximakehtml.c | 45 ++++++++++++++++++++++++++++++++++++++---
6 files changed, 66 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1df663fad6..e039bce85c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,18 @@
tp/Texinfo/XS/convert/html_converter_init_options.h: move enum
BUTTON_special_unit_directions to create_buttons.h.
+2024-08-10 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/texinfo.c (txi_converter),
+ tp/Texinfo/XS/teximakehtml.c (main): create converter before
+ txi_converter such that it may be used to get sorted options.
+
+ * tp/Texinfo/XS/main/utils.c (options_list_add_option): rename
+ list_add_option as options_list_add_option.
+
+ * tp/Texinfo/XS/teximakehtml.c (main, add_button_option): demonstrate
+ passing button and other options to txi_converter.
+
2024-08-10 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/create_buttons.c (new_button_specification)
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index 4f08ac9e1a..bbdc2b4713 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -140,22 +140,17 @@ txi_complete_document (DOCUMENT *document, unsigned long
flags,
document->options);
}
-CONVERTER *
-txi_converter (const char *format, const char *locale_encoding,
+void
+txi_converter (CONVERTER *converter,
+ const char *format, const char *locale_encoding,
const char *program_file, OPTIONS_LIST *customizations)
{
- size_t converter_descriptor;
- CONVERTER *converter;
enum converter_format converter_format = find_format_data_index (format);
CONVERTER_INITIALIZATION_INFO *format_defaults;
CONVERTER_INITIALIZATION_INFO *conf;
if (converter_format == COF_none)
- return 0;
-
- /* create converter and generic converter initializations */
- converter_descriptor = new_converter ();
- converter = retrieve_converter (converter_descriptor);
+ return;
/* prepare specific information for the converter */
format_defaults = new_converter_initialization_info ();
@@ -212,8 +207,6 @@ txi_converter (const char *format, const char
*locale_encoding,
destroy_converter_initialization_info (format_defaults);
destroy_converter_initialization_info (conf);
-
- return converter;
}
char *
diff --git a/tp/Texinfo/XS/convert/texinfo.h b/tp/Texinfo/XS/convert/texinfo.h
index 9acafe7185..17cc21abc4 100644
--- a/tp/Texinfo/XS/convert/texinfo.h
+++ b/tp/Texinfo/XS/convert/texinfo.h
@@ -37,8 +37,9 @@ txi_parser (const char *file_path, const char
*locale_encoding,
void txi_complete_document (DOCUMENT *document, unsigned long flags,
int format_menu);
-CONVERTER *txi_converter (const char *format, const char *locale_encoding,
- const char *program_file, OPTIONS_LIST *customizations);
+void txi_converter (CONVERTER *converter,
+ const char *format, const char *locale_encoding,
+ const char *program_file, OPTIONS_LIST *customizations);
char *txi_html_output (CONVERTER *converter, DOCUMENT *document);
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index db20fda8f9..5899f65b88 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -2120,8 +2120,8 @@ new_option_string_value (OPTION **sorted_options,
return option;
}
-static void
-list_add_option (OPTIONS_LIST *options_list, OPTION *option)
+void
+options_list_add_option (OPTIONS_LIST *options_list, OPTION *option)
{
if (options_list->number >= options_list->space)
{
@@ -2141,7 +2141,7 @@ add_option_string_value (OPTIONS_LIST *options_list,
OPTION **sorted_options,
int_value, char_value);
if (option)
- list_add_option (options_list, option);
+ options_list_add_option (options_list, option);
return option;
}
@@ -2155,7 +2155,7 @@ add_option_copy (OPTIONS_LIST *options_list, OPTION
**sorted_options,
copy_option (option, src_option);
- list_add_option (options_list, option);
+ options_list_add_option (options_list, option);
return option;
}
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 2f3aec91a2..7ccc64963e 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -290,6 +290,7 @@ OPTION *add_option_string_value (OPTIONS_LIST *options_list,
OPTION **sorted_options,
const char *option_name, int int_value,
const char *char_value);
+void options_list_add_option (OPTIONS_LIST *options_list, OPTION *option);
void copy_options_list (OPTIONS_LIST *options_list,
const OPTIONS_LIST *options_src, OPTION **sorted_options);
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 34be8cf6c2..291b1e5337 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -37,9 +37,10 @@
*/
/* retrieve_document remove_document_descriptor */
#include "document.h"
-#include "texinfo.h"
#include "converter.h"
+#include "create_buttons.h"
#include "convert_html.h"
+#include "texinfo.h"
#define LOCALEDIR DATADIR "/locale"
@@ -76,9 +77,27 @@ print_errors (ERROR_MESSAGE_LIST *error_messages)
clear_error_message_list (error_messages);
}
+/* this function is quite generic, it could be added to utils.c */
+static void
+add_button_option (OPTIONS_LIST *options_list, OPTION **sorted_options,
+ const char *option_name,
+ BUTTON_SPECIFICATION_LIST *buttons)
+{
+ OPTION *option;
+
+ const OPTION *ref_option = find_option_string (sorted_options, option_name);
+ if (!ref_option)
+ return;
+
+ option = new_option (ref_option->type, ref_option->name, ref_option->number);
+ option->o.buttons = buttons;
+
+ options_list_add_option (options_list, option);
+}
+
static const char *expanded_formats[] = {"html", 0};
-int
+int
main (int argc, char *argv[])
{
const char *locale_encoding;
@@ -88,8 +107,11 @@ main (int argc, char *argv[])
char *program_file;
size_t document_descriptor = 0;
DOCUMENT *document;
+ size_t converter_descriptor;
CONVERTER *converter;
char *result;
+ BUTTON_SPECIFICATION_LIST *custom_node_footer_buttons;
+ OPTIONS_LIST convert_options;
/*
const char *texinfo_text;
@@ -158,10 +180,27 @@ main (int argc, char *argv[])
print_errors (&document->error_messages);
+ /* create converter and generic converter initializations */
+ converter_descriptor = new_converter ();
+ converter = retrieve_converter (converter_descriptor);
+
+ initialize_options_list (&convert_options, 2);
+ /* customize buttons. This is a bit silly to use link buttons for
+ footer, it is for the demonstration */
+ custom_node_footer_buttons = new_base_links_buttons (0);
+ add_button_option (&convert_options, converter->sorted_options,
+ "NODE_FOOTER_BUTTONS", custom_node_footer_buttons);
+ add_option_string_value (&convert_options, converter->sorted_options,
+ "PROGRAM_NAME_IN_FOOTER", 1, 0);
+ /* this is set to help with comparison with previous invokations */
+ add_option_string_value (&convert_options, converter->sorted_options,
+ "TEST", 1, 0);
/* setup converter */
- converter = txi_converter ("html", locale_encoding, program_file, 0);
+ txi_converter (converter, "html", locale_encoding, program_file,
+ &convert_options);
+ free_options_list (&convert_options);
free (program_file);
/* return value can be NULL in case of errors or an empty string, but
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/convert/texinfo.c (txi_converter), tp/Texinfo/XS/teximakehtml.c (main): create converter before txi_converter such that it may be used to get sorted options.,
Patrice Dumas <=