texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Wed, 2 Oct 2024 16:14:31 -0400 (EDT)

branch: master
commit f2f531ca6e8004f6018dc22eff1cba4ebfa37d4b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 4 09:40:49 2024 +0200

    * tp/Texinfo/XS/main/api_to_perl.c (register_perl_data),
    tp/Texinfo/XS/main/utils.c (copy_option): copy icon sv.
    
    * tp/Texinfo/XS/main/option_types.h (OPTIONS_LIST),
    tp/Texinfo/XS/main/utils.c (free_options_list)
    (copy_options_list_options): add OPTIONS_LIST, and associated
    functions, free_options_list and copy_options_list_options.
    
    * tp/Texinfo/XS/main/get_perl_info.c (get_sv_option): handle options
    unset.  It could happen, for example, if the information gotten is a
    separate option information not (already) associated to an OPTIONS
    structure, for example passing through a OPTIONS_LIST.
    
    * tp/Texinfo/XS/main/converter_types.h (CONVERTER_DEFAULTS_INFO),
    tp/Texinfo/XS/convert/converter.c (new_converter_defaults_info)
    (new_converter_defaults_info), tp/Texinfo/XS/main/get_perl_info.c
    (get_converter_defaults_from_sv): add CONVERTER_DEFAULTS_INFO, a
    structure holding information that can be passed as information for
    converter, with options, format names and translated commands.  Add
    get_converter_defaults_from_sv to set it from Perl data.
    
    * tp/Texinfo/XS/main/get_perl_info.c (set_translated_commands):
    pass a SV and returns a newly allocated TRANSLATED_COMMAND.
    
    * tp/Texinfo/XS/main/get_perl_info.c (get_option_from_sv): setup an
    OPTION based on a SV and an option name.
    
    * tp/Texinfo/XS/convert/ConvertXS.xs (converter_initialize),
    tp/Texinfo/XS/convert/converter.c (apply_converter_defaults)
    (fill_converter_conf), tp/Texinfo/XS/main/get_perl_info.c
    (set_non_customization_sv, converter_get_defaults_sv): get information
    on format defaults and user customization in a separate function,
    converter_get_defaults_sv.  Then set them in the C converter with
    fill_converter_conf.  Remove converter_initialize_sv.
---
 ChangeLog                                       |  37 ++++++
 tp/Texinfo/XS/convert/ConvertXS.xs              |  15 ++-
 tp/Texinfo/XS/convert/convert_html.c            |   2 +-
 tp/Texinfo/XS/convert/converter.c               |  78 ++++++++++-
 tp/Texinfo/XS/convert/converter.h               |   7 +
 tp/Texinfo/XS/convert/get_converter_perl_info.c |  29 ++--
 tp/Texinfo/XS/convert/get_converter_perl_info.h |   4 +
 tp/Texinfo/XS/main/api_to_perl.c                |   6 +
 tp/Texinfo/XS/main/api_to_perl.h                |   1 +
 tp/Texinfo/XS/main/converter_types.h            |  12 ++
 tp/Texinfo/XS/main/get_perl_info.c              | 170 ++++++++++++++++++++++--
 tp/Texinfo/XS/main/get_perl_info.h              |   6 +-
 tp/Texinfo/XS/main/option_types.h               |   5 +
 tp/Texinfo/XS/main/utils.c                      |  44 ++++++
 tp/Texinfo/XS/main/utils.h                      |   3 +
 15 files changed, 392 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3836e8797f..a6cf7a7917 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+2024-08-04  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/api_to_perl.c (register_perl_data),
