texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Patrice Dumas
Date: Fri, 4 Oct 2024 20:02:11 -0400 (EDT)

branch: master
commit 450a6a31da0dc7a07457386581710a3d24a2a801
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 18 07:49:16 2024 +0200

    * tp/maintain/regenerate_C_options_info.pl: reorder code, add comments
    in output.  Pre-sort setup_sortable_options output.
---
 ChangeLog                                |   5 ++
 tp/maintain/regenerate_C_options_info.pl | 114 ++++++++++++++++---------------
 2 files changed, 63 insertions(+), 56 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1d481ee5c2..374c82fe9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-08-18  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/maintain/regenerate_C_options_info.pl: reorder code, add comments
+       in output.  Pre-sort setup_sortable_options output.
+
 2024-08-18  Patrice Dumas  <pertusus@free.fr>
 
        * tp/maintain/regenerate_C_options_info.pl: do not generate
diff --git a/tp/maintain/regenerate_C_options_info.pl 
b/tp/maintain/regenerate_C_options_info.pl
index 1afb02b16a..39ac28ed53 100755
--- a/tp/maintain/regenerate_C_options_info.pl
+++ b/tp/maintain/regenerate_C_options_info.pl
@@ -213,22 +213,6 @@ foreach my $category (sort(keys(%option_categories))) {
 
 print CODE "}\n\n";
 
-print CODE "OPTION **\nsetup_sortable_options (OPTIONS *options)\n{\n";
-print CODE "  OPTION **result = (OPTION **)\n"
-           ."    malloc (sizeof (OPTION *) * TXI_OPTIONS_NR);\n\n";
-my $index = 0;
-foreach my $category (sort(keys(%option_categories))) {
-  print CODE "\n/* ${category} */\n\n";
-  foreach my $option_info (@{$option_categories{$category}}) {
-    my ($option, $value, $type) = @$option_info;
-    print CODE "  result[$index] = &options->$option;\n";
-    $index++;
-  }
-}
-
-print CODE "\n  return result;\n"
-."}\n\n";
-
 print CODE "void\nfree_options (OPTIONS *options)\n{\n";
 foreach my $category (sort(keys(%option_categories))) {
   print CODE "\n/* ${category} */\n\n";
@@ -261,6 +245,64 @@ foreach my $category (sort(keys(%option_categories))) {
 }
 print CODE "}\n\n";
 
+my @sorted_options = sort(keys(%options));
+
+# returns an array of options ready to be sorted (and already sorted).
+print CODE "OPTION **\nsetup_sortable_options (OPTIONS *options)\n{\n";
+print CODE "  OPTION **result = (OPTION **)\n"
+           ."    malloc (sizeof (OPTION *) * TXI_OPTIONS_NR);\n\n";
+my $index = 0;
+foreach my $option (@sorted_options) {
+  my $option_info = $options{$option};
+  my ($category, $main_default, $type) = @$option_info;
+  print CODE "  result[$index] = &options->$option;   /* ${category} */\n";
+  $index++;
+}
+
+print CODE "\n  return result;\n"
+."}\n\n\n";
+
+# Static sorted options by name.  Can be used to find the number and type.
+# First define the internal OPTION structures, in a second step set the
+# array.  Could not find a way to do it in one step.
+print CODE "/* static OPTION structure pointers used as fields of sorted 
options just below */\n";
+my $option_nr = 0;
+foreach my $option (@sorted_options) {
+  $option_nr++;
+  my $option_info = $options{$option};
+  my ($category, $main_default, $type) = @$option_info;
+  print CODE "static OPTION _sorted_options_${option}_tmp = {GOT_${type}, 
\"$option\", $option_nr, 0, -1};  /* $category */\n";
+}
+
+print CODE "\n\n";
+
+print CODE "/* sorted options pointers array (for number and type, without 
values) */\n";
+print CODE "OPTION *${base_sorted_options_name}\[TXI_OPTIONS_NR\] = {\n";
+foreach my $option (@sorted_options) {
+  $option_nr++;
+  my $option_info = $options{$option};
+  my ($category, $main_default, $type) = @$option_info;
+  #print CODE "{GOT_${type}, \"$option\", $option_nr, 0, -1},  /* $category 
*/\n";
+  print CODE "&_sorted_options_${option}_tmp,\n";
+}
+print CODE "};\n\n";
+
+# call function to fill options directions for all the buttons options
+print CODE 'void
+html_fill_options_directions (OPTIONS *options, const CONVERTER *converter)
+{
+';
+foreach my $category (sort(keys(%option_categories))) {
+  foreach my $option_info (@{$option_categories{$category}}) {
+    my ($option, $value, $type) = @$option_info;
+    if ($type eq 'buttons') {
+      print CODE "  if (options->$option.o.buttons)\n"
+                ."    html_fill_button_directions_specification_list 
(converter, options->$option.o.buttons);\n\n";
+    }
+  }
+}
+print CODE "}\n\n";
+
 
 # associate commands to options
 print CODE "#include \"command_ids.h\"\n\n";
@@ -293,23 +335,6 @@ print CODE "
     }
 }\n\n";
 
-print CODE 'void
-html_fill_options_directions (OPTIONS *options, const CONVERTER *converter)
-{
-';
-foreach my $category (sort(keys(%option_categories))) {
-  foreach my $option_info (@{$option_categories{$category}}) {
-    my ($option, $value, $type) = @$option_info;
-    if ($type eq 'buttons') {
-      print CODE "  if (options->$option.o.buttons)\n"
-                ."    html_fill_button_directions_specification_list 
(converter, options->$option.o.buttons);\n\n";
-    }
-  }
-}
-print CODE '}
-
-';
-
 # table of defaults for options corresponding to commands
 print CODE "COMMAND_OPTION_DEFAULT command_option_default_table[] = {\n";
 
@@ -353,29 +378,6 @@ foreach my $command_name (@commands_order) {
 
 print CODE "};\n\n";
 
-# Sorted options by name.  Can be used to find the number and type.
-# First define the internal OPTION structures, in a second step set the
-# array.  Could not find a way to do it in one step.
-my $option_nr = 0;
-foreach my $option (sort(keys(%options))) {
-  $option_nr++;
-  my $option_info = $options{$option};
-  my ($category, $main_default, $type) = @$option_info;
-  print CODE "static OPTION _sorted_options_${option}_tmp = {GOT_${type}, 
\"$option\", $option_nr, 0, -1};  /* $category */\n";
-}
-
-print CODE "\n\n";
-
-print CODE "OPTION *${base_sorted_options_name}\[TXI_OPTIONS_NR\] = {\n";
-foreach my $option (sort(keys(%options))) {
-  $option_nr++;
-  my $option_info = $options{$option};
-  my ($category, $main_default, $type) = @$option_info;
-  #print CODE "{GOT_${type}, \"$option\", $option_nr, 0, -1},  /* $category 
*/\n";
-  print CODE "&_sorted_options_${option}_tmp,\n";
-}
-print CODE "};\n\n";
-
 close(CODE);
 
 open(OCDEF, ">$converter_defaults_code_file")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]