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, 24 Nov 2023 11:52:20 -0500 (EST)

branch: master
commit 100e1e40967f86542587879659f8d4ab2b75f570
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Nov 24 17:52:04 2023 +0100

    * tp/Texinfo/XS/main/build_perl_info.c (store_additional_info): readd
    cast to intptr_t, as it should be tested on the platforms where it
    could matter.
    
    * tp/Texinfo/XS/main/extra.c (lookup_info_string): add
    lookup_info_string.
    
    * tp/Texinfo/XS/main/builtin_commands.c (element_command_name),
    tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi),
    tp/Texinfo/XS/parsetexi/close.c (close_brace_command),
    tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): use
    lookup_info_string.
---
 ChangeLog                               | 15 +++++++++++++++
 tp/Texinfo/XS/main/build_perl_info.c    |  4 ++--
 tp/Texinfo/XS/main/builtin_commands.c   |  6 ++----
 tp/Texinfo/XS/main/convert_to_texinfo.c | 20 +++++++-------------
 tp/Texinfo/XS/main/extra.c              | 10 ++++++++++
 tp/Texinfo/XS/main/extra.h              |  1 +
 tp/Texinfo/XS/parsetexi/close.c         |  6 +++---
 tp/Texinfo/XS/parsetexi/parser.c        |  3 +--
 8 files changed, 41 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7db3ff50bc..bf9d61fffb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-11-24  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/build_perl_info.c (store_additional_info): readd
+       cast to intptr_t, as it should be tested on the platforms where it
+       could matter.
+
+       * tp/Texinfo/XS/main/extra.c (lookup_info_string): add
+       lookup_info_string.
+
+       * tp/Texinfo/XS/main/builtin_commands.c (element_command_name),
+       tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi),
+       tp/Texinfo/XS/parsetexi/close.c (close_brace_command),
+       tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): use
+       lookup_info_string.
+
 2023-11-24  Patrice Dumas  <pertusus@free.fr>
 
        Use an union for KEY_PAIR value.
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 735c8cb3b7..cd79b9e871 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -331,7 +331,7 @@ store_additional_info (const ELEMENT *e, ASSOCIATED_INFO* 
a, char *key)
               { /* A simple integer.  The intptr_t cast here prevents
                    a warning on MinGW ("cast from pointer to integer of
                    different size"). */
-              IV value = (IV) k->integer;
+              IV value = (IV) (intptr_t) k->integer;
               STORE(newSViv (value));
               break;
               }
@@ -350,7 +350,7 @@ store_additional_info (const ELEMENT *e, ASSOCIATED_INFO* 
a, char *key)
                   k_integer = lookup_extra (f->contents.list[j], "integer");
                   if (k_integer)
                     {
-                      IV value = (IV) k_integer->integer;
+                      IV value = (IV) (intptr_t) k_integer->integer;
                       av_store (av, j, newSViv (value));
                     }
                   else if (f->contents.list[j]->text.end > 0)
diff --git a/tp/Texinfo/XS/main/builtin_commands.c 
b/tp/Texinfo/XS/main/builtin_commands.c
index 5661c25530..96ace973b8 100644
--- a/tp/Texinfo/XS/main/builtin_commands.c
+++ b/tp/Texinfo/XS/main/builtin_commands.c
@@ -70,10 +70,8 @@ element_command_name (const ELEMENT *e)
     return builtin_command_data[e->cmd].cmdname;
   else
     {
-      KEY_PAIR *k_cmdname;
-      k_cmdname = lookup_info (e, "command_name");
-      if (k_cmdname && k_cmdname->string)
-        return k_cmdname->string;
+      char *cmdname = lookup_info_string (e, "command_name");
+      return cmdname;
     }
 
   return 0;
