texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Thu, 22 Feb 2024 17:11:55 -0500 (EST)

branch: master
commit 7c7dce5d29c8e00c22891dab26a08cf9ea55809f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Feb 22 23:11:49 2024 +0100

    * tp/Texinfo/XS/main/translations.c (gdt, gdt_tree, pgdt_tree)
    (gdt_string), tp/Texinfo/XS/main/DocumentXS.xs (gdt): remove options
    argument, pass debug_level as argument.  Update callers.
---
 ChangeLog                                       |  6 ++++
 tp/Texinfo/XS/main/DocumentXS.xs                | 32 ++++++++-------------
 tp/Texinfo/XS/main/convert_to_text.c            |  4 +--
 tp/Texinfo/XS/main/convert_utils.c              | 37 ++++++++++++++-----------
 tp/Texinfo/XS/main/translations.c               | 27 ++++++++----------
 tp/Texinfo/XS/main/translations.h               | 16 +++++------
 tp/Texinfo/XS/parsetexi/indices.c               | 16 ++++-------
 tp/Texinfo/XS/structuring_transfo/structuring.c | 13 +++++----
 8 files changed, 74 insertions(+), 77 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f9518a0d4c..27b46f6c0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-22  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/translations.c (gdt, gdt_tree, pgdt_tree)
+       (gdt_string), tp/Texinfo/XS/main/DocumentXS.xs (gdt): remove options
+       argument, pass debug_level as argument.  Update callers.
+
 2024-02-22  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Translations.pm (gdt, gdt_string): pass debug_level
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index adb8e65c10..0d39ba28d7 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -201,42 +201,34 @@ indices_sort_strings (SV *document_in, ...)
 # Next one is unused, kept as documentation only, as the code is
 # ok, but the approach is flawed as the trees in replaced_substrings
 # do not exist in XS/C data.
-
-# TODO not sure that the options_in argument is good to be
-# init_copy_sv_options argument, may need to retrieve a converter
-# first or Parser configuration.  Does not matter much as
-# the approach does not work because replaced_substrings
-# perl element tree cannot be retrieved in C stored documents.
 # optional:
-# lang, replaced_substrings, translation_context
+# lang, replaced_substrings, debug_level, translation_context
 SV *
-gdt (SV *options_in, string, ...)
+gdt (string, ...)
         char *string = (char *)SvPVutf8_nolen($arg);
       PROTOTYPE: $$;$$$
       PREINIT:
         char *translation_context = 0;
         char *in_lang = 0;
+        int debug_level = 0;
         HV *hv_replaced_substrings = 0;
         NAMED_STRING_ELEMENT_LIST *replaced_substrings = 0;
-        OPTIONS *options = 0;
         HV *result_tree;
         int gdt_document_descriptor;
         DOCUMENT *gdt_document;
       CODE:
-         if (SvOK(options_in))
-           {
-             options = init_copy_sv_options (options_in, 0, 0);
-           }
-        if (items > 2 && SvOK(ST(2)))
-           in_lang = (char *)SvPVutf8_nolen(ST(2));
-        if (items > 4 && SvOK(ST(4)))
-           translation_context = (char *)SvPVutf8_nolen(ST(4));
+        if (items > 1 && SvOK(ST(1)))
+           in_lang = (char *)SvPVutf8_nolen(ST(1));
         if (items > 3 && SvOK(ST(3)))
+           translation_context = (char *)SvPVutf8_nolen(ST(3));
+        if (items > 4 && SvOK(ST(4)))
+           debug_level = SvIV (ST(4));
+        if (items > 2 && SvOK(ST(2)))
            {
              /* TODO put in get_perl_info.h */
              I32 hv_number;
              I32 i;
-             hv_replaced_substrings = (HV *)SvRV (ST(3));
+             hv_replaced_substrings = (HV *)SvRV (ST(2));
              hv_number = hv_iterinit (hv_replaced_substrings);
              if (hv_number > 0)
                replaced_substrings = new_named_string_element_list ();
@@ -258,8 +250,8 @@ gdt (SV *options_in, string, ...)
            }
 
          gdt_document_descriptor
