texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sun, 29 Sep 2024 03:01:54 -0400 (EDT)

branch: master
commit e96bd3f6db9ebcddcc7ea83830755761f9edac38
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Jun 7 12:26:00 2024 +0200

    * tp/Texinfo/XS/main/element_types.awk,
    tp/Texinfo/XS/main/element_types.txt, tp/Texinfo/XS/main/tree_types.h:
    add braces type flag, use it in element_types.awk.
    
    * tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash),
    tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi),
    tp/Texinfo/XS/parsetexi/macro.c (handle_macro),
    tp/Texinfo/XS/parsetexi/parser.c (gather_spaces_after_cmd_before_arg)
    (new_value_element): put spaces_after_cmd_before_arg in elt_info
    instead of info.
---
 ChangeLog                               | 13 +++++++++++++
 tp/Texinfo/XS/main/build_perl_info.c    | 23 ++++++++++++++---------
 tp/Texinfo/XS/main/convert_to_texinfo.c |  6 +++++-
 tp/Texinfo/XS/main/element_types.awk    | 12 +++++++-----
 tp/Texinfo/XS/main/element_types.c      | 14 +++++++-------
 tp/Texinfo/XS/main/element_types.txt    | 14 +++++++-------
 tp/Texinfo/XS/main/tree_types.h         |  2 +-
 tp/Texinfo/XS/main/types_data.h         |  1 +
 tp/Texinfo/XS/parsetexi/macro.c         |  5 ++---
 tp/Texinfo/XS/parsetexi/parser.c        |  8 ++++----
 10 files changed, 61 insertions(+), 37 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8b62764249..697f0f1cba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-06-07  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/element_types.awk,
+       tp/Texinfo/XS/main/element_types.txt, tp/Texinfo/XS/main/tree_types.h:
+       add braces type flag, use it in element_types.awk.
+
+       * tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash),
+       tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi),
+       tp/Texinfo/XS/parsetexi/macro.c (handle_macro),
+       tp/Texinfo/XS/parsetexi/parser.c (gather_spaces_after_cmd_before_arg)
+       (new_value_element): put spaces_after_cmd_before_arg in elt_info
+       instead of info.
+
 2024-06-07  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/element_types.awk: block_line_arg and line_arg
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 14d84b4800..42cfd9d97a 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -686,26 +686,31 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
     {
       ELEMENT *f = e->elt_info[eit_comment_at_end];
       if (f)
-        {
-          store_info_element (e, f, "info", "comment_at_end",
-                              avoid_recursion, &nr_info);
-        }
+        store_info_element (e, f, "info", "comment_at_end",
+                            avoid_recursion, &nr_info);
     }
 
   /* non-text elements */
 
-  store_additional_info (e, &e->c->info_info, "info", &nr_info,
-                         avoid_recursion);
-
   if (e->cmd)
     {
+      /* Note we could optimize the call to newSVpv here and
+         elsewhere by passing an appropriate second argument. */
       sv = newSVpv (element_command_name (e), 0);
       hv_store (e->hv, "cmdname", strlen ("cmdname"), sv, HSH_cmdname);
+    }
 
-      /* Note we could optimize the call to newSVpv here and
-         elsewhere by passing an appropriate second argument. */
+  if (type_data[e->type].flags & TF_braces)
+    {
+      ELEMENT *f = e->elt_info[eit_spaces_after_cmd_before_arg];
+      if (f)
+        store_info_element (e, f, "info", "spaces_after_cmd_before_arg",
+                            avoid_recursion, &nr_info);
     }
 