diff --git a/tp/Texinfo/XS/main/convert_to_texinfo.c 
b/tp/Texinfo/XS/main/convert_to_texinfo.c
index e2419e8a23..a0e15cc5f2 100644
--- a/tp/Texinfo/XS/main/convert_to_texinfo.c
+++ b/tp/Texinfo/XS/main/convert_to_texinfo.c
@@ -45,7 +45,7 @@ static void
 expand_cmd_args_to_texi (const ELEMENT *e, TEXT *result)
 {
   enum command_id cmd = element_builtin_cmd (e);
-  KEY_PAIR *arg_line;
+  char *arg_line;
   ELEMENT *elt, *spc_before_arg;
 
   if (cmd)
@@ -59,19 +59,13 @@ expand_cmd_args_to_texi (const ELEMENT *e, TEXT *result)
 
   spc_before_arg = lookup_info_element (e, "spaces_before_argument");
 
-  arg_line = lookup_info (e, "arg_line");
+  arg_line = lookup_info_string (e, "arg_line");
   if (arg_line)
     {
-      char *s = 0;
-
       if (spc_before_arg)
         ADD((char *)spc_before_arg->text.text);
 
-      s = arg_line->string;
-      if (s)
-        {
-          ADD(s);
-        }
+      ADD(arg_line);
     }
   else if (e->args.number > 0)
     {
@@ -85,8 +79,8 @@ expand_cmd_args_to_texi (const ELEMENT *e, TEXT *result)
 
       if (cmd == CM_verb)
         {
-          KEY_PAIR *k_delimiter = lookup_info (e, "delimiter");
-          ADD(k_delimiter->string);
+          char *delimiter = lookup_info_string (e, "delimiter");
+          ADD(delimiter);
         }
 
       if (spc_before_arg)
@@ -120,8 +114,8 @@ expand_cmd_args_to_texi (const ELEMENT *e, TEXT *result)
 
       if (cmd == CM_verb)
         {
-          KEY_PAIR *k_delimiter = lookup_info (e, "delimiter");
-          ADD(k_delimiter->string);
+          char *delimiter = lookup_info_string (e, "delimiter");
+          ADD(delimiter);
         }
 
       if (braces)
diff --git a/tp/Texinfo/XS/main/extra.c b/tp/Texinfo/XS/main/extra.c
index b850e096da..0b5542e85f 100644
--- a/tp/Texinfo/XS/main/extra.c
+++ b/tp/Texinfo/XS/main/extra.c
@@ -273,6 +273,16 @@ lookup_info (const ELEMENT *e, char *key)
   return lookup_associated_info (&e->info_info, key);
 }
 
+char *
+lookup_info_string (const ELEMENT *e, char *key)
+{
+  const KEY_PAIR *k;
+  k = lookup_associated_info (&e->info_info, key);
+  if (!k || !k->string)
+    return 0;
+  return k->string;
+}
+
 /* only called in tree copy to optimize for speed */
 KEY_PAIR *
 lookup_associated_info_by_index (const ASSOCIATED_INFO *a, char *key, int 
index)
diff --git a/tp/Texinfo/XS/main/extra.h b/tp/Texinfo/XS/main/extra.h
index 9ed63e14e9..772bfb9af1 100644
--- a/tp/Texinfo/XS/main/extra.h
+++ b/tp/Texinfo/XS/main/extra.h
@@ -40,6 +40,7 @@ ELEMENT *lookup_extra_contents (ELEMENT *e, char *key, int 
create);
 ELEMENT *lookup_extra_directions (ELEMENT *e, char *key, int create);
 int lookup_extra_integer (const ELEMENT *e, char *key, int *ret);
 char *lookup_extra_string (const ELEMENT *e, char *key);
+char *lookup_info_string (const ELEMENT *e, char *key);
 
 KEY_PAIR *lookup_associated_info (const ASSOCIATED_INFO *a, char *key);
 
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index 5667780564..f19863ca53 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -67,8 +67,8 @@ close_brace_command (ELEMENT *current,
 
   if (current->cmd != CM_verb)
     goto yes;
-  k_delimiter = lookup_info (current, "delimiter");
-  if (!k_delimiter || !*k_delimiter->string)
+  delimiter = lookup_info_string (current, "delimiter");
+  if (!delimiter || !*delimiter)
     goto yes;
   if (0)
     {
@@ -93,7 +93,7 @@ close_brace_command (ELEMENT *current,
       command_error (current,
                       "@%s missing closing delimiter sequence: %s}",
                       command_name(current->cmd),
-                      k_delimiter->string);
+                      delimiter);
     }
   current = current->parent;
   return current;
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 02256872ee..b157937e58 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1604,8 +1604,7 @@ process_remaining_on_line (ELEMENT **current_inout, char 
**line_inout)
     {
       char *q;
 
-      KEY_PAIR *k_delimiter = lookup_info (current->parent, "delimiter");
-      char *delimiter = k_delimiter->string;
+      char *delimiter = lookup_info_string (current->parent, "delimiter");
 
       if (strcmp (delimiter, ""))
         {



reply via email to

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