texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Fri, 10 May 2024 18:43:10 -0400 (EDT)

branch: master
commit a19ee6a3c8ae9a144042de6011212d40fa2cf753
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat May 11 00:40:31 2024 +0200

    * tp/Texinfo/XS/parsetexi/def.c (DEF_MAP, parse_def),
    tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line): remove
    arguments field from DEF_MAP, have parse_def return an array of
    ELEMENT and use the type of elements in end_line_def_line instead
    of a string.
---
 ChangeLog                          |  8 +++++
 tp/Texinfo/XS/parsetexi/def.c      | 60 ++++++++++----------------------------
 tp/Texinfo/XS/parsetexi/def.h      |  2 +-
 tp/Texinfo/XS/parsetexi/end_line.c | 18 +++++-------
 4 files changed, 33 insertions(+), 55 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 89aa574ccd..50d9a55a36 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-05-10  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/parsetexi/def.c (DEF_MAP, parse_def),
+       tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line): remove
+       arguments field from DEF_MAP, have parse_def return an array of
+       ELEMENT and use the type of elements in end_line_def_line instead
+       of a string.
+
 2024-05-10  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_split_delimiters, _split_def_args)
diff --git a/tp/Texinfo/XS/parsetexi/def.c b/tp/Texinfo/XS/parsetexi/def.c
index 5cc8f70a3a..742a4e9b18 100644
--- a/tp/Texinfo/XS/parsetexi/def.c
+++ b/tp/Texinfo/XS/parsetexi/def.c
@@ -152,7 +152,6 @@ next_bracketed_or_word_agg (ELEMENT *current, int *i)
 
 typedef struct {
     enum command_id command;
-    char **arguments;
     enum command_id *argument_types;
 } DEF_MAP;
 
