texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/main/translations.c (replace_conv


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/translations.c (replace_convert_substrings): call reset_parser.
Date: Fri, 02 Feb 2024 15:45:38 -0500

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 1d5aacce30 * tp/Texinfo/XS/main/translations.c 
(replace_convert_substrings): call reset_parser.
1d5aacce30 is described below

commit 1d5aacce3057c2dc6a23282d68c843e747cfe532
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Feb 2 21:45:20 2024 +0100

    * tp/Texinfo/XS/main/translations.c (replace_convert_substrings):
    call reset_parser.
    
    * tp/Texinfo/XS/convert/convert_html.c (html_cdt),
    tp/Texinfo/XS/main/translations.c (replace_convert_substrings, gdt):
    pass debug_level instead of options to replace_convert_substrings.
    Set parser debug level in replace_convert_substrings.
---
 ChangeLog                            | 10 ++++++++++
 tp/Texinfo/XS/convert/convert_html.c |  9 +++++++--
 tp/Texinfo/XS/main/translations.c    | 32 ++++++++++++++++++++------------
 tp/Texinfo/XS/main/translations.h    |  5 +++--
 4 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fc21c044e0..e2d7d9f6cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-02-02  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/translations.c (replace_convert_substrings):
+       call reset_parser.
+
+       * tp/Texinfo/XS/convert/convert_html.c (html_cdt),
+       tp/Texinfo/XS/main/translations.c (replace_convert_substrings, gdt):
+       pass debug_level instead of options to replace_convert_substrings.
+       Set parser debug level in replace_convert_substrings.
+
 2024-02-02  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Translations.pm (translate_string, gdt, gdt_string):
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index a976339dfe..cf5863386a 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -596,14 +596,19 @@ html_cdt (const char *string, CONVERTER *self, const char 
*lang,
      NAMED_STRING_ELEMENT_LIST *replaced_substrings,
      const char *translation_context)
 {
+  int debug_level = 0;
   char *translated_string;
   int document_descriptor;
 
   translated_string = html_translate_string (self, string, lang,
                                              translation_context);
+
+  if (self->conf && self->conf->DEBUG.integer >= 0)
+    debug_level = self->conf->DEBUG.integer;
+
   document_descriptor
-    = replace_convert_substrings (self->conf, translated_string,
-                                  replaced_substrings);
+    = replace_convert_substrings (translated_string,
+                                  replaced_substrings, debug_level);
   free (translated_string);
   return document_descriptor;
 }
diff --git a/tp/Texinfo/XS/main/translations.c 
b/tp/Texinfo/XS/main/translations.c
index c5bb1771fa..4640fe654c 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -423,12 +423,14 @@ substitute (ELEMENT *tree, NAMED_STRING_ELEMENT_LIST 
*replaced_substrings)
 /* the caller should have made sure that the
    inserted elements do not appear elsewhere in the tree. */
 int
-replace_convert_substrings (OPTIONS *options, char *translated_string,
-                            NAMED_STRING_ELEMENT_LIST *replaced_substrings)
+replace_convert_substrings (char *translated_string,
+                            NAMED_STRING_ELEMENT_LIST *replaced_substrings,
+                            int debug_level)
 {
   int i;
   char *texinfo_line;
   int document_descriptor;
+  int parser_debug_level = 0;
   DOCUMENT *document;
 
   if (replaced_substrings)
@@ -459,18 +461,20 @@ replace_convert_substrings (OPTIONS *options, char 
*translated_string,
   fprintf(stderr, "INTERNAL V CMDS '%s' '%s'\n", translated_string,
                                                  texinfo_line);
    */ 
-  /* FIXME different from Perl case, as in perl case, a parser is
-     setup, which means a full reset of configuration, here would
-     correspond to a call of reset_parser */
+
+  /* set parser debug level to one less than debug_level */
+  if (debug_level > 0)
+    parser_debug_level = debug_level - 1;
+
+  reset_parser (parser_debug_level);
+  parser_set_debug (parser_debug_level);
+
   /*
    accept @txiinternalvalue as a valid Texinfo command, used to mark
    location in tree of substituted brace enclosed strings.
    */
   parser_set_accept_internalvalue (1);
 
-  /* TODO implement setting DEBUG.  This may not be needed when
-     called from a parser without reset_parser being called, but could be
-     when called from a converter. */
   document_descriptor = parse_string (texinfo_line, 1);
 
   /* FIXME if called from parser through complete_indices, options will
@@ -479,7 +483,7 @@ replace_convert_substrings (OPTIONS *options, char 
*translated_string,
   /*
   debug ("IN TR PARSER '%s'", texinfo_line);
    */
-  if (options && options->DEBUG.integer > 0)
+  if (debug_level > 0)
     fprintf (stderr, "XS|IN TR PARSER '%s'\n", texinfo_line);
 
   document = retrieve_document (document_descriptor);
@@ -507,7 +511,7 @@ replace_convert_substrings (OPTIONS *options, char 
*translated_string,
 /*
   {
     char *result_texi = convert_to_texinfo (document->tree);
-    if (options && options->DEBUG.integer > 0)
+    if (debug_level > 0)
       fprintf (stderr, "XS|RESULT GDT %d: '%s'\n", document_descriptor,
                result_texi);
     free (result_texi);
@@ -526,12 +530,16 @@ gdt (const char *string, OPTIONS *options, const char 
*lang,
      NAMED_STRING_ELEMENT_LIST *replaced_substrings,
      const char *translation_context)
 {
+  int debug_level = 0;
   char *translated_string = translate_string (string, lang,
                                               translation_context);
 
+  if (options && options->DEBUG.integer >= 0)
+    debug_level = options->DEBUG.integer;
+
   int document_descriptor
-    = replace_convert_substrings (options, translated_string,
-                                  replaced_substrings);
+    = replace_convert_substrings (translated_string,
+                                  replaced_substrings, debug_level);
   free (translated_string);
   return document_descriptor;
 }
diff --git a/tp/Texinfo/XS/main/translations.h 
b/tp/Texinfo/XS/main/translations.h
index 1406fcae41..9f123b7fcf 100644
--- a/tp/Texinfo/XS/main/translations.h
+++ b/tp/Texinfo/XS/main/translations.h
@@ -26,8 +26,9 @@ void configure_output_strings_translations (char *localesdir,
 
 char *translate_string (const char * string, const char *lang,
                         const char *translation_context);
-int replace_convert_substrings (OPTIONS *options, char *translated_string,
-                            NAMED_STRING_ELEMENT_LIST *replaced_substrings);
+int replace_convert_substrings (char *translated_string,
+                            NAMED_STRING_ELEMENT_LIST *replaced_substrings,
+                            int debug_level);
 char *replace_substrings (const char *string,
                     const NAMED_STRING_ELEMENT_LIST *replaced_substrings);
 



reply via email to

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