+       tp/Texinfo/XS/main/utils.c (copy_option): copy icon sv.
+
+       * tp/Texinfo/XS/main/option_types.h (OPTIONS_LIST),
+       tp/Texinfo/XS/main/utils.c (free_options_list)
+       (copy_options_list_options): add OPTIONS_LIST, and associated
+       functions, free_options_list and copy_options_list_options.
+
+       * tp/Texinfo/XS/main/get_perl_info.c (get_sv_option): handle options
+       unset.  It could happen, for example, if the information gotten is a
+       separate option information not (already) associated to an OPTIONS
+       structure, for example passing through a OPTIONS_LIST.
+
+       * tp/Texinfo/XS/main/converter_types.h (CONVERTER_DEFAULTS_INFO),
+       tp/Texinfo/XS/convert/converter.c (new_converter_defaults_info)
+       (new_converter_defaults_info), tp/Texinfo/XS/main/get_perl_info.c
+       (get_converter_defaults_from_sv): add CONVERTER_DEFAULTS_INFO, a
+       structure holding information that can be passed as information for
+       converter, with options, format names and translated commands.  Add
+       get_converter_defaults_from_sv to set it from Perl data.
+
+       * tp/Texinfo/XS/main/get_perl_info.c (set_translated_commands):
+       pass a SV and returns a newly allocated TRANSLATED_COMMAND.
+
+       * tp/Texinfo/XS/main/get_perl_info.c (get_option_from_sv): setup an
+       OPTION based on a SV and an option name.
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (converter_initialize),
+       tp/Texinfo/XS/convert/converter.c (apply_converter_defaults)
+       (fill_converter_conf), tp/Texinfo/XS/main/get_perl_info.c
+       (set_non_customization_sv, converter_get_defaults_sv): get information
+       on format defaults and user customization in a separate function,
+       converter_get_defaults_sv.  Then set them in the C converter with
+       fill_converter_conf.  Remove converter_initialize_sv.
+
 2024-08-03  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/get_perl_info.h: remove get_options_key_sv_option
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 6980124e08..50afd7afe4 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -90,15 +90,26 @@ init (int texinfo_uninstalled, SV *pkgdatadir_sv, SV 
*tp_builddir_sv, SV *top_sr
         RETVAL
 
 void
-converter_initialize (SV *converter_in, const char *class, SV 
*format_defaults, SV *conf=0)
+converter_initialize (SV *converter_in, const char *class, SV 
*format_defaults_sv, SV *conf_sv=0)
       PREINIT:
          size_t converter_descriptor;
          CONVERTER *self;
+         CONVERTER_DEFAULTS_INFO *format_defaults;
+         CONVERTER_DEFAULTS_INFO *conf;
       CODE:
          converter_descriptor = new_converter ();
          self = retrieve_converter (converter_descriptor);
 
-         converter_initialize_sv (converter_in, self, format_defaults, conf);
+         format_defaults = new_converter_defaults_info ();
+         conf = new_converter_defaults_info ();
+
+         converter_get_defaults_sv (converter_in, self, format_defaults_sv,
+                                    conf_sv, format_defaults, conf);
+
+         fill_converter_conf (self, format_defaults, conf);
+
+         free_converter_defaults_info (format_defaults);
+         free_converter_defaults_info (conf);
 
          pass_generic_converter_to_converter_sv (converter_in, self);
 
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index f7c0b682a3..fee865c88b 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -18242,7 +18242,7 @@ html_converter_initialize (CONVERTER *self)
         + external_formatting_function;
 
    /*
-  fprintf (stderr, "TOTAL: %d. conf %d fi %d sbf %d ouc %d cc %d co %d tc %d 
to %d f %d\n",
+  fprintf (stderr, "TOTAL: %d. conf %zu fi %d sbf %d ouc %d cc %d co %d tc %d 
to %d f %d\n",
            self->external_references_number,
            self->conf->BIT_user_function_number,
            self->file_id_setting_ref_number,
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 38aa5aa61c..fc89857cbf 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -211,7 +211,6 @@ init_generic_converter (CONVERTER *self)
 
   self->translated_commands[0].cmd = CM_error;
   self->translated_commands[0].translation = strdup ("error@arrow{}");
-
 }
 
 /* descriptor starts at 1, 0 is not found or an error */
@@ -258,6 +257,83 @@ new_converter (void)
   return converter_index +1;
 }
 