-                     = gdt (string, options, in_lang, replaced_substrings,
-                           translation_context);
+                     = gdt (string, in_lang, replaced_substrings,
+                           debug_level, translation_context);
          gdt_document = retrieve_document (gdt_document_descriptor);
          result_tree = build_texinfo_tree (gdt_document->tree, 0);
          hv_store (result_tree, "tree_document_descriptor",
diff --git a/tp/Texinfo/XS/main/convert_to_text.c 
b/tp/Texinfo/XS/main/convert_to_text.c
index b51ed9038d..b7fe2ebbd7 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -552,8 +552,8 @@ convert_to_text_internal (const ELEMENT *element, 
TEXT_OPTIONS *text_options,
                  it is very unlikely to have small strings given that the
                  converted tree should be very simple and is a string only,
                  no macro, no file */
-              tree = gdt_tree (element->text.text, 0, 0, documentlanguage,
-                               0, translation_context);
+              tree = gdt_tree (element->text.text, 0, documentlanguage,
+                               0, 0, translation_context);
             }
 
           if (tree)
diff --git a/tp/Texinfo/XS/main/convert_utils.c 
b/tp/Texinfo/XS/main/convert_utils.c
index f5c1c24faa..822097728c 100644
--- a/tp/Texinfo/XS/main/convert_utils.c
+++ b/tp/Texinfo/XS/main/convert_utils.c
@@ -91,8 +91,9 @@ expand_today (OPTIONS *options)
 
   year = time_tm->tm_year + 1900;
 
-  month_tree = gdt_tree (convert_utils_month_name[time_tm->tm_mon], 0, options,
-                         options->documentlanguage.string, 0, 0);
+  month_tree = gdt_tree (convert_utils_month_name[time_tm->tm_mon], 0,
+                         options->documentlanguage.string, 0,
+                         options->DEBUG.integer, 0);
   day_element = new_element (ET_NONE);
   year_element = new_element (ET_NONE);
   text_printf (&day_element->text, "%d", time_tm->tm_mday);
@@ -103,8 +104,9 @@ expand_today (OPTIONS *options)
   add_element_to_named_string_element_list (substrings, "day", day_element);
   add_element_to_named_string_element_list (substrings, "year", year_element);
 
-  result = gdt_tree ("{month} {day}, {year}", 0, options,
-                     options->documentlanguage.string, substrings, 0);
+  result = gdt_tree ("{month} {day}, {year}", 0,
+                     options->documentlanguage.string, substrings,
+                     options->DEBUG.integer, 0);
   destroy_named_string_element_list (substrings);
 
   return result;
@@ -211,13 +213,13 @@ add_heading_number (OPTIONS *options, const ELEMENT 
*current, char *text,
                 {
                   numbered_heading
                    = gdt_string ("Appendix {number} {section_title}",
-                                 options, options->documentlanguage.string,
+                                 options->documentlanguage.string,
                                  substrings, 0);
                 }
             }
           if (!numbered_heading)
             numbered_heading
-              = gdt_string ("{number} {section_title}", options,
+              = gdt_string ("{number} {section_title}",
                             options->documentlanguage.string, substrings, 0);
 
           destroy_named_string_element_list (substrings);
@@ -569,15 +571,16 @@ definition_category_tree (OPTIONS * options, const 
ELEMENT *current)
           in descriptions of object-oriented programming methods or operations.
            */
 
-          result = gdt_tree ("{category} on @code{{class}}", 0, options,
-                             options->documentlanguage.string, substrings, 0);
+          result = gdt_tree ("{category} on @code{{class}}", 0,
+                             options->documentlanguage.string, substrings,
+                             options->DEBUG.integer, 0);
         }
       else
         {
           const char *documentlanguage
                 = lookup_extra_string (current, "documentlanguage");
-          result = gdt_tree ("{category} on @code{{class}}", 0, 0,
-                             documentlanguage, substrings, 0);
+          result = gdt_tree ("{category} on @code{{class}}", 0,
+                             documentlanguage, substrings, 0, 0);
           /*
           result = new_element (ET_NONE);
           ELEMENT *text_element = new_element (ET_NONE);
@@ -607,15 +610,16 @@ definition_category_tree (OPTIONS * options, const 
ELEMENT *current)
           in descriptions of object-oriented programming methods or operations.
            */
 
-          result = gdt_tree ("{category} of @code{{class}}", 0, options,
-                             options->documentlanguage.string, substrings, 0);
+          result = gdt_tree ("{category} of @code{{class}}", 0,
+                             options->documentlanguage.string, substrings,
+                             options->DEBUG.integer, 0);
         }
       else
         {
           const char *documentlanguage
                 = lookup_extra_string (current, "documentlanguage");
-          result = gdt_tree ("{category} of @code{{class}}", 0, 0,
-                             documentlanguage, substrings, 0);
+          result = gdt_tree ("{category} of @code{{class}}", 0,
+                             documentlanguage, substrings, 0, 0);
           /*
           result = new_element (ET_NONE);
           ELEMENT *text_element = new_element (ET_NONE);
@@ -636,9 +640,10 @@ cdt_tree (const char * string, CONVERTER *self,
           const char *translation_context)
 {
   const char *lang = self->conf->documentlanguage.string;
+  int debug_level = self->conf->DEBUG.integer;
 
-  return gdt_tree (string, self->document, self->conf, lang,
-                   replaced_substrings, translation_context);
+  return gdt_tree (string, self->document, lang, replaced_substrings,
+                   debug_level, translation_context);
 }
 
 ELEMENT *
diff --git a/tp/Texinfo/XS/main/translations.c 
b/tp/Texinfo/XS/main/translations.c
index 79dab5565e..88029d75b0 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -526,19 +526,15 @@ replace_convert_substrings (char *translated_string,
 
 /* returns a document descriptor. */
 int
-gdt (const char *string, OPTIONS *options, const char *lang,
+gdt (const char *string, const char *lang,
      NAMED_STRING_ELEMENT_LIST *replaced_substrings,
-     const char *translation_context)
+     int debug_level, const char *translation_context)
 {
-  int debug_level = 0;
   int document_descriptor;
 
   char *translated_string = translate_string (string, lang,
                                               translation_context);
 
-  if (options && options->DEBUG.integer >= 0)
-    debug_level = options->DEBUG.integer;
-
   document_descriptor  = replace_convert_substrings (translated_string,
                                   replaced_substrings, debug_level);
   free (translated_string);
@@ -550,12 +546,12 @@ gdt (const char *string, OPTIONS *options, const char 
*lang,
    DOCUMENT small strings.  It is possible to pass 0 for the DOCUMENT
    if one knows that there won't be small strings (the general case) */
 ELEMENT *
-gdt_tree (const char *string, DOCUMENT *document, OPTIONS *options,
+gdt_tree (const char *string, DOCUMENT *document,
           const char *lang, NAMED_STRING_ELEMENT_LIST *replaced_substrings,
-          const char *translation_context)
+          int debug_level, const char *translation_context)
 {
-  int gdt_document_descriptor = gdt (string, options, lang,
-                                     replaced_substrings, translation_context);
+  int gdt_document_descriptor = gdt (string, lang, replaced_substrings,
+                                    debug_level, translation_context);
   ELEMENT *tree
     = unregister_document_merge_with_document (gdt_document_descriptor,
                                                document);
@@ -564,7 +560,7 @@ gdt_tree (const char *string, DOCUMENT *document, OPTIONS 
*options,
 }
 
 char *
-gdt_string (const char *string, OPTIONS *options, const char *lang,
+gdt_string (const char *string, const char *lang,
             NAMED_STRING_ELEMENT_LIST *replaced_substrings,
             const char *translation_context)
 {
@@ -578,11 +574,12 @@ gdt_string (const char *string, OPTIONS *options, const 
char *lang,
 
 ELEMENT *
 pgdt_tree (const char *translation_context, const char *string,
-           DOCUMENT *document, OPTIONS *options, const char *lang,
-           NAMED_STRING_ELEMENT_LIST *replaced_substrings)
+           DOCUMENT *document, const char *lang,
+           NAMED_STRING_ELEMENT_LIST *replaced_substrings,
+           int debug_level)
 {
-  return gdt_tree (string, document, options, lang, replaced_substrings,
-                   translation_context);
+  return gdt_tree (string, document, lang, replaced_substrings,
+                   debug_level, translation_context);
 }
 
 NAMED_STRING_ELEMENT_LIST *
diff --git a/tp/Texinfo/XS/main/translations.h 
b/tp/Texinfo/XS/main/translations.h
index 9f123b7fcf..738862ae2d 100644
--- a/tp/Texinfo/XS/main/translations.h
+++ b/tp/Texinfo/XS/main/translations.h
@@ -32,23 +32,23 @@ int replace_convert_substrings (char *translated_string,
 char *replace_substrings (const char *string,
                     const NAMED_STRING_ELEMENT_LIST *replaced_substrings);
 
-int gdt (const char * string, OPTIONS *options, const char *lang,
+int gdt (const char *string, const char *lang,
          NAMED_STRING_ELEMENT_LIST *replaced_substrings,
-         const char *translation_context);
+         int debug_level, const char *translation_context);
 
-ELEMENT *gdt_tree (const char * string, DOCUMENT *document, OPTIONS *options,
+ELEMENT *gdt_tree (const char *string, DOCUMENT *document,
                    const char *lang,
                    NAMED_STRING_ELEMENT_LIST *replaced_substrings,
-                   const char *translation_context);
+                   int debug_level, const char *translation_context);
 
-char *gdt_string (const char *string, OPTIONS *options, const char *lang,
+char *gdt_string (const char *string, const char *lang,
                   NAMED_STRING_ELEMENT_LIST *replaced_substrings,
                   const char *translation_context);
 
 ELEMENT *pgdt_tree (const char *translation_context, const char *string,
-                    DOCUMENT *document, OPTIONS *options,
-                    const char *lang,
-                    NAMED_STRING_ELEMENT_LIST *replaced_substrings);
+                    DOCUMENT *document, const char *lang,
+                    NAMED_STRING_ELEMENT_LIST *replaced_substrings,
+                    int debug_level);
 
 NAMED_STRING_ELEMENT_LIST * new_named_string_element_list (void);
 void add_string_to_named_string_element_list (NAMED_STRING_ELEMENT_LIST *nsel,
diff --git a/tp/Texinfo/XS/parsetexi/indices.c 
b/tp/Texinfo/XS/parsetexi/indices.c
index 76ecab47b0..fc609c9f1c 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -20,8 +20,7 @@
 
 #include "tree_types.h"
 #include "command_ids.h"
-/* document and options used in complete_indices */
-#include "options_types.h"
+/* document used in complete_indices */
 #include "document_types.h"
 #include "tree.h"
 #include "errors_parser.h"
@@ -380,7 +379,6 @@ complete_indices (int document_descriptor)
   INDEX **i, *idx;
   DOCUMENT *document;
   INDEX **index_names;
-  OPTIONS *options;
 
   /* beware that document may have a change in adress if realloc on
      the documents list is called in gdt.  So only use it here and
@@ -388,7 +386,6 @@ complete_indices (int document_descriptor)
   document = retrieve_document (document_descriptor);
 
   index_names = document->index_names;
-  options = document->options;
 
   for (i = index_names; (idx = *i); i++)
     {
@@ -457,11 +454,10 @@ complete_indices (int document_descriptor)
                           || def_command == CM_deftypeop
                           || def_command == CM_defmethod
                           || def_command == CM_deftypemethod)
-                        { /* note that at that point, options are unlikely
-                          to be set, but we use the language of the element */
+                        {
                           index_entry = gdt_tree ("{name} on {class}",
-                                                  document, options,
-                                                  lang, substrings, 0);
+                                                  document,
+                                                  lang, substrings, 0, 0);
 
                           text_append (&text_element->text, " on ");
                         }
@@ -471,8 +467,8 @@ complete_indices (int document_descriptor)
                                || def_command == CM_deftypecv)
                         {
                           index_entry = gdt_tree ("{name} of {class}",
-                                                  document, options, lang,
-                                                  substrings, 0);
+                                                  document, lang,
+                                                  substrings, 0, 0);
 
                           text_append (&text_element->text, " of ");
                         }
diff --git a/tp/Texinfo/XS/structuring_transfo/structuring.c 
b/tp/Texinfo/XS/structuring_transfo/structuring.c
index 0679cd3ff2..71635d6291 100644
--- a/tp/Texinfo/XS/structuring_transfo/structuring.c
+++ b/tp/Texinfo/XS/structuring_transfo/structuring.c
@@ -1877,9 +1877,9 @@ new_complete_node_menu (ELEMENT *node, DOCUMENT *document,
                                                 "part_title", part_title_copy);
 
                       part_title
-                        = gdt_tree ("Part: {part_title}", document, options,
+                        = gdt_tree ("Part: {part_title}", document,
                                     options->documentlanguage.string,
-                                    substrings, 0);
+                                    substrings, options->DEBUG.integer, 0);
 
                       insert_menu_comment_content (&new_menu->contents,
                                                    content_index, part_title,
@@ -1894,9 +1894,9 @@ new_complete_node_menu (ELEMENT *node, DOCUMENT *document,
                       && command_other_flags (child_section) & CF_appendix)
                     {
                       ELEMENT *appendix_title
-                        = gdt_tree ("Appendices", document, options,
+                        = gdt_tree ("Appendices", document,
                                     options->documentlanguage.string,
-                                    0, 0);
+                                    0, options->DEBUG.integer, 0);
 
                       insert_menu_comment_content (&new_menu->contents,
                                                    content_index,
@@ -2073,8 +2073,9 @@ new_master_menu (OPTIONS *options, LABEL_LIST 
*identifiers_target,
         {
           ELEMENT *master_menu_title;
           master_menu_title
-            = gdt_tree (" --- The Detailed Node Listing ---", 0, options,
-                        options->documentlanguage.string, 0, 0);
+            = gdt_tree (" --- The Detailed Node Listing ---", 0,
+                        options->documentlanguage.string, 0,
+                        options->DEBUG.integer, 0);
 
           for (i = 0; i < master_menu_title->contents.number; i++)
             master_menu_title->contents.list[i]->parent = first_preformatted;



reply via email to

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