texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Tue, 28 Feb 2023 13:46:14 -0500 (EST)

branch: master
commit 82e8120d486c05cacf37359bef9d90a2880db759
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Feb 28 19:45:43 2023 +0100

    * tp/Texinfo/XS/parsetexi/convert.c (convert_contents_to_texinfo),
    tp/Texinfo/XS/parsetexi/end_line.c
    (check_register_target_element_label, end_line_starting_block),
    tp/Texinfo/XS/parsetexi/macro.c (new_macro): add the
    convert_contents_to_texinfo function that converts only the contents
    of an element.  Use it.
---
 ChangeLog                          |  9 +++++++++
 tp/Texinfo/XS/parsetexi/convert.c  | 14 ++++++++++++++
 tp/Texinfo/XS/parsetexi/convert.h  |  1 +
 tp/Texinfo/XS/parsetexi/end_line.c | 21 ++++-----------------
 tp/Texinfo/XS/parsetexi/macro.c    |  6 +-----
 5 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e5d1987e74..d5c7a41cbe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-02-28  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/parsetexi/convert.c (convert_contents_to_texinfo),
+       tp/Texinfo/XS/parsetexi/end_line.c
+       (check_register_target_element_label, end_line_starting_block),
+       tp/Texinfo/XS/parsetexi/macro.c (new_macro): add the
+       convert_contents_to_texinfo function that converts only the contents
+       of an element.  Use it.
+
 2023-02-28  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/parsetexi/convert.c (expand_cmd_args_to_texi)
diff --git a/tp/Texinfo/XS/parsetexi/convert.c 
b/tp/Texinfo/XS/parsetexi/convert.c
index f244f438ea..9d0e13d9e4 100644
--- a/tp/Texinfo/XS/parsetexi/convert.c
+++ b/tp/Texinfo/XS/parsetexi/convert.c
@@ -221,6 +221,20 @@ convert_to_texinfo (ELEMENT *e)
   return result.text;
 }
 
+char *
+convert_contents_to_texinfo (ELEMENT *e)
+{
+  ELEMENT *tmp = new_element (ET_NONE);
+  char *result;
+
+  tmp->contents = e->contents;
+  result = convert_to_texinfo (tmp);
+  tmp->contents.list = 0;
+  destroy_element (tmp);
+
+  return result;
+}
+
 /* Very stripped-down version of Texinfo::Convert::Text.
    Convert the contents of E to plain text.  Suitable for specifying a file
    name containing an at sign or braces.  Set *SUPERFLUOUS_ARG if the contents
diff --git a/tp/Texinfo/XS/parsetexi/convert.h 
b/tp/Texinfo/XS/parsetexi/convert.h
index a0a9650428..1b74c4175a 100644
--- a/tp/Texinfo/XS/parsetexi/convert.h
+++ b/tp/Texinfo/XS/parsetexi/convert.h
@@ -5,6 +5,7 @@
 #include "tree_types.h"
 
 char *convert_to_texinfo (ELEMENT *e);
+char *convert_contents_to_texinfo (ELEMENT *e);
 char *convert_to_text (ELEMENT *e, int *superfluous_arg);
 char *node_extra_to_texi (NODE_SPEC_EXTRA *nse);
 
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c 
b/tp/Texinfo/XS/parsetexi/end_line.c
index 516465cca3..71742d4f02 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -807,14 +807,10 @@ check_register_target_element_label (ELEMENT 
*label_element,
       NODE_SPEC_EXTRA *label_info = parse_node_manual (label_element, 0);
       if (label_info && label_info->manual_content)
         {
-          ELEMENT *label_element_contents = new_element (ET_NONE);
-          /* copy contents only to avoid leading/trailing spaces */
-          insert_slice_into_contents (label_element_contents, 0, label_element,
-                                      0, label_element->contents.number);
-          char *texi = convert_to_texinfo (label_element_contents);
+          /* show contents only to avoid leading/trailing spaces */
+          char *texi = convert_contents_to_texinfo (label_element);
           line_error ("syntax for an external node used for `%s'", texi);
           free (texi);
-          destroy_element (label_element_contents);
         }
       destroy_node_spec (label_info);
     }
@@ -1263,16 +1259,12 @@ end_line_starting_block (ELEMENT *current)
               if (current->args.number > 0
                   && current->args.list[0]->contents.number > 0)
                 {
-                  ELEMENT *tmp = new_element (ET_NONE);
                   char *texi_arg;
 
                   /* expand the contents to avoid surrounding spaces */
-                  tmp->contents = current->args.list[0]->contents;
-                  texi_arg = convert_to_texinfo (tmp);
+                  texi_arg = convert_contents_to_texinfo 
(current->args.list[0]);
                   command_error (current, "bad argument to @%s: %s",
                                  command_name(command), texi_arg);
-                  tmp->contents.list = 0;
-                  destroy_element (tmp);
                   free (texi_arg);
                 }
               else
@@ -1397,18 +1389,13 @@ end_line_starting_block (ELEMENT *current)
            && current->args.number > 0
            && current->args.list[0]->contents.number > 0)
     {
-      ELEMENT *tmp = new_element (ET_NONE);
       char *texi_arg;
 
       /* expand the contents to avoid surrounding spaces */
-      tmp->contents = current->args.list[0]->contents;
-      texi_arg = convert_to_texinfo (tmp);
+      texi_arg = convert_contents_to_texinfo (current->args.list[0]);
       command_warn (current, "unexpected argument on @%s line: %s",
                      command_name(command), texi_arg);
       free (texi_arg);
-      /* important to do that in order not to deallocate in the tree */
-      tmp->contents.list = 0;
-      destroy_element (tmp);
     }
 
   if (command_data(command).data == BLOCK_conditional)
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index 1a5021b2cb..78b440c86b 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -69,11 +69,7 @@ new_macro (char *name, ELEMENT *macro)
   m->macro_name = strdup (name);
   m->element = macro;
 
-  tmp = new_element (ET_NONE);
-  tmp->contents = macro->contents;
-  m->macrobody = convert_to_texinfo (tmp);
-  tmp->contents.list = 0;
-  destroy_element (tmp);
+  m->macrobody = convert_contents_to_texinfo (macro);
 }
 
 /* CMD will be either CM_macro or CM_rmacro.  Read the line defining a macro's 



reply via email to

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