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 15:47:23 -0400 (EDT)

branch: master
commit 381bbaf0182ccc530c2aaa8f6122f6417d91eef6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 3 20:58:10 2024 +0200

    * tp/maintain/regenerate_C_options_info.pl: rename generated
    build_sv_option as build_sv_option_key.
    
    * tp/Texinfo/XS/main/build_perl_info.c (build_sv_option): add
    build_sv_option that gets a Perl SV based on an OPTION, for all the
    types of options.
    
    * tp/Texinfo/XS/main/build_perl_info.c (get_sv_conf),
    tp/Texinfo/XS/main/DocumentXS.xs (document_get_conf): find option
    using sorted options with a call to find_option_string.  Call
    build_sv_option to get the Perl SV.
---
 ChangeLog                                | 14 +++++++
 tp/Texinfo/XS/main/DocumentXS.xs         | 11 +++++-
 tp/Texinfo/XS/main/build_perl_info.c     | 64 +++++++++++++++++++++++++++++++-
 tp/Texinfo/XS/main/build_perl_info.h     |  4 +-
 tp/maintain/regenerate_C_options_info.pl |  5 ++-
 5 files changed, 89 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fd3e7d3600..49ed3f7379 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-08-03  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/maintain/regenerate_C_options_info.pl: rename generated
+       build_sv_option as build_sv_option_key.
+
+       * tp/Texinfo/XS/main/build_perl_info.c (build_sv_option): add
+       build_sv_option that gets a Perl SV based on an OPTION, for all the
+       types of options.
+
+       * tp/Texinfo/XS/main/build_perl_info.c (get_sv_conf),
+       tp/Texinfo/XS/main/DocumentXS.xs (document_get_conf): find option
+       using sorted options with a call to find_option_string.  Call
+       build_sv_option to get the Perl SV.
+
 2024-08-03  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/ConvertXS.xs,
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index ad2d1b4a09..b01867e368 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -172,8 +172,15 @@ document_get_conf (SV *document_in, conf)
      CODE:
         document = get_sv_document_document (document_in,
                                              "document_get_conf");
-        if (document && document->options)
-           RETVAL = build_sv_option (document->options, conf, 0);
+        if (document && document->sorted_options)
+           {
+             OPTION *option
+               = find_option_string (document->sorted_options, conf);
+             if (option)
+               RETVAL = build_sv_option (option, 0);
+             else
+               RETVAL = newSV (0);
+           }
         else
            RETVAL = newSV (0);
     OUTPUT:
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 18d5c2c9ba..f739cdcf29 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -2414,6 +2414,61 @@ pass_document_to_converter_sv (const CONVERTER 
*converter,
     }
 }
 
+SV *
+build_sv_option (const OPTION *option, const CONVERTER *converter)
+{
+  dTHX;
+
+  switch (option->type)
+    {
+      case GOT_integer:
+        if (option->o.integer == -1)
+          return newSV (0);
+        return newSViv (option->o.integer);
+        break;
+
+      case GOT_char:
+        if (!option->o.string)
+          return newSV (0);
+        return newSVpv_utf8 (option->o.string, 0);
+        break;
+
+      case GOT_bytes:
+        if (!option->o.string)
+          return newSV (0);
+        return newSVpv_byte (option->o.string, 0);
+        break;
+
+      case GOT_bytes_string_list:
+        return newRV_noinc ((SV *) build_string_list(option->o.strlist,
+                            svt_byte));
+        break;
+
+      case GOT_file_string_list:
+        return newRV_noinc ((SV *) build_string_list(option->o.strlist,
+                            svt_dir));
+        break;
+
+      case GOT_char_string_list:
+        return newRV_noinc ((SV *) build_string_list(option->o.strlist,
+                            svt_char));
+        break;
+
+      case GOT_buttons:
+        if (!option->o.buttons) return newSV (0);
+        return newRV_inc ((SV *) option->o.buttons->av);
+        break;
+
+      case GOT_icons:
+        return html_build_direction_icons (converter, option->o.icons);
+        break;
+
+      default:
+        return newSV (0);
+        break;
+    }
+}
+
 SV *
 get_sv_conf (const CONVERTER *converter, const char *option_name)
 {
@@ -2421,8 +2476,13 @@ get_sv_conf (const CONVERTER *converter, const char 
*option_name)
 
   if (converter->conf)
     {
-      SV *result = build_sv_option (converter->conf, option_name, converter);
-      return result;
+      const OPTION *option
+        = find_option_string (converter->sorted_options, option_name);
+      if (option)
+        {
+          SV *result = build_sv_option (option, converter);
+          return result;
+       }
     }
   return newSV (0);
 }
diff --git a/tp/Texinfo/XS/main/build_perl_info.h 
b/tp/Texinfo/XS/main/build_perl_info.h
index e6504e183a..ae41199f6a 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -23,9 +23,7 @@ char *perl_only_strndup (const char *s, size_t n);
 int init (int texinfo_uninstalled, SV *pkgdatadir_sv, SV *builddir_sv,
           SV *top_srcdir_sv);
 
-/* in options_get_perl.c */
-SV *build_sv_option (const OPTIONS *options, const char *key,
-                     const CONVERTER *converter);
+SV *build_sv_option (const OPTION *option, const CONVERTER *converter);
 
 /* in call_perl_function.c, but declared here to avoid pulling in Perl
    headers in call_perl_function.h */
diff --git a/tp/maintain/regenerate_C_options_info.pl 
b/tp/maintain/regenerate_C_options_info.pl
index ab09462432..4c44df4dd1 100755
--- a/tp/maintain/regenerate_C_options_info.pl
+++ b/tp/maintain/regenerate_C_options_info.pl
@@ -557,9 +557,10 @@ print GET '}
 ';
 
 
+# Unused
 print GET 'SV *
-build_sv_option (const OPTIONS *options, const char *key,
-                 const CONVERTER *converter)
+build_sv_option_key (const OPTIONS *options, const char *key,
+                     const CONVERTER *converter)
 {
   dTHX;
 



reply via email to

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