[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: PlainTexinfo converter in C
From: |
Patrice Dumas |
Subject: |
branch master updated: PlainTexinfo converter in C |
Date: |
Wed, 25 Dec 2024 19:07:07 -0500 |
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 deb0cac7e1 PlainTexinfo converter in C
deb0cac7e1 is described below
commit deb0cac7e1bbba1954538d7da6a025d4e10c1032
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Dec 26 01:07:04 2024 +0100
PlainTexinfo converter in C
* tp/Texinfo/Convert/PlainTexinfo.pm (%defaults),
tp/Texinfo/Convert/converters_defaults.txt (plaintexinfo_converter):
add PlainTexinfo converter defaults to converters_defaults.txt.
* tp/Texinfo/XS/convert/converter.c (converter_defaults)
(converter_conversion_initialization): add default implementations.
* tp/Texinfo/XS/convert/converter.h (CONVERTER_FORMAT_DATA),
tp/Texinfo/XS/convert/converter.c (write_or_return)
(converter_output_tree): implement converter_output_tree.
* tp/Texinfo/XS/Makefile.am (C_libtexinfo_convert_sources),
tp/Texinfo/XS/convert/plaintexinfo_converter_api.c
(plaintexinfo_converter_defaults, plaintexinfo_output)
(plaintexinfo_convert, plaintexinfo_convert_tree): implement a
converter for PlainTexinfo.
* tp/Texinfo/XS/texi2any.c (formats_table),
tp/Texinfo/XS/convert/converter.c (converter_format_data):
register the PlainTexinfo C converter.
* tp/Texinfo/XS/texi2any.c (main): check if FORMAT_MENU string is set
before accessing.
* tp/Texinfo/XS/main/document.c (set_document_options): free temporary
document_options options list.
---
ChangeLog | 31 +++
tp/Texinfo/Convert/PlainTexinfo.pm | 12 +-
tp/Texinfo/Convert/converters_defaults.txt | 4 +
tp/Texinfo/Options.pm | 7 +
tp/Texinfo/XS/Makefile.am | 2 +
tp/Texinfo/XS/convert/converter.c | 262 ++++++++++++++++++++-
tp/Texinfo/XS/convert/converter.h | 18 +-
tp/Texinfo/XS/convert/converters_options.c | 14 ++
tp/Texinfo/XS/convert/converters_options.h | 4 +
tp/Texinfo/XS/convert/plaintexinfo_converter_api.c | 61 +++++
tp/Texinfo/XS/convert/plaintexinfo_converter_api.h | 35 +++
tp/Texinfo/XS/main/converter_types.h | 1 +
tp/Texinfo/XS/main/document.c | 2 +-
tp/Texinfo/XS/texi2any.c | 6 +-
14 files changed, 435 insertions(+), 24 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 247570ddca..1d338c63bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2024-12-25 Patrice Dumas <pertusus@free.fr>
+
+ PlainTexinfo converter in C
+
+ * tp/Texinfo/Convert/PlainTexinfo.pm (%defaults),
+ tp/Texinfo/Convert/converters_defaults.txt (plaintexinfo_converter):
+ add PlainTexinfo converter defaults to converters_defaults.txt.
+
+ * tp/Texinfo/XS/convert/converter.c (converter_defaults)
+ (converter_conversion_initialization): add default implementations.
+
+ * tp/Texinfo/XS/convert/converter.h (CONVERTER_FORMAT_DATA),
+ tp/Texinfo/XS/convert/converter.c (write_or_return)
+ (converter_output_tree): implement converter_output_tree.
+
+ * tp/Texinfo/XS/Makefile.am (C_libtexinfo_convert_sources),
+ tp/Texinfo/XS/convert/plaintexinfo_converter_api.c
+ (plaintexinfo_converter_defaults, plaintexinfo_output)
+ (plaintexinfo_convert, plaintexinfo_convert_tree): implement a
+ converter for PlainTexinfo.
+
+ * tp/Texinfo/XS/texi2any.c (formats_table),
+ tp/Texinfo/XS/convert/converter.c (converter_format_data):
+ register the PlainTexinfo C converter.
+
+ * tp/Texinfo/XS/texi2any.c (main): check if FORMAT_MENU string is set
+ before accessing.
+
+ * tp/Texinfo/XS/main/document.c (set_document_options): free temporary
+ document_options options list.
+
2024-12-25 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/document.c (set_document_options): replace
diff --git a/tp/Texinfo/Convert/PlainTexinfo.pm
b/tp/Texinfo/Convert/PlainTexinfo.pm
index 042dcd2f33..fa403d4f4d 100644
--- a/tp/Texinfo/Convert/PlainTexinfo.pm
+++ b/tp/Texinfo/Convert/PlainTexinfo.pm
@@ -25,6 +25,8 @@ package Texinfo::Convert::PlainTexinfo;
use 5.006;
use strict;
+use Texinfo::Options;
+
use Texinfo::Convert::ConvertXS;
use Texinfo::XSLoader;
@@ -54,13 +56,9 @@ sub import {
goto &Exporter::import;
}
-
-my %defaults = (
- # Customization option variables
- 'EXTENSION' => 'texi',
- # different from the default, which is undef
- 'OUTFILE' => '-',
-);
+my $regular_defaults
+ = Texinfo::Options::get_regular_options('plaintexinfo_converter');
+my %defaults = %{$regular_defaults};
sub converter_defaults($$)
{
diff --git a/tp/Texinfo/Convert/converters_defaults.txt
b/tp/Texinfo/Convert/converters_defaults.txt
index 057b52343f..23793c9713 100644
--- a/tp/Texinfo/Convert/converters_defaults.txt
+++ b/tp/Texinfo/Convert/converters_defaults.txt
@@ -64,6 +64,10 @@ PACKAGE_VERSION
PACKAGE_URL https://www.gnu.org/software/texinfo/
PROGRAM
+# Texinfo::Convert::PlainTexinfo
+- plaintexinfo_converter
+EXTENSION texi
+OUTFILE -
- html_converter
diff --git a/tp/Texinfo/Options.pm b/tp/Texinfo/Options.pm
index 74099ef8bc..53a249ba7b 100644
--- a/tp/Texinfo/Options.pm
+++ b/tp/Texinfo/Options.pm
@@ -358,6 +358,13 @@ my %html_converter_regular_options_defaults = (
$regular_options_types{'html_converter'} =
\%html_converter_regular_options_defaults;
+my %plaintexinfo_converter_regular_options_defaults = (
+ 'EXTENSION' => 'texi',
+ 'OUTFILE' => '-',
+);
+
+$regular_options_types{'plaintexinfo_converter'} =
\%plaintexinfo_converter_regular_options_defaults;
+
my %texi2html_regular_options_defaults = (
'FORMAT_MENU' => 'menu',
'USE_SETFILENAME_EXTENSION' => 0,
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index df08f0685d..d787b6aa03 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -505,6 +505,8 @@ C_libtexinfo_convert_sources = \
convert/html_conversion_api.h \
convert/html_converter_api.c \
convert/html_converter_api.h \
+ convert/plaintexinfo_converter_api.c \
+ convert/plaintexinfo_converter_api.h \
convert/texinfo.c \
convert/texinfo.h
diff --git a/tp/Texinfo/XS/convert/converter.c
b/tp/Texinfo/XS/convert/converter.c
index 85fbc01e03..86fda331ed 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -60,16 +60,22 @@
#include "unicode.h"
#include "manipulate_indices.h"
#include "document.h"
-#include "html_converter_api.h"
#include "api_to_perl.h"
+#include "html_converter_api.h"
+#include "plaintexinfo_converter_api.h"
#include "converter.h"
/* table used to dispatch format specific functions.
Same purpose as inherited methods in Texinfo::Convert::Converter */
+/* Should be kept in sync with enum converter_format
+ and TXI_CONVERSION_FORMAT_NR */
CONVERTER_FORMAT_DATA converter_format_data[] = {
{"html", "Texinfo::Convert::HTML", &html_converter_defaults,
- &html_converter_initialize, &html_output, &html_convert,
+ &html_converter_initialize, &html_output, &html_convert, 0,
&html_reset_converter, &html_free_converter},
+ {"plaintexinfo", "Texinfo::Convert::PlainTexinfo",
+ &plaintexinfo_converter_defaults, 0, &plaintexinfo_output,
+ &plaintexinfo_convert, &plaintexinfo_convert_tree, 0, 0},
};
/* associate lower case no brace accent command to the upper case
@@ -479,9 +485,9 @@ copy_converter_initialization_info
(CONVERTER_INITIALIZATION_INFO *dst_info,
functions are already called (and possibly overriden). Inheritance
in Perl is replaced by dispatching using a table here.
- converter_initialize cannot be overriden fully in HTML because Perl
+ converter_initialize cannot be overriden fully in HTML as long as Perl
code is needed to setup customization in Perl. Therefore, there is
- no prospect of overriding converter_initialize fully, and therefore
+ no prospect of overriding converter_initialize for now, and therefore
of overridding converter_converter. Those functions are only meant
for pure C.
*/
@@ -490,19 +496,31 @@ CONVERTER_INITIALIZATION_INFO *
converter_defaults (enum converter_format converter_format,
const CONVERTER_INITIALIZATION_INFO *user_conf)
{
- if (converter_format != COF_none
- && converter_format_data[converter_format].converter_defaults)
+ if (converter_format != COF_none)
{
- CONVERTER_INITIALIZATION_INFO *
- (* format_converter_defaults) (enum converter_format format,
+ if (converter_format_data[converter_format].converter_defaults)
+ {
+ CONVERTER_INITIALIZATION_INFO *
+ (* format_converter_defaults) (enum converter_format format,
const CONVERTER_INITIALIZATION_INFO *conf)
- = converter_format_data[converter_format].converter_defaults;
- return format_converter_defaults (converter_format, user_conf);
+ = converter_format_data[converter_format].converter_defaults;
+ return format_converter_defaults (converter_format, user_conf);
+ }
+ else
+ { /* Texinfo::Convert::Converter implementation */
+ CONVERTER_INITIALIZATION_INFO *format_defaults
+ = new_converter_initialization_info ();
+
+ add_converter_defaults_regular_options_defaults
+ (&format_defaults->conf);
+ return format_defaults;
+ }
}
return 0;
}
/* corresponds to Perl $converter->converter_initialize() Converter */
+/* default is to do nothing */
void
converter_initialize (CONVERTER *converter)
{
@@ -592,6 +610,230 @@ converter_set_document (CONVERTER *converter, DOCUMENT
*document)
= copy_converter_options_for_convert_text (converter);
}
+/* default implementation */
+void
+converter_conversion_initialization (CONVERTER *converter, DOCUMENT *document)
+{
+ converter_set_document (converter, document);
+}
+
+/* output fo $fh if defined, otherwise return the text. */
+void
+write_or_return (const ENCODING_CONVERSION *conversion,
+ const char *encoded_out_filepath,
+ FILE *file_fh, TEXT *result, char *text)
+{
+ if (file_fh)
+ {
+ char *result;
+ size_t res_len;
+ size_t write_len;
+
+ if (conversion)
+ {
+ result = encode_with_iconv (conversion->iconv,
+ text, 0);
+ res_len = strlen (result);
+ }
+ else
+ {
+ result = text;
+ res_len = strlen (text);
+ }
+ write_len = fwrite (result, sizeof (char),
+ res_len, file_fh);
+ if (conversion)
+ free (result);
+ if (write_len != res_len)
+ { /* register error message instead? */
+ fprintf (stderr,
+ "ERROR: write to %s failed (%zu/%zu)\n",
+ encoded_out_filepath, write_len, res_len);
+ }
+ }
+ else
+ text_append (result, text);
+}
+
+char *
+converter_output_tree (CONVERTER *converter, DOCUMENT *document,
+ void * (* conversion_initialization)
+ (CONVERTER *converter, DOCUMENT *document),
+ char * (* conversion_output_begin)
+ (CONVERTER *converter,
+ const char *output_file, const char *output_filename),
+ char * (* conversion_output_end) (CONVERTER *converter),
+ void * (* conversion_finalization) (CONVERTER *converter))
+{
+ int status = 1;
+ ELEMENT *root = document->tree;
+ int i;
+ char *paths[5];
+ char *dir_encoding;
+ const char *output_file;
+ const char *destination_directory;
+ const char *output_filename;
+ FILE *file_fh = 0;
+ char *encoded_destination_directory;
+ int succeeded;
+ const ENCODING_CONVERSION *conversion = 0;
+ TEXT result;
+ char *encoded_out_filepath = 0;
+ char *tree_result;
+
+ char *(* format_convert_tree) (CONVERTER *converter,
+ const ELEMENT *tree)
+ = converter_format_data[converter->format].converter_convert_tree;
+
+ if (conversion_initialization)
+ {
+ conversion_initialization (converter, document);
+ }
+ else
+ converter_conversion_initialization (converter, document);
+
+ determine_files_and_directory (converter,
+ converter->conf->TEXINFO_OUTPUT_FORMAT.o.string, paths);
+
+ output_file = paths[0];
+ destination_directory = paths[1];
+ output_filename = paths[2];
+
+ /* cast to remove const since the encoded_output_file_name argument cannot
+ be const even though the string is not modified */
+ encoded_destination_directory = encoded_output_file_name (converter->conf,
+ &converter->document->global_info,
+ (char *)destination_directory,
+ &dir_encoding, 0);
+ free (dir_encoding);
+
+ succeeded = create_destination_directory (converter,
+ encoded_destination_directory,
+ destination_directory);
+
+ free (encoded_destination_directory);
+
+ if (!succeeded)
+ {
+ if (conversion_finalization)
+ conversion_finalization (converter);
+ status = 0;
+ goto finalization;
+ }
+
+ if (strlen (output_file))
+ {
+ char *path_encoding;
+ int overwritten_file;
+ char *open_error_message;
+
+ encoded_out_filepath = encoded_output_file_name (converter->conf,
+ &converter->document->global_info,
+ (char *)output_file, &path_encoding, 0);
+ /* overwritten_file being set cannot happen */
+ file_fh = output_files_open_out (&converter->output_files_information,
+ encoded_out_filepath, &open_error_message,
+ &overwritten_file, 0);
+ free (path_encoding);
+
+ if (!file_fh)
+ {
+ message_list_document_error (&converter->error_messages,
+ converter->conf, 0,
+ "could not open %s for writing: %s",
+ output_file, open_error_message);
+ free (open_error_message);
+ free (encoded_out_filepath);
+
+ if (conversion_finalization)
+ conversion_finalization (converter);
+ status = 0;
+ goto finalization;
+ }
+ }
+
+ text_init (&result);
+ text_append (&result, "");
+
+ if (file_fh)
+ {
+ if (converter->conf->OUTPUT_ENCODING_NAME.o.string
+ && strcmp (converter->conf->OUTPUT_ENCODING_NAME.o.string, "utf-8"))
+ {
+ conversion
+ = get_encoding_conversion (
+ converter->conf->OUTPUT_ENCODING_NAME.o.string,
+ &output_conversions);
+ }
+ }
+
+ if (conversion_output_begin)
+ {
+ char *output_beginning = conversion_output_begin (converter,
+ output_file,
+ output_filename);
+ if (output_beginning)
+ {
+ write_or_return (conversion, encoded_out_filepath,
+ file_fh, &result, output_beginning);
+ free (output_beginning);
+ }
+ }
+ tree_result = format_convert_tree (converter, root);
+ if (tree_result)
+ {
+ write_or_return (conversion, encoded_out_filepath,
+ file_fh, &result, tree_result);
+ free (tree_result);
+ }
+
+ if (conversion_output_end)
+ {
+ char *output_end = conversion_output_end (converter);
+ if (output_end)
+ {
+ write_or_return (conversion, encoded_out_filepath,
+ file_fh, &result, output_end);
+ free (output_end);
+ }
+ }
+
+ if (file_fh && !strcmp (output_file, "-"))
+ {
+ output_files_register_closed
+ (&converter->output_files_information,
+ encoded_out_filepath);
+ if (fclose (file_fh))
+ {
+ message_list_document_error (
+ &converter->error_messages, converter->conf, 0,
+ "error on closing %s: %s",
+ output_file, strerror (errno));
+ }
+ }
+
+ if (encoded_out_filepath)
+ free (encoded_out_filepath);
+
+ if (conversion_finalization)
+ conversion_finalization (converter);
+
+ finalization:
+
+ for (i = 0; i < 5; i++)
+ {
+ free (paths[i]);
+ }
+
+ if (status)
+ return result.text;
+ else
+ {
+ free (result.text);
+ return 0;
+ }
+}
+
/* result to be freed */
diff --git a/tp/Texinfo/XS/convert/converter.h
b/tp/Texinfo/XS/convert/converter.h
index efbaf07f7f..b9de51872a 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -66,7 +66,7 @@
} \
break;
-#define TXI_CONVERSION_FORMAT_NR (COF_html +1)
+#define TXI_CONVERSION_FORMAT_NR (COF_plaintexinfo +1)
typedef struct FLOAT_CAPTION_PREPENDED_ELEMENT {
const ELEMENT *caption;
@@ -99,11 +99,11 @@ typedef struct CONVERTER_FORMAT_DATA {
void (* converter_initialize) (CONVERTER *self);
char * (* converter_output) (CONVERTER *converter, DOCUMENT *document);
char * (* converter_convert) (CONVERTER *converter, DOCUMENT *document);
- /* API to be determined, in HTML there is a debugging explanation
+ /* TODO API to be determined, in HTML there is a debugging explanation
argument
- char *(* converter_convert_tree) (CONVERTER *converter,
- const ELEMENT *tree);
*/
+ char * (* converter_convert_tree) (CONVERTER *converter,
+ const ELEMENT *tree);
void (* converter_reset) (CONVERTER *self);
void (* converter_free) (CONVERTER *self);
} CONVERTER_FORMAT_DATA;
@@ -155,6 +155,16 @@ void destroy_converter_initialization_info (
void converter_set_document (CONVERTER *converter, DOCUMENT *document);
+char *
+converter_output_tree (CONVERTER *converter, DOCUMENT *document,
+ void * (* conversion_initialization)
+ (CONVERTER *converter, DOCUMENT *document),
+ char * (* conversion_output_begin)
+ (CONVERTER *converter,
+ const char *output_file, const char *output_filename),
+ char * (* conversion_output_end) (CONVERTER *converter),
+ void * (* conversion_finalization) (CONVERTER *converter));
+
char *converter_output (CONVERTER *self, DOCUMENT *document);
char *converter_convert (CONVERTER *self, DOCUMENT *document);
diff --git a/tp/Texinfo/XS/convert/converters_options.c
b/tp/Texinfo/XS/convert/converters_options.c
index c86cb6e2ad..d59e5daad7 100644
--- a/tp/Texinfo/XS/convert/converters_options.c
+++ b/tp/Texinfo/XS/convert/converters_options.c
@@ -186,6 +186,20 @@ add_html_converter_regular_options_defaults (OPTIONS_LIST
*options_list)
add_option_value (options_list, "xrefautomaticsectiontitle", -2, "on");
}
+void
+set_plaintexinfo_converter_regular_options_defaults (OPTIONS *options)
+{
+ option_set_conf (&options->EXTENSION, -2, "texi");
+ option_set_conf (&options->OUTFILE, -2, "-");
+}
+
+void
+add_plaintexinfo_converter_regular_options_defaults (OPTIONS_LIST
*options_list)
+{
+ add_option_value (options_list, "EXTENSION", -2, "texi");
+ add_option_value (options_list, "OUTFILE", -2, "-");
+}
+
void
set_texi2html_regular_options_defaults (OPTIONS *options)
{
diff --git a/tp/Texinfo/XS/convert/converters_options.h
b/tp/Texinfo/XS/convert/converters_options.h
index a4de892b04..19ddf804c6 100644
--- a/tp/Texinfo/XS/convert/converters_options.h
+++ b/tp/Texinfo/XS/convert/converters_options.h
@@ -31,6 +31,10 @@ void set_html_converter_regular_options_defaults (OPTIONS
*options);
void add_html_converter_regular_options_defaults (OPTIONS_LIST *options_list);
+void set_plaintexinfo_converter_regular_options_defaults (OPTIONS *options);
+
+void add_plaintexinfo_converter_regular_options_defaults (OPTIONS_LIST
*options_list);
+
void set_texi2html_regular_options_defaults (OPTIONS *options);
void add_texi2html_regular_options_defaults (OPTIONS_LIST *options_list);
diff --git a/tp/Texinfo/XS/convert/plaintexinfo_converter_api.c
b/tp/Texinfo/XS/convert/plaintexinfo_converter_api.c
new file mode 100644
index 0000000000..9d853f583f
--- /dev/null
+++ b/tp/Texinfo/XS/convert/plaintexinfo_converter_api.c
@@ -0,0 +1,61 @@
+/* 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 "document_types.h"
+#include "converter_types.h"
+#include "customization_options.h"
+#include "convert_to_texinfo.h"
+#include "converters_options.h"
+/* converter_output_tree */
+#include "converter.h"
+#include "plaintexinfo_converter_api.h"
+
+CONVERTER_INITIALIZATION_INFO *
+plaintexinfo_converter_defaults (enum converter_format format,
+ const CONVERTER_INITIALIZATION_INFO *conf)
+{
+ CONVERTER_INITIALIZATION_INFO *format_defaults
+ = new_converter_initialization_info ();
+
+ add_plaintexinfo_converter_regular_options_defaults (&format_defaults->conf);
+
+ return format_defaults;
+}
+
+char *
+plaintexinfo_output (CONVERTER *converter, DOCUMENT *document)
+{
+ return converter_output_tree (converter, document, 0, 0, 0, 0);
+}
+
+char *
+plaintexinfo_convert (CONVERTER *converter, DOCUMENT *document)
+{
+ char *result = convert_to_texinfo (document->tree);
+ return result;
+}
+
+char *
+plaintexinfo_convert_tree (CONVERTER *converter,
+ const ELEMENT *tree)
+{
+ char *result = convert_to_texinfo (tree);
+ return result;
+}
+
+
diff --git a/tp/Texinfo/XS/convert/plaintexinfo_converter_api.h
b/tp/Texinfo/XS/convert/plaintexinfo_converter_api.h
new file mode 100644
index 0000000000..ab0d9a4047
--- /dev/null
+++ b/tp/Texinfo/XS/convert/plaintexinfo_converter_api.h
@@ -0,0 +1,35 @@
+/* plaintexinfo_converter_api.h - PlainTexinfo converter API */
+#ifndef PLAINTEXINFO_CONVERTER_API_H
+#define PLAINTEXINFO_CONVERTER_API_H
+
+/* 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/>. */
+
+/* PlainTexinfo Converter API */
+
+#include "document_types.h"
+#include "converter_types.h"
+
+CONVERTER_INITIALIZATION_INFO *plaintexinfo_converter_defaults
+ (enum converter_format format,
+ const CONVERTER_INITIALIZATION_INFO *conf);
+
+char *plaintexinfo_output (CONVERTER *converter, DOCUMENT *document);
+
+char *plaintexinfo_convert (CONVERTER *converter, DOCUMENT *document);
+
+char *plaintexinfo_convert_tree (CONVERTER *converter,
+ const ELEMENT *tree);
+#endif
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 54163de0b8..79386f96c9 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -36,6 +36,7 @@ struct TEXT_OPTIONS;
enum converter_format {
COF_none = -1,
COF_html,
+ COF_plaintexinfo,
};
/* for string information passing to/from perl */
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index 4a6d77fa44..c08567a4df 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -199,7 +199,7 @@ set_document_options (DOCUMENT *document, const
OPTIONS_LIST *program_options,
sorted_options,
&document_options, 0);
- clear_options_list (&document_options);
+ free_options_list (&document_options);
register_document_options (document, options, sorted_options);
}
diff --git a/tp/Texinfo/XS/texi2any.c b/tp/Texinfo/XS/texi2any.c
index 6e519e9a5a..c642b227ac 100644
--- a/tp/Texinfo/XS/texi2any.c
+++ b/tp/Texinfo/XS/texi2any.c
@@ -129,6 +129,7 @@ static FORMAT_SPECIFICATION formats_table[] = {
{"debugtree", STTF_split,
NULL, "Texinfo::DebugTree", NULL},
{"textcontent", 0, NULL, "Texinfo::Convert::TextContent", NULL},
+ {"plaintexinfo", 0, NULL, NULL, NULL},
{"parse", 0, NULL, NULL, NULL},
{"structure", STTF_nodes_tree | STTF_floats | STTF_split, NULL, NULL, NULL},
{NULL, 0, NULL, NULL, NULL}
@@ -1854,8 +1855,9 @@ main (int argc, char *argv[], char *env[])
is set */
if (format_defaults)
{
- conversion_format_menu_default
- = strdup (format_defaults->conf.options->FORMAT_MENU.o.string);
+ if (format_defaults->conf.options->FORMAT_MENU.o.string)
+ conversion_format_menu_default
+ = strdup (format_defaults->conf.options->FORMAT_MENU.o.string);
if (conversion_format_menu_default != 0)
{
/*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: PlainTexinfo converter in C,
Patrice Dumas <=