+static void
+apply_converter_defaults (CONVERTER *converter,
+                        CONVERTER_DEFAULTS_INFO *defaults, int set_configured)
+{
+  copy_options_list_options (converter->conf, converter->sorted_options,
+                             &defaults->conf, set_configured);
+
+  if (defaults->output_format)
+    {
+      free (converter->output_format);
+      converter->output_format = strdup (defaults->output_format);
+    }
+  if (defaults->converted_format)
+    {
+      free (converter->converted_format);
+      converter->converted_format = strdup (defaults->converted_format);
+    }
+
+  if (defaults->translated_commands)
+    {
+      destroy_translated_commands (converter->translated_commands);
+      converter->translated_commands = defaults->translated_commands;
+      defaults->translated_commands = 0;
+    }
+}
+
+void
+fill_converter_conf (CONVERTER *converter,
+                     CONVERTER_DEFAULTS_INFO *format_defaults,
+                     CONVERTER_DEFAULTS_INFO *user_conf)
+{
+  apply_converter_defaults (converter, format_defaults, 0);
+
+  apply_converter_defaults (converter, user_conf, 1);
+
+  /* in Perl sets converter_init_conf, but in C we use only one
+     structure for converter_init_conf and output_init_conf, which
+     is overwritten to set the similar values as output_init_conf
+     in specific converters.
+   */
+  copy_options (converter->init_conf, converter->conf);
+
+  set_expanded_formats_from_options (converter->expanded_formats,
+                                     converter->conf);
+
+  /*
+  fprintf (stderr, "XS|CONVERTER Fill conf: %d; %s, %s\n",
+                   converter->converter_descriptor,
+                   converter->output_format,
+                   converter->converted_format);
+   */
+
+}
+
+CONVERTER_DEFAULTS_INFO *
+new_converter_defaults_info (void)
+{
+  CONVERTER_DEFAULTS_INFO *result = (CONVERTER_DEFAULTS_INFO *)
+     malloc (sizeof (CONVERTER_DEFAULTS_INFO));
+  memset (result, 0, sizeof (CONVERTER_DEFAULTS_INFO));
+  return result;
+}
+
+void
+free_converter_defaults_info (CONVERTER_DEFAULTS_INFO *defaults)
+{
+  if (defaults->translated_commands)
+    destroy_translated_commands (defaults->translated_commands);
+
+  free (defaults->converted_format);
+  free (defaults->output_format);
+
+  free_options_list (&defaults->conf);
+
+  free_strings_list (&defaults->non_valid_customization);
+}
+
 void
 unregister_converter_descriptor (int converter_descriptor)
 {
diff --git a/tp/Texinfo/XS/convert/converter.h 
b/tp/Texinfo/XS/convert/converter.h
index 60783dd18e..1582a52254 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -112,6 +112,13 @@ CONVERTER *retrieve_converter (int converter_descriptor);
 size_t new_converter (void);
 void unregister_converter_descriptor (int converter_descriptor);
 
+void fill_converter_conf (CONVERTER *converter,
+                          CONVERTER_DEFAULTS_INFO *format_defaults,
+                          CONVERTER_DEFAULTS_INFO *user_conf);
+
+CONVERTER_DEFAULTS_INFO *new_converter_defaults_info (void);
+void free_converter_defaults_info (CONVERTER_DEFAULTS_INFO *defaults);
+
 void converter_set_document (CONVERTER *converter, DOCUMENT *document);
 
 int set_conf (OPTION *option, int int_value, const char *char_value);
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.c 
b/tp/Texinfo/XS/convert/get_converter_perl_info.c
index 1d8fce947f..3a56816d90 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.c
@@ -85,32 +85,32 @@ converter_set_document_from_sv (SV *converter_in, SV 
*document_in)
   return converter;
 }
 
