texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/convert/converter.c (CONVERTER_FO


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/converter.c (CONVERTER_FORMAT_DATA) (converter_format_data): rename CONVERSION_FORMAT_DATA as CONVERTER_FORMAT_DATA, conversion_format as converter_format_data, enum conversion_output_format as enum converter_format and CONVERSION_FORMAT_NR as TXI_CONVERSION_FORMAT_NR.
Date: Wed, 02 Oct 2024 17:33:24 -0400

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 fd72eba38c * tp/Texinfo/XS/convert/converter.c (CONVERTER_FORMAT_DATA) 
(converter_format_data): rename CONVERSION_FORMAT_DATA as 
CONVERTER_FORMAT_DATA, conversion_format as converter_format_data, enum 
conversion_output_format as enum converter_format and CONVERSION_FORMAT_NR as 
TXI_CONVERSION_FORMAT_NR.
fd72eba38c is described below

commit fd72eba38c2e787deb157b7d0cb18d4feaa19b64
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 4 14:45:12 2024 +0200

    * tp/Texinfo/XS/convert/converter.c (CONVERTER_FORMAT_DATA)
    (converter_format_data): rename CONVERSION_FORMAT_DATA as
    CONVERTER_FORMAT_DATA, conversion_format as converter_format_data,
    enum conversion_output_format as enum converter_format and
    CONVERSION_FORMAT_NR as TXI_CONVERSION_FORMAT_NR.
    
    * tp/Texinfo/XS/convert/converter.h (enum converter_format)
    (TXI_CONVERSION_FORMAT_NR, CONVERTER_FORMAT_DATA),
    tp/Texinfo/XS/convert/converter.c: move declarations to converter.h.
    
    * tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init),
    tp/Texinfo/XS/convert/converter.c (set_converter_init_information),
    tp/Texinfo/XS/main/get_perl_info.c (converter_get_info_from_sv):
    determine enum converter format in converter_get_info_from_sv, pass it
    as return value.  Pass status in an integer reference.
    
    * tp/Texinfo/XS/convert/converter.c (set_global_document_commands):
    allow converter document to be NULL.
---
 ChangeLog                                       | 21 ++++++++++++++++++++
 tp/Texinfo/XS/convert/ConvertXS.xs              | 13 ++++++++-----
 tp/Texinfo/XS/convert/converter.c               | 26 +++++++++----------------
 tp/Texinfo/XS/convert/converter.h               | 19 ++++++++++++++++--
 tp/Texinfo/XS/convert/get_converter_perl_info.c | 23 ++++++++++++++++++----
 tp/Texinfo/XS/convert/get_converter_perl_info.h | 12 +++++++-----
 6 files changed, 81 insertions(+), 33 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e5436e2a9f..40bae7c2fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,27 @@
        (get_converter_info_from_sv): do not error out on
        deprecated_config_directories customization hash directory key.
 