@@ -164,17 +163,6 @@ typedef struct {
      NAME - name of entity being documented
      ARGUMENTS - arguments to a function or macro                  */
 
-char *defline_arguments[] = {"category", "name", "arg", 0};
-char *deftypeline_arguments[] = {"category", "type", "name", "argtype", 0};
-char *defvr_arguments[] = {"category", "name", 0};
-char *deftypefn_arguments[] = {"category", "type", "name", "argtype", 0};
-char *deftypeop_arguments[] = {"category", "class" , "type", "name", 
"argtype", 0};
-char *deftypevr_arguments[] = {"category", "type", "name", 0};
-char *defcv_arguments[] = {"category", "class" , "name", 0};
-char *deftypecv_arguments[] = {"category", "class" , "type", "name", 0};
-char *defop_arguments[] = {"category", "class" , "name", "arg", 0};
-char *deftp_arguments[] = {"category", "name", "argtype", 0};
-
 enum command_id defline_types[] = {ET_def_category, ET_def_name, ET_def_arg, 
0};
 enum command_id deftypeline_types[] = {ET_def_category, ET_def_type, 
ET_def_name, ET_def_typearg, 0};
 enum command_id defvr_types[] = {ET_def_category, ET_def_name, 0};
@@ -187,17 +175,17 @@ enum command_id defop_types[] = {ET_def_category, 
ET_def_class , ET_def_name, ET
 enum command_id deftp_types[] = {ET_def_category, ET_def_name, ET_def_typearg, 
0};
 
 DEF_MAP def_maps[] = {
-  CM_defline, defline_arguments, defline_types,
-  CM_deftypeline, deftypeline_arguments, deftypeline_types,
-  CM_deffn, defline_arguments, defline_types,
-  CM_defvr, defvr_arguments, defvr_types,
-  CM_deftypefn, deftypefn_arguments, deftypefn_types,
-  CM_deftypeop, deftypeop_arguments, deftypeop_types,
-  CM_deftypevr, deftypevr_arguments, deftypevr_types,
-  CM_defcv, defcv_arguments, defcv_types,
-  CM_deftypecv, deftypecv_arguments, deftypecv_types,
-  CM_defop, defop_arguments, defop_types,
-  CM_deftp, deftp_arguments, deftp_types,
+  CM_defline, defline_types,
+  CM_deftypeline, deftypeline_types,
+  CM_deffn, defline_types,
+  CM_defvr, defvr_types,
+  CM_deftypefn, deftypefn_types,
+  CM_deftypeop, deftypeop_types,
+  CM_deftypevr, deftypevr_types,
+  CM_defcv, defcv_types,
+  CM_deftypecv, deftypecv_types,
+  CM_defop, defop_types,
+  CM_deftp, deftp_types,
 };
 
 /* Split non-space text elements into strings without [ ] ( ) , and single
@@ -369,7 +357,7 @@ split_def_args (ELEMENT *current, int starting_idx)
     }
 }
 
-DEF_ARG **
+ELEMENT **
 parse_def (enum command_id command, ELEMENT *current)
 {
   int contents_idx = 0;
@@ -377,8 +365,7 @@ parse_def (enum command_id command, ELEMENT *current)
   int i, i_def;
   int arg_types_nr;
   ELEMENT *e, *e1;
-  DEF_ARG **result;
-  char **arguments_list;
+  ELEMENT **result;
   enum command_id *arguments_types_list;
   int inserted_category = 0;
 
@@ -437,9 +424,8 @@ parse_def (enum command_id command, ELEMENT *current)
 
   /* determine non arg/argtype number of arguments */
   arg_types_nr = 0;
-  arguments_list = def_maps[i_def].arguments;
   arguments_types_list = def_maps[i_def].argument_types;
-  while (arguments_list[arg_types_nr])
+  while (arguments_types_list[arg_types_nr])
     {
       enum element_type arg_type = arguments_types_list[arg_types_nr];
 
@@ -447,7 +433,7 @@ parse_def (enum command_id command, ELEMENT *current)
         break;
       arg_types_nr++;
     }
-  result = malloc ((arg_types_nr+1) * sizeof (DEF_ARG *));
+  result = malloc ((arg_types_nr+1) * sizeof (ELEMENT *));
 
   for (i = 0; i < arg_types_nr; i++)
     {
@@ -455,17 +441,13 @@ parse_def (enum command_id command, ELEMENT *current)
 
       if (e)
         {
-          char *arg_type_name = arguments_list[i];
           enum element_type arg_type = arguments_types_list[i];
-          DEF_ARG *def_arg = malloc (sizeof (DEF_ARG));
           ELEMENT *new_def_type = new_element (arg_type);
 
           new_def_type->parent = e->parent;
           current->contents.list[contents_idx - 1] = new_def_type;
           add_to_element_contents (new_def_type, e);
-          result[i] = def_arg;
-          def_arg->arg_type = strdup(arg_type_name);
-          def_arg->element = new_def_type;
+          result[i] = new_def_type;
         }
       else
         break;
@@ -473,16 +455,6 @@ parse_def (enum command_id command, ELEMENT *current)
 
   result[i] = 0;
 
-  for (i = 0; i < arg_types_nr; i++)
-    {
-      if (result[i])
-        {
-          DEF_ARG *def_arg = result[i];
-        }
-      else
-        break;
-    }
-
   if (inserted_category)
     {
       add_info_integer (current->contents.list[0], "inserted", 1);
diff --git a/tp/Texinfo/XS/parsetexi/def.h b/tp/Texinfo/XS/parsetexi/def.h
index 906b744038..cbb864114e 100644
--- a/tp/Texinfo/XS/parsetexi/def.h
+++ b/tp/Texinfo/XS/parsetexi/def.h
@@ -5,5 +5,5 @@
 #include "tree_types.h"
 
 void gather_def_item (ELEMENT *current, enum command_id next_command);
-DEF_ARG **parse_def (enum command_id command, ELEMENT *current);
+ELEMENT **parse_def (enum command_id command, ELEMENT *current);
 #endif
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c 
b/tp/Texinfo/XS/parsetexi/end_line.c
index 1744a7d778..40e41a2473 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -661,7 +661,7 @@ ELEMENT *
 end_line_def_line (ELEMENT *current)
 {
   enum command_id def_command;
-  DEF_ARG **def_info = 0;
+  ELEMENT **def_info = 0;
   char *def_cmdname;
   ELEMENT *index_entry = 0; /* Index entry text. */
   ELEMENT *def_info_name = 0;
@@ -687,16 +687,14 @@ end_line_def_line (ELEMENT *current)
 
   /* Record the index entry if def_info is not empty. */
 
-  while (def_info[i] != 0 && def_info[i]->element != 0)
+  while (def_info[i] != 0)
     {
-      if (!strcmp(def_info[i]->arg_type, "name"))
-        def_info_name = def_info[i]->element;
-      else if (!strcmp(def_info[i]->arg_type, "class"))
-        def_info_class = def_info[i]->element;
-      else if (!strcmp(def_info[i]->arg_type, "category"))
-        def_info_category = def_info[i]->element;
-      free (def_info[i]->arg_type);
-      free (def_info[i]);
+      if (def_info[i]->type == ET_def_name)
+        def_info_name = def_info[i];
+      else if (def_info[i]->type == ET_def_class)
+        def_info_class = def_info[i];
+      else if (def_info[i]->type == ET_def_category)
+        def_info_category = def_info[i];
       i++;
     }
   free (def_info);



reply via email to

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