-void
-set_translated_commands (CONVERTER *converter, HV *hv_in)
+TRANSLATED_COMMAND *
+set_translated_commands (SV *translated_commands_sv)
 {
-  SV **translated_commands_sv;
+  TRANSLATED_COMMAND *translated_commands = 0;
 
   dTHX;
 
-  translated_commands_sv = hv_fetch (hv_in, "translated_commands",
-                                     strlen ("translated_commands"), 0);
-
   if (translated_commands_sv)
     {
+      HV *translated_commands_hv = 0;
       I32 hv_number;
       I32 i;
 
-      HV *translated_commands_hv
-        = (HV *)SvRV (*translated_commands_sv);
-
-      hv_number = hv_iterinit (translated_commands_hv);
+      if (!SvOK (translated_commands_sv))
+        hv_number = 0;
+      else
+        {
+          HV *translated_commands_hv
+            = (HV *)SvRV (translated_commands_sv);
 
-      if (converter->translated_commands)
-        destroy_translated_commands (converter->translated_commands);
+          hv_number = hv_iterinit (translated_commands_hv);
+        }
 
-      converter->translated_commands = (TRANSLATED_COMMAND *)
+      translated_commands = (TRANSLATED_COMMAND *)
         malloc ((hv_number +1) * sizeof (TRANSLATED_COMMAND));
-      memset (converter->translated_commands, 0,
+      memset (translated_commands, 0,
               (hv_number +1) * sizeof (TRANSLATED_COMMAND));
 
       for (i = 0; i < hv_number; i++)
@@ -136,6 +136,7 @@ set_translated_commands (CONVERTER *converter, HV *hv_in)
             }
         }
     }
+  return translated_commands;
 }
 
 void
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.h 
b/tp/Texinfo/XS/convert/get_converter_perl_info.h
index 1a540318f8..0d872cc5e7 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.h
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.h
@@ -14,6 +14,10 @@ void converter_initialize_sv (SV *converter_sv, CONVERTER 
*converter,
                               SV *format_defaults, SV *conf);
 CONVERTER *converter_set_document_from_sv (SV *converter_in, SV *document_in);
 
+TRANSLATED_COMMAND *set_translated_commands (SV *translated_commands_sv);
+CONVERTER *get_sv_converter (SV *sv_in, const char *warn_string);
+CONVERTER *converter_set_document_from_sv (SV *converter_in, SV *document_in);
+
 struct TEXT_OPTIONS *copy_sv_options_for_convert_text (SV *sv_in);
 
 #endif
diff --git a/tp/Texinfo/XS/main/api_to_perl.c b/tp/Texinfo/XS/main/api_to_perl.c
index 29d8b47fd8..fd2887973a 100644
--- a/tp/Texinfo/XS/main/api_to_perl.c
+++ b/tp/Texinfo/XS/main/api_to_perl.c
@@ -106,6 +106,12 @@ unregister_perl_direction_icons (DIRECTION_ICON_LIST 
*direction_icons)
     SvREFCNT_dec (direction_icons->sv);
 }
 
