[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Wed, 2 Oct 2024 07:39:03 -0400 (EDT) |
branch: master
commit bfd7624c6a5de857b8ce9b59b41bc5bff23b2337
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Aug 1 01:34:32 2024 +0200
* tp/Makefile.am (EXTRA_DIST),
tp/Texinfo/Convert/converters_defaults.txt, tp/Texinfo/XS/Makefile.am
(BUILT_SOURCES, MAINTAINERCLEANFILES, regenerate_C_options_info.pl)
(ConvertXS_la_SOURCES, EXTRA_DIST),
tp/maintain/regenerate_C_options_info.pl: generate with
regenerate_C_options_info.pl C functions in
convert/converters_defaults.c based on a textual description in
tp/Texinfo/Convert/converters_defaults.txt that sets converters default
string and integer options.
---
ChangeLog | 12 +++
tp/Makefile.am | 3 +-
tp/Texinfo/Convert/converters_defaults.txt | 83 +++++++++++++++++
tp/Texinfo/XS/Makefile.am | 14 ++-
tp/Texinfo/XS/convert/converters_defaults.c | 64 +++++++++++++
tp/Texinfo/XS/convert/converters_defaults.h | 17 ++++
tp/maintain/regenerate_C_options_info.pl | 136 +++++++++++++++++++++++++---
7 files changed, 311 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b6994542ff..180c4f16bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-07-31 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Makefile.am (EXTRA_DIST),
+ tp/Texinfo/Convert/converters_defaults.txt, tp/Texinfo/XS/Makefile.am
+ (BUILT_SOURCES, MAINTAINERCLEANFILES, regenerate_C_options_info.pl)
+ (ConvertXS_la_SOURCES, EXTRA_DIST),
+ tp/maintain/regenerate_C_options_info.pl: generate with
+ regenerate_C_options_info.pl C functions in
+ convert/converters_defaults.c based on a textual description in
+ tp/Texinfo/Convert/converters_defaults.txt that sets converters default
+ string and integer options.
+
2024-07-31 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c (html_default_format_button):
diff --git a/tp/Makefile.am b/tp/Makefile.am
index 20f2583f9a..de2673479b 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -357,7 +357,8 @@ EXTRA_DIST = \
$(maintenance_files) \
maintain/lib \
Texinfo/command_data.txt \
- Texinfo/options_data.txt
+ Texinfo/options_data.txt \
+ Texinfo/Convert/converters_defaults.txt
# template.pod is the basis for the .pm documentation, and the script
# invoked here updates them; to be run when template.pod changes.
diff --git a/tp/Texinfo/Convert/converters_defaults.txt
b/tp/Texinfo/Convert/converters_defaults.txt
new file mode 100644
index 0000000000..422a7606d0
--- /dev/null
+++ b/tp/Texinfo/Convert/converters_defaults.txt
@@ -0,0 +1,83 @@
+# Copyright 2010-2024 Free Software Foundation, Inc.
+#
+# This file is part of GNU Texinfo.
+#
+# GNU Texinfo 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/>.
+
+# this information is used to setup converter options for both C and
+# Perl.
+
+- html
+
+BIG_RULE <hr>
+BODY_ELEMENT_ATTRIBUTES undef
+CHAPTER_HEADER_LEVEL 2
+CLOSE_QUOTE_SYMBOL undef
+CONTENTS_OUTPUT_LOCATION after_top
+CONVERT_TO_LATEX_IN_MATH undef
+INDENTED_BLOCK_COMMANDS_IN_TABLE 0
+COPIABLE_LINKS 1
+DATE_IN_HEADER 0
+DEFAULT_RULE <hr>
+documentlanguage en
+DOCTYPE <!DOCTYPE html>
+DO_ABOUT 0
+OUTPUT_CHARACTERS 0
+EXTENSION html
+# based on EXTENSION
+EXTERNAL_CROSSREF_EXTENSION undef
+FOOTNOTE_END_HEADER_LEVEL 4
+FOOTNOTE_SEPARATE_HEADER_LEVEL 4
+FORMAT_MENU sectiontoc
+HEADERS 1
+INDEX_ENTRY_COLON
+# if set style is added in attribute.
+INLINE_CSS_STYLE 0
+JS_WEBLABELS generate
+# no clash with node name
+JS_WEBLABELS_FILE js_licenses.html
+MAX_HEADER_LEVEL 4
+MENU_ENTRY_COLON :
+MENU_SYMBOL undef
+MONOLITHIC 1
+NO_CUSTOM_HTML_ATTRIBUTE 0
+# if set, no css is used.
+NO_CSS 0
+NO_NUMBER_FOOTNOTE_SYMBOL *
+NODE_NAME_IN_MENU 1
+OPEN_QUOTE_SYMBOL undef
+OUTPUT_ENCODING_NAME utf-8
+SECTION_NAME_IN_TITLE 0
+SHORT_TOC_LINK_TO_TOC 1
+SHOW_TITLE undef
+SPLIT node
+# ignores EXTENSION
+# ignores EXTENSION
+TOP_FILE index.html
+TOP_NODE_FILE_TARGET index.html
+USE_ACCESSKEY 1
+USE_NEXT_HEADING_FOR_LONE_NODE 1
+USE_ISO 1
+USE_LINKS 1
+USE_NODES 1
+USE_NODE_DIRECTIONS undef
+USE_REL_REV 1
+USE_TITLEPAGE_FOR_TITLE 1
+WORDS_IN_PAGE 300
+# for internal cross references
+XREF_USE_NODE_NAME_ARG undef
+XREF_USE_FLOAT_LABEL 0
+xrefautomaticsectiontitle on
+
+
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 2c3224d365..4f24c8f6a0 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -230,6 +230,8 @@ libtexinfo_la_LDFLAGS = -version-info 0:0:0
$(perl_conf_LDFLAGS) $(LTLIBINTL) $(
BUILT_SOURCES = main/accent_tables_8bit_codepoints.c \
convert/cmd_converter.c \
+ convert/converters_defaults.c \
+ convert/converters_defaults.h \
main/cmd_normalization.c \
main/cmd_structuring.c \
main/cmd_text.c \
@@ -251,6 +253,8 @@ BUILT_SOURCES = main/accent_tables_8bit_codepoints.c \
EXTRA_DIST+=main/element_types.txt main/element_types.awk \
main/command_data.awk
EXTRA_DIST += convert/cmd_converter.c
+EXTRA_DIST += convert/converters_defaults.c
+EXTRA_DIST += convert/converters_defaults.h
$(srcdir)/main/element_types.c $(srcdir)/main/element_types.h:
main/element_types.txt main/element_types.awk
$(GAWK) -v srcdir=$(srcdir)/main -f $(srcdir)/main/element_types.awk \
@@ -295,16 +299,20 @@ $(srcdir)/main/accent_tables_8bit_codepoints.c:
$(srcdir)/../../maintain/setup_a
MAINTAINERCLEANFILES += main/accent_tables_8bit_codepoints.c
-$(srcdir)/main/options_init_free.c $(srcdir)/main/options_types.h
$(srcdir)/main/options_get_perl.c: ../options_data.txt main/command_data.c
$(srcdir)/../../maintain/regenerate_C_options_info.pl
+$(srcdir)/main/options_init_free.c $(srcdir)/main/options_types.h
$(srcdir)/main/options_get_perl.c $(srcdir)/convert/converters_defaults.c
$(srcdir)/convert/converters_defaults.h: ../options_data.txt
../Convert/converters_defaults.txt main/command_data.c
$(srcdir)/../../maintain/regenerate_C_options_info.pl
$(PERL) $(srcdir)/../../maintain/regenerate_C_options_info.pl \
< $(srcdir)/../options_data.txt \
$(srcdir)/main/command_data.c \
+ $(srcdir)/../Convert/converters_defaults.txt \
$(srcdir)/main/options_init_free.c \
$(srcdir)/main/options_types.h \
+ $(srcdir)/convert/converters_defaults.c \
+ $(srcdir)/convert/converters_defaults.h \
$(srcdir)/main/options_get_perl.c
MAINTAINERCLEANFILES += main/options_init_free.c main/options_types.h \
- main/options_get_perl.c
+ main/options_get_perl.c convert/converters_defaults.c \
+ convert/converters_defaults.h
$(srcdir)/main/conversion_data.c $(srcdir)/main/conversion_data.h:
main/command_data.c $(srcdir)/../Data/default_css_element_class_styles.csv
$(srcdir)/../Data/default_direction_strings.csv
$(srcdir)/../Data/default_special_unit_info.csv
$(srcdir)/../Data/html_style_commands_element.csv
$(srcdir)/../../maintain/generate_code_convert_data.pl
$(PERL) $(srcdir)/../../maintain/generate_code_convert_data.pl \
@@ -361,6 +369,8 @@ libtexinfo_convert_la_SOURCES= \
convert/cmd_converter.c \
convert/convert_html.h \
convert/convert_html.c \
+ convert/converters_defaults.c \
+ convert/converters_defaults.h \
convert/build_html_perl_state.h \
convert/build_html_perl_state.c \
convert/call_html_perl_function.h \
diff --git a/tp/Texinfo/XS/convert/converters_defaults.c
b/tp/Texinfo/XS/convert/converters_defaults.c
new file mode 100644
index 0000000000..9130e70917
--- /dev/null
+++ b/tp/Texinfo/XS/convert/converters_defaults.c
@@ -0,0 +1,64 @@
+/* Automatically generated from ./../../maintain/regenerate_C_options_info.pl
*/
+
+#include <config.h>
+
+#include "options_types.h"
+#include "converter.h"
+#include "converters_defaults.h"
+
+void set_html_regular_options_defaults (OPTIONS *options)
+{
+ set_conf (&options->BIG_RULE, -2, "<hr>");
+ set_conf (&options->BODY_ELEMENT_ATTRIBUTES, -2, 0);
+ set_conf (&options->CHAPTER_HEADER_LEVEL, 2, 0);
+ set_conf (&options->CLOSE_QUOTE_SYMBOL, -2, 0);
+ set_conf (&options->CONTENTS_OUTPUT_LOCATION, -2, "after_top");
+ set_conf (&options->CONVERT_TO_LATEX_IN_MATH, -1, 0);
+ set_conf (&options->INDENTED_BLOCK_COMMANDS_IN_TABLE, 0, 0);
+ set_conf (&options->COPIABLE_LINKS, 1, 0);
+ set_conf (&options->DATE_IN_HEADER, 0, 0);
+ set_conf (&options->DEFAULT_RULE, -2, "<hr>");
+ set_conf (&options->documentlanguage, -2, "en");
+ set_conf (&options->DOCTYPE, -2, "");
+ set_conf (&options->DO_ABOUT, 0, 0);
+ set_conf (&options->OUTPUT_CHARACTERS, 0, 0);
+ set_conf (&options->EXTENSION, -2, "html");
+ set_conf (&options->EXTERNAL_CROSSREF_EXTENSION, -2, 0);
+ set_conf (&options->FOOTNOTE_END_HEADER_LEVEL, 4, 0);
+ set_conf (&options->FOOTNOTE_SEPARATE_HEADER_LEVEL, 4, 0);
+ set_conf (&options->FORMAT_MENU, -2, "sectiontoc");
+ set_conf (&options->HEADERS, 1, 0);
+ set_conf (&options->INDEX_ENTRY_COLON, -2, "");
+ set_conf (&options->INLINE_CSS_STYLE, 0, 0);
+ set_conf (&options->JS_WEBLABELS, -2, "generate");
+ set_conf (&options->JS_WEBLABELS_FILE, -2, "js_licenses.html");
+ set_conf (&options->MAX_HEADER_LEVEL, 4, 0);
+ set_conf (&options->MENU_ENTRY_COLON, -2, ":");
+ set_conf (&options->MENU_SYMBOL, -2, 0);
+ set_conf (&options->MONOLITHIC, 1, 0);
+ set_conf (&options->NO_CUSTOM_HTML_ATTRIBUTE, 0, 0);
+ set_conf (&options->NO_CSS, 0, 0);
+ set_conf (&options->NO_NUMBER_FOOTNOTE_SYMBOL, -2, "*");
+ set_conf (&options->NODE_NAME_IN_MENU, 1, 0);
+ set_conf (&options->OPEN_QUOTE_SYMBOL, -2, 0);
+ set_conf (&options->OUTPUT_ENCODING_NAME, -2, "utf-8");
+ set_conf (&options->SECTION_NAME_IN_TITLE, 0, 0);
+ set_conf (&options->SHORT_TOC_LINK_TO_TOC, 1, 0);
+ set_conf (&options->SHOW_TITLE, -1, 0);
+ set_conf (&options->SPLIT, -2, "node");
+ set_conf (&options->TOP_FILE, -2, "index.html");
+ set_conf (&options->TOP_NODE_FILE_TARGET, -2, "index.html");
+ set_conf (&options->USE_ACCESSKEY, 1, 0);
+ set_conf (&options->USE_NEXT_HEADING_FOR_LONE_NODE, 1, 0);
+ set_conf (&options->USE_ISO, 1, 0);
+ set_conf (&options->USE_LINKS, 1, 0);
+ set_conf (&options->USE_NODES, 1, 0);
+ set_conf (&options->USE_NODE_DIRECTIONS, -1, 0);
+ set_conf (&options->USE_REL_REV, 1, 0);
+ set_conf (&options->USE_TITLEPAGE_FOR_TITLE, 1, 0);
+ set_conf (&options->WORDS_IN_PAGE, 300, 0);
+ set_conf (&options->XREF_USE_NODE_NAME_ARG, -1, 0);
+ set_conf (&options->XREF_USE_FLOAT_LABEL, 0, 0);
+ set_conf (&options->xrefautomaticsectiontitle, -2, "on");
+}
+
diff --git a/tp/Texinfo/XS/convert/converters_defaults.h
b/tp/Texinfo/XS/convert/converters_defaults.h
new file mode 100644
index 0000000000..6cdb21befa
--- /dev/null
+++ b/tp/Texinfo/XS/convert/converters_defaults.h
@@ -0,0 +1,17 @@
+#ifndef CONVERTERS_DEFAULTS_H
+#define CONVERTERS_DEFAULTS_H
+
+#include "main/option_types.h"
+
+/* Undefine values set from autoconf as we use these as
+ customization variable names. The original values are
+ available with a _CONFIG suffix, e.g. PACKAGE_CONFIG for
+ PACKAGE. */
+#undef PACKAGE
+#undef PACKAGE_NAME
+#undef PACKAGE_URL
+#undef PACKAGE_VERSION
+
+void set_html_regular_options_defaults (OPTIONS *options);
+
+#endif
diff --git a/tp/maintain/regenerate_C_options_info.pl
b/tp/maintain/regenerate_C_options_info.pl
index 029ecfaf28..129c4b763f 100755
--- a/tp/maintain/regenerate_C_options_info.pl
+++ b/tp/maintain/regenerate_C_options_info.pl
@@ -28,6 +28,8 @@ my %option_categories;
my %commands_options;
+my %options;
+
while (<STDIN>) {
if (not (/^#/ or /^ *$/)) {
if (/^([^ ]+) +([^ ]+) +([^ ]+) +(.+)$/) {
@@ -44,6 +46,7 @@ while (<STDIN>) {
if ($category eq 'multiple_at_command' or $category eq
'unique_at_command') {
$commands_options{$option} = [$category, $value, $type];
}
+ $options{$option} = [$category, $value, $type];
} else {
warn "ERROR: unexpected line: $_";
}
@@ -84,13 +87,56 @@ while (<ORDER>) {
#print STDERR "$command\n";
}
-my $code_file = $ARGV[1];
+my $converter_defaults_file = $ARGV[1];
+die "Need converter defaults file\n" if (!defined($converter_defaults_file));
+
+open(CDEF, $converter_defaults_file)
+ or die "open $converter_defaults_file: $!";
+
+my %converter_defaults;
+my $format;
+my $line = 1;
+while (<CDEF>) {
+ if (not (/^ *#/ or /^ *$/)) {
+ if (/^ *- *(\S+)/) {
+ $format = $1;
+ if (!defined($converter_defaults{$format})) {
+ $converter_defaults{$format} = [];
+ }
+ } elsif (defined($format)) {
+ if (/^ *([A-Za-z][A-Za-z0-9_]*)( +(.*))?$/) {
+ my $option = $1;
+ my $value = $3;
+ if (!defined($value) or $value =~ / +/) {
+ $value = '';
+ }
+ #print STDERR "$format|$variable|'$value'\n";
+ if (!defined($options{$option})) {
+ print STDERR "$converter_defaults_file: $line: unknown option
$option\n";
+ } else {
+ push @{$converter_defaults{$format}}, [$option, $value];
+ }
+ }
+ }
+ }
+ $line++;
+}
+
+my $code_file = $ARGV[2];
die "Need a code file\n" if (!defined($code_file));
-my $header_file = $ARGV[2];
+my $header_file = $ARGV[3];
die "Need a header file\n" if (!defined($header_file));
-my $get_file = $ARGV[3];
+my $converter_defaults_code_file = $ARGV[4];
+die "Need a converter code defaults file\n"
+ if (!defined($converter_defaults_code_file));
+
+my $converter_defaults_header_file = $ARGV[5];
+die "Need a converter header defaults file\n"
+ if (!defined($converter_defaults_header_file));
+
+my $get_file = $ARGV[6];
die "Need an XS code file\n" if (!defined($get_file));
my $program_name = basename($0);
@@ -239,6 +285,27 @@ print CODE "
# table of defaults for options corresponding to commands
print CODE "COMMAND_OPTION_DEFAULT command_option_default_table[] = {\n";
+sub get_value($$)
+{
+ my $type = shift;
+ my $value = shift;
+
+ my $char_value = 0;
+ my $int_value = '-2';
+ if ($type eq 'integer') {
+ $int_value = -1;
+ }
+ if ($value ne 'undef') {
+ if ($type eq 'integer') {
+ $int_value = $value;
+ } else {
+ $char_value = '"'.$value.'"';
+ }
+ }
+
+ return $int_value, $char_value;
+}
+
foreach my $command_name (@commands_order) {
my $command = $command_name;
if (exists($name_commands{$command_name})) {
@@ -247,18 +314,7 @@ foreach my $command_name (@commands_order) {
if ($commands_options{$command}) {
my ($category, $value, $type) = @{$commands_options{$command}};
#print STDERR "$command $category, $value, $type\n";
- my $char_value = 0;
- my $int_value = '-2';
- if ($type eq 'integer') {
- $int_value = -1;
- }
- if ($value ne 'undef') {
- if ($type eq 'integer') {
- $int_value = $value;
- } else {
- $char_value = '"'.$value.'"';
- }
- }
+ my ($int_value, $char_value) = get_value($type, $value);
print CODE "{GOT_$type, $int_value, $char_value}, /* $command
($category) */\n";
} else {
print CODE "{GOT_NONE, -2, 0},\n";
@@ -269,6 +325,56 @@ print CODE "};\n\n";
close(CODE);
+open(OCDEF, ">$converter_defaults_code_file")
+ or die "Open $converter_defaults_code_file: $!\n";
+
+print OCDEF "/* Automatically generated from $0 */\n\n";
+
+print OCDEF '#include <config.h>'."\n\n";
+
+print OCDEF '#include "options_types.h"'."\n";
+print OCDEF '#include "converter.h"'."\n";
+print OCDEF '#include "converters_defaults.h"'."\n\n";
+
+open(OHDEF, ">$converter_defaults_header_file")
+ or die "Open $converter_defaults_header_file: $!\n";
+
+print OHDEF "#ifndef CONVERTERS_DEFAULTS_H\n#define CONVERTERS_DEFAULTS_H\n\n";
+
+print OHDEF "#include \"main/option_types.h\"\n\n";
+
+print OHDEF "/* Undefine values set from autoconf as we use these as\n";
+print OHDEF " customization variable names. The original values are\n";
+print OHDEF " available with a _CONFIG suffix, e.g. PACKAGE_CONFIG for\n";
+print OHDEF " PACKAGE. */\n";
+print OHDEF "#undef PACKAGE\n";
+print OHDEF "#undef PACKAGE_NAME\n";
+print OHDEF "#undef PACKAGE_URL\n";
+print OHDEF "#undef PACKAGE_VERSION\n\n";
+
+my @sorted_formats = sort(keys(%converter_defaults));
+
+foreach my $format (@sorted_formats) {
+ my $fun = "void set_${format}_regular_options_defaults (OPTIONS *options)";
+
+ print OHDEF "$fun;\n\n";
+
+ print OCDEF "$fun\n{\n";
+ foreach my $option_spec (@{$converter_defaults{$format}}) {
+ my ($option, $value) = @$option_spec;
+ my $option_info = $options{$option};
+ my ($option_unused, $main_default, $type) = @$option_info;
+ my ($int_value, $char_value) = get_value($type, $value);
+ print OCDEF " set_conf (&options->${option}, $int_value, $char_value);\n";
+ }
+ print OCDEF "}\n\n";
+}
+
+close(OCDEF);
+
+print OHDEF "#endif\n";
+close(OHDEF);
+
open(GET, ">$get_file") or die "Open $get_file: $!\n";
print GET "/* Automatically generated from $program_name */\n\n";