+  store_additional_info (e, &e->c->info_info, "info", &nr_info,
+                         avoid_recursion);
+
   if (e->c->contents.number > 0)
     {
       AV *av;
diff --git a/tp/Texinfo/XS/main/convert_to_texinfo.c 
b/tp/Texinfo/XS/main/convert_to_texinfo.c
index 6d120de0c7..6053e6fe05 100644
--- a/tp/Texinfo/XS/main/convert_to_texinfo.c
+++ b/tp/Texinfo/XS/main/convert_to_texinfo.c
@@ -54,7 +54,11 @@ expand_cmd_args_to_texi (const ELEMENT *e, TEXT *result)
     {
       const char *cmdname = element_command_name (e);
       ADD("@");  ADD(cmdname);
-      elt = lookup_info_element (e, "spaces_after_cmd_before_arg");
+    }
+
+  if (type_data[e->type].flags & TF_braces)
+    {
+      elt = e->elt_info[eit_spaces_after_cmd_before_arg];
       if (elt)
         ADD((char *)elt->text->text);
     }
diff --git a/tp/Texinfo/XS/main/element_types.awk 
b/tp/Texinfo/XS/main/element_types.awk
index acdb231982..b6acfd795c 100644
--- a/tp/Texinfo/XS/main/element_types.awk
+++ b/tp/Texinfo/XS/main/element_types.awk
@@ -59,18 +59,20 @@ END {
         t = types[line_idx]
         flags_str = ""
         elt_info_number = 0;
+        # spaces_after_cmd_before_arg
+        if (type_flags[t] != "" && match(type_flags[t], /braces/)) {
+          elt_info_number = 1;
+        }
         # line_command: spaces_before_argument
-        # block_line_arg: spaces_before_argument
-        if (t == "macro_call" || t == "rmacro_call" \
-                   || t == "brace_noarg_command" || t == "brace_command" \
-                   || t == "block_command" || t == "line_command" ) {
+        # block_command: spaces_before_argument
+        if (t == "block_command" || t == "line_command" ) {
           elt_info_number = 1;
         # block_line_arg and line_arg: comment_at_end, spaces_after_argument
         } else if (t == "brace_arg" || t == "bracketed_arg" \
                    || t == "block_line_arg" || t == "line_arg") {
           elt_info_number = 2;
         } else if (t == "context_brace_command") {
-          elt_info_number = 3;
+          elt_info_number += 2;
         }
         if (type_flags[t] != "") {
             split(type_flags[t], flags_array, ",")
diff --git a/tp/Texinfo/XS/main/element_types.c 
b/tp/Texinfo/XS/main/element_types.c
index e0a9b358b1..2327ea7752 100644
--- a/tp/Texinfo/XS/main/element_types.c
+++ b/tp/Texinfo/XS/main/element_types.c
@@ -5,16 +5,16 @@
 TYPE_DATA type_data[] = {
 0, 0, 0,
 "index_entry_command", 0, 0,
-"definfoenclose_command", 0, 0,
+"definfoenclose_command", TF_braces, 1,
 "nobrace_command", 0, 0,
-"brace_noarg_command", 0, 1,
+"brace_noarg_command", TF_braces, 1,
 "container_command", 0, 0,
 "lineraw_command", 0, 0,
 "line_command", 0, 1,
 "block_command", 0, 1,
-"brace_command", 0, 1,
-"brace_args_command", 0, 0,
-"context_brace_command", 0, 3,
+"brace_command", TF_braces, 1,
+"brace_args_command", TF_braces, 1,
+"context_brace_command", TF_braces, 3,
 "empty_line", TF_text, 0,
 "raw", TF_text, 0,
 "ignorable_spaces_after_command", TF_text, 0,
@@ -86,8 +86,8 @@ TYPE_DATA type_data[] = {
 "untranslated", TF_text, 0,
 "elided_rawpreformatted", 0, 0,
 "elided_brace_command_arg", 0, 0,
-"macro_call", 0, 1,
-"rmacro_call", 0, 1,
+"macro_call", TF_braces, 1,
+"rmacro_call", TF_braces, 1,
 "linemacro_call", 0, 0,
 "bracketed_linemacro_arg", TF_text, 0,
 "text", 0, 0,
diff --git a/tp/Texinfo/XS/main/element_types.txt 
b/tp/Texinfo/XS/main/element_types.txt
index f24bd7bb9d..faba8513e6 100644
--- a/tp/Texinfo/XS/main/element_types.txt
+++ b/tp/Texinfo/XS/main/element_types.txt
@@ -17,19 +17,19 @@
 
 # Types for @-commands
 index_entry_command
-definfoenclose_command
+definfoenclose_command                 braces
 
 # only in C
 nobrace_command
-brace_noarg_command
+brace_noarg_command                    braces
 # @item, @tab
 container_command
 lineraw_command
 line_command
 block_command
-brace_command
-brace_args_command
-context_brace_command
+brace_command                          braces
+brace_args_command                     braces
+context_brace_command                  braces
 
 # For text elements
 empty_line                                text
@@ -132,8 +132,8 @@ elided_rawpreformatted
 elided_brace_command_arg
 
 # for macro expansion source marks
-macro_call
-rmacro_call
+macro_call                                braces
+rmacro_call                               braces
 linemacro_call
 
 bracketed_linemacro_arg                    text
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index 0db1ea9253..4c802fa263 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -219,7 +219,7 @@ typedef struct CONTAINER {
 
 /* indices in ELEMENT elt_info */
 enum elt_info_type {
-  eit_spaces_after_cmd_before_arg,
+  eit_spaces_after_cmd_before_arg, /* types with braces flag */
   eit_comment_at_end = 0,
   eit_types_spaces_before_argument = 0,
   eit_spaces_before_argument,
diff --git a/tp/Texinfo/XS/main/types_data.h b/tp/Texinfo/XS/main/types_data.h
index 9c68f0a376..3c5abbd4f4 100644
--- a/tp/Texinfo/XS/main/types_data.h
+++ b/tp/Texinfo/XS/main/types_data.h
@@ -27,5 +27,6 @@ typedef struct types_struct {
 extern TYPE_DATA type_data[];
 
 #define TF_text               0x0001
+#define TF_braces             0x0002
 
 #endif
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index cabf19e0df..73b0eb2a51 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -854,9 +854,8 @@ handle_macro (ELEMENT *current, const char **line_inout, 
enum command_id cmd)
             {
               ELEMENT *spaces_element = new_text_element (ET_other_text);
               text_append_n (spaces_element->text, line, p - line);
-              add_info_element_oot (macro_call_element, 
"spaces_after_cmd_before_arg",
-                                    spaces_element);
-
+              macro_call_element->elt_info[eit_spaces_after_cmd_before_arg]
+               = spaces_element;
             }
           line = p;
           expand_macro_arguments (macro, &line, cmd, macro_call_element);
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 88b8b7a75f..799d2fe81a 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1097,8 +1097,8 @@ gather_spaces_after_cmd_before_arg (ELEMENT *current)
 {
   ELEMENT *spaces_element = pop_element_from_contents (current);
   spaces_element->type = ET_other_text;
-  add_info_element_oot (current, "spaces_after_cmd_before_arg",
-                        spaces_element);
+  current->elt_info[eit_spaces_after_cmd_before_arg]
+    = spaces_element;
 }
 
 static ELEMENT *
@@ -1114,8 +1114,8 @@ new_value_element (enum command_id cmd, const char *flag,
   add_to_element_args (value_elt, brace_container);
   add_to_element_contents (brace_container, value_text);
   if (spaces_element)
-    add_info_element_oot (value_elt, "spaces_after_cmd_before_arg",
-                                     spaces_element);
+    value_elt->elt_info[eit_spaces_after_cmd_before_arg]
+      = spaces_element;
   return value_elt;
 }
 



reply via email to

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