+void
+register_perl_data (void *sv)
+{
+  SvREFCNT_inc (sv);
+}
+
 char *
 get_perl_scalar_reference_value (const void *sv_string)
 {
diff --git a/tp/Texinfo/XS/main/api_to_perl.h b/tp/Texinfo/XS/main/api_to_perl.h
index 611e5eeb70..8ddbaf44bb 100644
--- a/tp/Texinfo/XS/main/api_to_perl.h
+++ b/tp/Texinfo/XS/main/api_to_perl.h
@@ -14,6 +14,7 @@ void unregister_perl_button (BUTTON_SPECIFICATION *button);
 void register_perl_button (BUTTON_SPECIFICATION *button);
 void unregister_perl_direction_icons (DIRECTION_ICON_LIST *direction_icons);
 void unregister_document_hv (DOCUMENT *document);
+void register_perl_data (void *sv);
 /* HTML specific */
 void unregister_html_converter_perl_hv (CONVERTER *converter);
 
diff --git a/tp/Texinfo/XS/main/converter_types.h 
b/tp/Texinfo/XS/main/converter_types.h
index 9263d2e8ee..6748c4714a 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -26,6 +26,7 @@
 #include "command_ids.h"
 #include "tree_types.h"
 #include "document_types.h"
+#include "option_types.h"
 #include "options_types.h"
 
 /* for interdependency with convert_to_text.h */
@@ -917,6 +918,17 @@ typedef struct CONVERTER {
     void *pl_info_hv; /* converter->{'converter_info'} */
 } CONVERTER;
 
+/* information on converter defaults from a source of configuration
+   (either output format or user customization) */
+typedef struct CONVERTER_DEFAULTS_INFO {
+    char *converted_format;
+    char *output_format;
+    TRANSLATED_COMMAND *translated_commands;
+    OPTIONS_LIST conf;
+    /* gather strings that are not customization options */
+    STRING_LIST non_valid_customization;
+} CONVERTER_DEFAULTS_INFO;
+
 typedef struct TRANSLATED_SUI_ASSOCIATION {
     enum special_unit_info_tree tree_type;
     enum special_unit_info_type string_type;
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index 6c4abbfe64..ad6de751e6 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -399,11 +399,11 @@ get_sv_option (OPTION *option, SV *value, int force,
         if (SvOK (value))
           {
             if (looks_like_number (value))
-            option->o.integer = SvIV (value);
-        else
-          {
-            fprintf (stderr, "BUG: %s: not an integer: %s\n",
-                     option->name, SvPVutf8_nolen (value));
+              option->o.integer = SvIV (value);
+          else
+            {
+              fprintf (stderr, "BUG: %s: not an integer: %s\n",
+                       option->name, SvPVutf8_nolen (value));
               option->o.integer = -1;
               return -3;
             }
@@ -447,14 +447,15 @@ get_sv_option (OPTION *option, SV *value, int force,
       case GOT_buttons:
         if (option->o.buttons)
           {
-            options->BIT_user_function_number
-               -= option->o.buttons->BIT_user_function_number;
+            if (options)
+              options->BIT_user_function_number
+                -= option->o.buttons->BIT_user_function_number;
             html_free_button_specification_list (option->o.buttons);
           }
 
         option->o.buttons
            = html_get_button_specification_list (converter, value);
-        if (option->o.buttons)
+        if (option->o.buttons && options)
           options->BIT_user_function_number
             += option->o.buttons->BIT_user_function_number;
         break;
@@ -527,6 +528,159 @@ init_copy_sv_options (SV *sv_in, CONVERTER *converter, 
int force,
   return options;
 }
 
+/* OPTION should be already allocated but otherwise set to 0 */
+static int
+get_option_from_sv (OPTION *option, SV *option_sv, CONVERTER *converter,
+                    OPTION **sorted_options, const char *option_name)
+{
+  int status;
+
+  const OPTION *ref_option = find_option_string (sorted_options, option_name);
+  if (!ref_option)
+    return -2;
+
+  initialize_option (option, ref_option->type, ref_option->name);
+  option->number = ref_option->number;
+
+  status = get_sv_option (option, option_sv, 0, 0, converter);
+
+  return status;
+}
+
+static int
+get_converter_defaults_from_sv (SV *conf_sv, CONVERTER *converter,
+                                OPTION **sorted_options,
+                                CONVERTER_DEFAULTS_INFO *defaults_info)
+{
+  dTHX;
+
+  if (conf_sv && SvOK (conf_sv))
+    {
+      I32 hv_number;
+      I32 i;
+
+      HV *conf_hv = (HV *)SvRV (conf_sv);
+
+      hv_number = hv_iterinit (conf_hv);
+
+      if (!hv_number)
+        return 0;
+
+      defaults_info->conf.list
+        = (OPTION *) malloc (sizeof (OPTION) * hv_number);
+      memset (defaults_info->conf.list, 0, sizeof (OPTION) * hv_number);
+
+      for (i = 0; i < hv_number; i++)
+        {
+          OPTION *option = 
&defaults_info->conf.list[defaults_info->conf.number];
+          char *key;
+          I32 retlen;
+          SV *value = hv_iternextsv (conf_hv, &key, &retlen);
+          int status = get_option_from_sv (option, value, converter,
+                                           sorted_options, key);
+          if (!status)
+            {
+              defaults_info->conf.number++;
+            }
+          else
+            {
+              memset (option, 0, sizeof (OPTION));
+              if (status == -2)
+                {
+                  add_string (key, &defaults_info->non_valid_customization);
+
+                  if (!strcmp (key, "translated_commands"))
+                    defaults_info->translated_commands
+                      = set_translated_commands (value);
+                  else if (!strcmp (key, "output_format"))
+                    defaults_info->output_format
+                      = non_perl_strdup (SvPVutf8_nolen (value));
+                  else if (!strcmp (key, "converted_format"))
+                    defaults_info->converted_format
+                      = non_perl_strdup (SvPVutf8_nolen (value));
+         /* TODO in defaults here means in format_defaults or
+            non customization variable
+            in Texinfo::Convert::Converter::common_converters_defaults
+      } elsif (!exists($defaults{$key})) {
+        warn "$key not a possible configuration in $class\n";
+          */
+                }
+              else
+                fprintf (stderr, "ERROR: %s unexpected conf error\n", key);
+            }
+        }
+      return 1;
+    }
+  return 0;
+}
+
+static void
+set_non_customization_sv (HV *converter_hv, SV *defaults_sv,
+                          STRING_LIST *non_valid_customization)
+{
+  dTHX;
+
+  if (non_valid_customization->number > 0)
+    {
+      HV *defaults_hv = (HV *) SvRV (defaults_sv);
+      size_t i;
+      for (i = 0; i < non_valid_customization->number; i++)
+        {
+          const char *key
+               = non_valid_customization->list[i];
+          /* not a customization variable, set in converter */
+          SV **value = hv_fetch (defaults_hv, key, strlen (key), 0);
+          if (*value)
+            {
+              if (SvOK (*value))
+                SvREFCNT_inc (*value);
+              hv_store (converter_hv, key, strlen (key), *value, 0);
+            }
+        }
+    }
+}
+
+/* Texinfo::Convert::Converter generic initialization for all the converters */
+/* Called early, in particuliar before any format specific code has been
+   called */
+int
+converter_get_defaults_sv (SV *converter_sv, CONVERTER *converter,
+                         SV *format_defaults_sv, SV *conf_sv,
+                         CONVERTER_DEFAULTS_INFO *format_defaults,
+                         CONVERTER_DEFAULTS_INFO *conf)
+{
+  HV *converter_hv;
+  int has_format_defaults;
+  int has_conf;
+
+  dTHX;
+
+  converter_hv = (HV *)SvRV (converter_sv);
+
+  converter->hv = converter_hv;
+
+  has_format_defaults
+    = get_converter_defaults_from_sv (format_defaults_sv, converter,
+                              converter->sorted_options, format_defaults);
+
+  has_conf = get_converter_defaults_from_sv (conf_sv, converter,
+                               converter->sorted_options, conf);
+
+  set_non_customization_sv (converter_hv, format_defaults_sv,
+                            &format_defaults->non_valid_customization);
+
+  set_non_customization_sv (converter_hv, conf_sv,
+                            &conf->non_valid_customization);
+
+   /*
+  fprintf (stderr, "XS|CONVERTER Init from SV: %d; %d %d\n",
+                   converter->converter_descriptor, has_format_defaults,
+                   has_conf);
+    */
+
+  return has_format_defaults + has_conf;
+}
+
 INDEX_ENTRY *
 find_index_entry_sv (const SV *index_entry_sv, INDEX_LIST *indices_info,
                      const char *warn_string, const INDEX **entry_idx,
diff --git a/tp/Texinfo/XS/main/get_perl_info.h 
b/tp/Texinfo/XS/main/get_perl_info.h
index b091800128..7c351b6565 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -17,7 +17,6 @@ void html_fill_options (OPTIONS *options, const CONVERTER 
*converter);
 
 void get_sv_options (SV *sv, OPTIONS *options, OPTION **sorted_options,
                      CONVERTER *converter, int force);
-void set_translated_commands (CONVERTER *converter, HV *hv_in);
 int get_sorted_options_key_sv_option (OPTIONS *options, OPTION 
**sorted_options,
                                       const char *key, SV *value,
                                       int force, const CONVERTER *converter);
@@ -43,6 +42,11 @@ OPTIONS *init_copy_sv_options (SV *sv_in, CONVERTER 
*converter, int force,
 int set_sv_conf (CONVERTER *converter, const char *conf, SV *value);
 void force_sv_conf (CONVERTER *converter, const char *conf, SV *value);
 
+int converter_get_defaults_sv (SV *converter_sv, CONVERTER *converter,
+                              SV *format_defaults_sv, SV *conf_sv,
+                              CONVERTER_DEFAULTS_INFO *format_defaults,
+                              CONVERTER_DEFAULTS_INFO *conf);
+
 INDEX_ENTRY *find_index_entry_sv (const SV *index_entry_sv,
                      INDEX_LIST *indices_info,
                      const char *warn_string, const INDEX **entry_idx,
diff --git a/tp/Texinfo/XS/main/option_types.h 
b/tp/Texinfo/XS/main/option_types.h
index c716c43002..4955962d1d 100644
--- a/tp/Texinfo/XS/main/option_types.h
+++ b/tp/Texinfo/XS/main/option_types.h
@@ -170,4 +170,9 @@ typedef struct OPTION {
     } o;
 } OPTION;
 
+typedef struct OPTIONS_LIST {
+    size_t number;
+    OPTION *list;
+} OPTIONS_LIST;
+
 #endif
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 98de8ee7cd..41fc8291d2 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -1884,6 +1884,8 @@ copy_option (OPTION *destination, const OPTION *source)
           if (source_icons)
             {
               dest_icons->number = source_icons->number;
+              dest_icons->sv = source_icons->sv;
+              register_perl_data (dest_icons->sv);
               if (dest_icons->number)
                 {
                   size_t i;
@@ -1998,6 +2000,48 @@ set_sorted_option_key_configured (OPTION 
**sorted_options, const char *key,
     }
 }
 
+/* copy OPTIONS_LIST options to an OPTIONS structure, using the sorted options
+   to find the struct fields. */
+void
+copy_options_list_options (OPTIONS *options, OPTION **sorted_options,
+                           OPTIONS_LIST *options_list, int set_configured)
+{
+  size_t i;
+
+  for (i = 0; i < options_list->number; i++)
+    {
+      OPTION *src_option = &options_list->list[i];
+      if (src_option->number > 0)
+        {
+          size_t index = src_option->number - 1;
+          OPTION *dst_option = sorted_options[index];
+
+          copy_option (dst_option, src_option);
+
+          if (dst_option->type == GOT_buttons
+              && dst_option->o.buttons && options)
+            options->BIT_user_function_number
+               += dst_option->o.buttons->BIT_user_function_number;
+
+          if (set_configured)
+            dst_option->configured = 1;
+        }
+    }
+}
+
+void
+free_options_list (OPTIONS_LIST *options_list)
+{
+  size_t i;
+
+  for (i = 0; i < options_list->number; i++)
+    {
+      free_option (&options_list->list[i]);
+    }
+
+  free (options_list->list);
+}
+
 
 /* constructors in particular called from files including perl headers */
 
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index f87b739f4e..ebda6a147a 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -212,6 +212,9 @@ void clear_options (OPTIONS *options);
 void free_options (OPTIONS *options);
 void copy_options (OPTIONS *destination, const OPTIONS *source);
 
+void copy_options_list_options (OPTIONS *options, OPTION **sorted_options,
+                                OPTIONS_LIST *options_list, int 
set_configured);
+void free_options_list (OPTIONS_LIST *options_list);
 
 OPTIONS *new_options (void);
 OPTION **setup_sorted_options (OPTIONS *options);



reply via email to

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