[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 1 Oct 2024 17:28:17 -0400 (EDT) |
branch: master
commit eb502adcad0eade5d8190c3d90cb30b66c9c98c5
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jul 29 21:50:16 2024 +0200
* tp/Texinfo/XS/Makefile.am (main/conversion_data.c),
maintain/generate_code_convert_data.pl: read C commands data on STDIN.
Generate default_translated_directions_strings and
html_style_commands_element C data.
* tp/Makefile.am (Texinfo/Data.pm): reformat.
---
ChangeLog | 9 +++
tp/Makefile.am | 7 +-
tp/Texinfo/XS/Makefile.am | 15 ++--
tp/maintain/generate_code_convert_data.pl | 111 ++++++++++++++++++++++++++++--
4 files changed, 130 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b5f229afc6..b0591f6208 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-07-29 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/Makefile.am (main/conversion_data.c),
+ maintain/generate_code_convert_data.pl: read C commands data on STDIN.
+ Generate default_translated_directions_strings and
+ html_style_commands_element C data.
+
+ * tp/Makefile.am (Texinfo/Data.pm): reformat.
+
2024-07-29 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Data/default_direction_strings.csv,
diff --git a/tp/Makefile.am b/tp/Makefile.am
index 87bf6deb0c..4fe28ecead 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -386,7 +386,12 @@ $(srcdir)/Texinfo/Options.pm: Texinfo/options_data.txt
$(srcdir)/maintain/regene
$(srcdir)/maintain/regenerate_perl_options_info.pl
$(srcdir)/Texinfo/Options.pm < $(srcdir)/Texinfo/options_data.txt
$(srcdir)/Texinfo/Data.pm: Texinfo/Data/default_css_element_class_styles.csv
Texinfo/Data/default_direction_strings.csv
Texinfo/Data/default_special_unit_info.csv
Texinfo/Data/html_style_commands_element.csv
$(srcdir)/maintain/generate_code_convert_data.pl
- $(srcdir)/maintain/generate_code_convert_data.pl
$(srcdir)/Texinfo/Data/default_css_element_class_styles.csv
$(srcdir)/Texinfo/Data/default_direction_strings.csv
$(srcdir)/Texinfo/Data/default_special_unit_info.csv
$(srcdir)/Texinfo/Data/html_style_commands_element.csv perl $@
+ $(srcdir)/maintain/generate_code_convert_data.pl \
+ $(srcdir)/Texinfo/Data/default_css_element_class_styles.csv \
+ $(srcdir)/Texinfo/Data/default_direction_strings.csv \
+ $(srcdir)/Texinfo/Data/default_special_unit_info.csv \
+ $(srcdir)/Texinfo/Data/html_style_commands_element.csv \
+ perl $@
libsrcdir = $(srcdir)/maintain/lib
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 615c213371..2c3224d365 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -306,14 +306,15 @@ $(srcdir)/main/options_init_free.c
$(srcdir)/main/options_types.h $(srcdir)/main
MAINTAINERCLEANFILES += main/options_init_free.c main/options_types.h \
main/options_get_perl.c
-$(srcdir)/main/conversion_data.c $(srcdir)/main/conversion_data.h:
$(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
+$(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 \
- $(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 \
- C $(srcdir)/main/conversion_data.c \
- $(srcdir)/main/conversion_data.h
+ < $(srcdir)/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 \
+ C $(srcdir)/main/conversion_data.c \
+ $(srcdir)/main/conversion_data.h
MAINTAINERCLEANFILES += main/conversion_data.c main/conversion_data.h
diff --git a/tp/maintain/generate_code_convert_data.pl
b/tp/maintain/generate_code_convert_data.pl
index eb9b306967..b8e91db8b0 100755
--- a/tp/maintain/generate_code_convert_data.pl
+++ b/tp/maintain/generate_code_convert_data.pl
@@ -162,6 +162,11 @@ if ($perl_format) {
print HDR "/* Automatically generated from $program_name */\n\n";
print HDR "#ifndef $C_header_string\n"
."#define $C_header_string\n\n";
+ print HDR 'typedef struct HTML_DEFAULT_DIRECTION_STRING_TRANSLATED {'."\n"
+ .' const char *converted;'."\n"
+ .' const char *to_convert;'."\n"
+ .'} HTML_DEFAULT_DIRECTION_STRING_TRANSLATED;'."\n\n";
+
}
@@ -235,6 +240,7 @@ if ($C_format) {
# gather for direction structures below
my %su_directions;
+my @ordered_su_directions;
my @su_ordered;
while (<DSUI>) {
chomp;
@@ -248,6 +254,7 @@ while (<DSUI>) {
$value = $data[$index];
if ($untranslated_type eq 'direction') {
$su_directions{$value} = 1;
+ push @ordered_su_directions, $value;
}
}
if ($perl_format) {
@@ -428,13 +435,11 @@ if ($C_format) {
print OUT "const char *direction_type_translation_context[] = {\n";
foreach my $type (@d_ordered_translated_hashes) {
- print OUT '"'.$type_contexts_map{$type}.'", '."\n";
+ print OUT '"'.$type_contexts_map{$type}.'", '."/* $type */\n";
}
print OUT "};\n\n";
}
-my @relative_directions_order;
-my @file_directions_order;
while (<DDS>) {
chomp;
my @data = split (/\|/);
@@ -457,7 +462,7 @@ while (<DDS>) {
$hash_lines{$untranslated_type} .= " '$direction' => '$value',\n";
} else {
if ($value ne '') {
- $hash_values{$untranslated_type}->{$direction} = {'untranslated' =>
$value};
+ $hash_values{$untranslated_type}->{$direction} = $value;
}
}
}
@@ -498,6 +503,9 @@ while (<DDS>) {
}
}
+my @ordered_directions = (@{$direction_orders{'global'}},
@{$direction_orders{'relative'}},
+ @{$direction_orders{'file'}},
@ordered_su_directions);
+
if ($perl_format) {
print OUT 'sub get_directions_order() {'."\n"
. 'return [';
@@ -561,6 +569,50 @@ if ($perl_format) {
.$direction_orders{'relative'}[0]."\n";
print HDR "#define FIRSTINFILE_MAX_IDX D_direction_FirstInFile"
.$direction_orders{'relative'}[-1]."\n\n";
+
+ my $nr_string_directions = scalar(@ordered_directions);
+ print OUT "const char * const default_converted_directions_strings[]["
+ ."$nr_string_directions] = {\n";
+ foreach my $type (@d_ordered_untranslated_hashes) {
+ print OUT " { /* $type */\n";
+ foreach my $direction (@ordered_directions) {
+ print OUT ' ';
+ if ($hash_values{$type} and $hash_values{$type}->{$direction}) {
+ print OUT '"'.$hash_values{$type}->{$direction}.'",';
+ } else {
+ print OUT '0,';
+ }
+ print OUT " /* $direction */\n";
+ }
+ print OUT " },\n";
+ }
+ print OUT "};\n\n";
+
+ print OUT "const HTML_DEFAULT_DIRECTION_STRING_TRANSLATED "
+ ."default_translated_directions_strings[][$nr_string_directions] = {\n";
+ foreach my $type (@d_ordered_translated_hashes) {
+ print OUT " { /* $type */\n";
+ foreach my $direction (@ordered_directions) {
+ if ($hash_values{$type} and $hash_values{$type}->{$direction}) {
+ print OUT ' {';
+ if (defined($hash_values{$type}->{$direction}->{'converted'})) {
+ print OUT '"'.$hash_values{$type}->{$direction}->{'converted'}.'",
0';
+ } else {
+ my $to_convert = $hash_values{$type}->{$direction};
+ my $context = $to_convert->{'context'};
+ my $string = $to_convert->{'string'};
+ my $value = "pgdt_noop(\"$context\", \"$string\")";
+ print OUT "0, $value";
+ }
+ print OUT '},';
+ } else {
+ print OUT ' {0, 0},';
+ }
+ print OUT " /* $direction */\n";
+ }
+ print OUT " },\n";
+ }
+ print OUT "};\n\n";
}
my $sce_header_line = <SCE>;
@@ -589,6 +641,7 @@ if ($perl_format) {
print OUT "my %html_style_commands_element = (\n";
}
+my %command_element;
my $line_nr = 1;
while (<SCE>) {
$line_nr++;
@@ -612,6 +665,8 @@ while (<SCE>) {
}
if ($perl_format) {
print OUT " '$sce_command' => '$sce_html_element',\n";
+ } else {
+ $command_element{$sce_command} = $sce_html_element;
}
}
@@ -624,6 +679,54 @@ if ($perl_format) {
print OUT "1;\n";
} else {
+ print HDR "extern const char *html_style_commands_element[];\n\n";
+
print HDR "#endif\n";
+
+ my @commands_order = ('');
+
+ my %commands_map = (
+ '\\t' => "\t",
+ '\\n' => "\n",
+ '\\x20' => ' ',
+ '\"' => '"',
+ '\\\\' => '\\',
+ );
+
+ my %name_commands;
+ while (<STDIN>) {
+ my $command;
+ if (/^"([^"]+?)", /) {
+ $command = $1;
+ } elsif (/^"\\"", /) {
+ $command = '\"';
+ }
+ next if (!defined($command));
+ my $command_name = $command;
+ if (exists $commands_map{$command}) {
+ $command_name = $commands_map{$command};
+ $name_commands{$command_name} = $command;
+ }
+ push @commands_order, $command_name;
+ print STDERR "$command\n";
+ }
+
+ if ($C_format) {
+ print OUT "const char *html_style_commands_element[] = {\n";
+ foreach my $command_name (@commands_order) {
+ my $command = $command_name;
+ if (exists($name_commands{$command_name})) {
+ $command = $name_commands{$command_name};
+ }
+
+ if (exists($command_element{$command})) {
+ print OUT "\"$command_element{$command}\", /* $command */\n";
+ } else {
+ print OUT "0,\n";
+ }
+ }
+ print OUT "};\n\n";
+ }
}
+close(OUT);