+2024-08-04  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/converter.c (CONVERTER_FORMAT_DATA)
+       (converter_format_data): rename CONVERSION_FORMAT_DATA as
+       CONVERTER_FORMAT_DATA, conversion_format as converter_format_data,
+       enum conversion_output_format as enum converter_format and
+       CONVERSION_FORMAT_NR as TXI_CONVERSION_FORMAT_NR.
+
+       * tp/Texinfo/XS/convert/converter.h (enum converter_format)
+       (TXI_CONVERSION_FORMAT_NR, CONVERTER_FORMAT_DATA),
+       tp/Texinfo/XS/convert/converter.c: move declarations to converter.h.
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init),
+       tp/Texinfo/XS/convert/converter.c (set_converter_init_information),
+       tp/Texinfo/XS/main/get_perl_info.c (converter_get_info_from_sv):
+       determine enum converter format in converter_get_info_from_sv, pass it
+       as return value.  Pass status in an integer reference.
+
+       * tp/Texinfo/XS/convert/converter.c (set_global_document_commands):
+       allow converter document to be NULL.
+
 2024-08-04  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/Makefile.am (libtexinfo_la_SOURCES)
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 8e5ff79d12..d08bc5dc1a 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -89,7 +89,7 @@ init (int texinfo_uninstalled, SV *pkgdatadir_sv, SV 
*tp_builddir_sv, SV *top_sr
     OUTPUT:
         RETVAL
 
-# NOTE not sure what the scope of class is.  In a test, valgrind did not
+# NOTE not sure what the scope of class is.  When tested, valgrind did not
 # complain.
 void
 generic_converter_init (SV *converter_in, const char *class, SV 
*format_defaults_sv, SV *conf_sv=0)
@@ -98,6 +98,7 @@ generic_converter_init (SV *converter_in, const char *class, 
SV *format_defaults
          CONVERTER *self;
          CONVERTER_INITIALIZATION_INFO *format_defaults;
          CONVERTER_INITIALIZATION_INFO *conf;
+         enum converter_format converter_format;
       CODE:
          converter_descriptor = new_converter ();
          self = retrieve_converter (converter_descriptor);
@@ -105,11 +106,13 @@ generic_converter_init (SV *converter_in, const char 
*class, SV *format_defaults
          format_defaults = new_converter_initialization_info ();
          conf = new_converter_initialization_info ();
 
-         converter_get_info_from_sv (converter_in, class, self,
-                                     format_defaults_sv,
-                                     conf_sv, format_defaults, conf);
+         converter_format
+           = converter_get_info_from_sv (converter_in, class, self,
+                                         format_defaults_sv,
+                                         conf_sv, format_defaults, conf, 0);
 
-         set_converter_init_information (self, format_defaults, conf);
+         set_converter_init_information (self, converter_format,
+                                         format_defaults, conf);
 
          destroy_converter_initialization_info (format_defaults);
          destroy_converter_initialization_info (conf);
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 3fc3733a0a..f6c37db236 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -59,20 +59,7 @@
 #include "call_perl_function.h"
 #include "converter.h"
 
-enum conversion_output_format {
-   COF_none = -1,
-   COF_html,
-};
-
-#define CONVERSION_FORMAT_NR (COF_html +1)
-
-typedef struct CONVERSION_FORMAT_DATA {
-    const char *output_format;
-    const char *perl_converter_class;
-} CONVERSION_FORMAT_DATA;
-
-
-CONVERSION_FORMAT_DATA conversion_format[] = {
+CONVERTER_FORMAT_DATA converter_format_data[] = {
   {"html", "Texinfo::Convert::HTML", },
 };
 
@@ -285,6 +272,7 @@ apply_converter_info (CONVERTER *converter,
 
 void
 set_converter_init_information (CONVERTER *converter,
+                            enum converter_format converter_format,
                             CONVERTER_INITIALIZATION_INFO *format_defaults,
                             CONVERTER_INITIALIZATION_INFO *user_conf)
 {
@@ -812,7 +800,7 @@ set_global_document_commands (CONVERTER *converter,
       int i;
       for (i = 0; cmd_list[i] > 0; i++)
         {
-          const ELEMENT *element;
+          const ELEMENT *element = 0;
           enum command_id cmd = cmd_list[i];
           if (converter->conf->DEBUG.o.integer > 0)
             {
@@ -820,10 +808,14 @@ set_global_document_commands (CONVERTER *converter,
                        command_location_names[location],
                        builtin_command_data[cmd].cmdname);
             }
-          element
-          = set_global_document_command (&converter->document->global_commands,
+          if (converter->document)
+            {
+              element
+                = set_global_document_command (
+                                     &converter->document->global_commands,
                                          converter->conf,
                                          cmd, location);
+            }
           if (!element)
             {
               OPTION *option_value = command_init (cmd,
diff --git a/tp/Texinfo/XS/convert/converter.h 
b/tp/Texinfo/XS/convert/converter.h
index 7f9c05f8ff..48893a3b18 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -66,6 +66,13 @@
             } \
           break;
 
+enum converter_format {
+   COF_none = -1,
+   COF_html,
+};
+
+#define TXI_CONVERSION_FORMAT_NR (COF_html +1)
+
 typedef struct FLOAT_CAPTION_PREPENDED_ELEMENT {
     const ELEMENT *caption;
     ELEMENT *prepended;
@@ -88,6 +95,11 @@ typedef struct PATHS_INFORMATION {
     } p;
 } PATHS_INFORMATION;
 
+typedef struct CONVERTER_FORMAT_DATA {
+    const char *output_format;
+    const char *perl_converter_class;
+} CONVERTER_FORMAT_DATA;
+
 extern enum command_id no_brace_command_accent_upper_case[][2];
 
 extern enum command_id default_upper_case_commands[];
@@ -105,6 +117,8 @@ extern COMMAND_ACCENT_ENTITY_INFO 
xml_accent_text_entities[];
 
 extern PATHS_INFORMATION conversion_paths_info;
 
+extern CONVERTER_FORMAT_DATA converter_format_data[];
+
 void converter_setup (int texinfo_uninstalled, const char *tp_builddir,
                       const char *pkgdatadir, const char *top_srcdir);
 
@@ -113,8 +127,9 @@ size_t new_converter (void);
 void unregister_converter_descriptor (int converter_descriptor);
 
 void set_converter_init_information (CONVERTER *converter,
-                          CONVERTER_INITIALIZATION_INFO *format_defaults,
-                          CONVERTER_INITIALIZATION_INFO *user_conf);
+                            enum converter_format converter_format,
+                            CONVERTER_INITIALIZATION_INFO *format_defaults,
+                            CONVERTER_INITIALIZATION_INFO *user_conf);
 
 CONVERTER_INITIALIZATION_INFO *new_converter_initialization_info (void);
 void destroy_converter_initialization_info (
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.c 
b/tp/Texinfo/XS/convert/get_converter_perl_info.c
index 285077419f..7730db97d1 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.c
@@ -265,17 +265,20 @@ set_non_customization_sv (HV *converter_hv, SV 
*init_info_sv,
 }
 
 /* CLASS is the perl converter class.  It could also be taken from
-   the object and is only used for a warning */
-int
+   the object */
+enum converter_format
 converter_get_info_from_sv (SV *converter_sv, const char *class,
                             CONVERTER *converter,
                             SV *format_defaults_sv, SV *conf_sv,
                             CONVERTER_INITIALIZATION_INFO *format_defaults,
-                            CONVERTER_INITIALIZATION_INFO *conf)
+                            CONVERTER_INITIALIZATION_INFO *conf,
+                            int *status)
 {
   HV *converter_hv;
   int has_format_defaults;
   int has_conf;
+  int i;
+  enum converter_format converter_format = COF_none;
 
   dTHX;
 
@@ -283,6 +286,16 @@ converter_get_info_from_sv (SV *converter_sv, const char 
*class,
 
   converter->hv = converter_hv;
 
+  /* determine the converter format, if handled in C */
+  for (i =0; i < TXI_CONVERSION_FORMAT_NR; i++)
+    {
+      if (!strcmp (converter_format_data[i].perl_converter_class, class))
+        {
+          converter_format = i;
+          break;
+        }
+    }
+
   has_format_defaults
     = get_converter_info_from_sv (format_defaults_sv, class, converter,
                               converter->sorted_options, format_defaults);
@@ -303,7 +316,9 @@ converter_get_info_from_sv (SV *converter_sv, const char 
*class,
                    has_conf);
     */
 
-  return has_format_defaults + has_conf;
+  if (status)
+    *status = has_format_defaults + has_conf;
+  return converter_format;
 }
 
 void
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.h 
b/tp/Texinfo/XS/convert/get_converter_perl_info.h
index e17c851e22..7c53ed49ec 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.h
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.h
@@ -12,11 +12,13 @@ struct TEXT_OPTIONS;
 CONVERTER *get_sv_converter (SV *sv_in, const char *warn_string);
 CONVERTER *converter_set_document_from_sv (SV *converter_in, SV *document_in);
 
-int converter_get_info_from_sv (SV *converter_sv, const char *class,
-                                CONVERTER *converter,
-                                SV *format_defaults_sv, SV *conf_sv,
-                                CONVERTER_INITIALIZATION_INFO *format_defaults,
-                                CONVERTER_INITIALIZATION_INFO *conf);
+enum converter_format converter_get_info_from_sv (SV *converter_sv,
+                            const char *class,
+                            CONVERTER *converter,
+                            SV *format_defaults_sv, SV *conf_sv,
+                            CONVERTER_INITIALIZATION_INFO *format_defaults,
+                            CONVERTER_INITIALIZATION_INFO *conf,
+                            int *status);
 
 struct TEXT_OPTIONS *copy_sv_options_for_convert_text (SV *sv_in);
 



reply via email to

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