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/extra.c (lookup_extra_string


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/extra.c (lookup_extra_string) (lookup_extra_integer, lookup_extra_contents): more check of consistency of lookup_* function with extra_* type.
Date: Fri, 24 Nov 2023 16:18:03 -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 8b50540f89 * tp/Texinfo/XS/main/extra.c (lookup_extra_string) 
(lookup_extra_integer, lookup_extra_contents): more check of consistency of 
lookup_* function with extra_* type.
8b50540f89 is described below

commit 8b50540f89def57747d9d17666d464d67f9a5c46
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Nov 24 22:17:53 2023 +0100

    * tp/Texinfo/XS/main/extra.c (lookup_extra_string)
    (lookup_extra_integer, lookup_extra_contents): more check of
    consistency of lookup_* function with extra_* type.
---
 ChangeLog                  |  6 ++++++
 tp/Texinfo/XS/main/extra.c | 36 +++++++++++++++++++++++++++++++-----
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 75455b4f43..4613b3d06d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-11-24  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/extra.c (lookup_extra_string)
+       (lookup_extra_integer, lookup_extra_contents): more check of
+       consistency of lookup_* function with extra_* type.
+
 2023-11-24  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/output_unit.h (relative_unit_direction_name),
diff --git a/tp/Texinfo/XS/main/extra.c b/tp/Texinfo/XS/main/extra.c
index 1289a30792..720d0868f1 100644
--- a/tp/Texinfo/XS/main/extra.c
+++ b/tp/Texinfo/XS/main/extra.c
@@ -206,9 +206,22 @@ lookup_extra_string (const ELEMENT *e, char *key)
 {
   const KEY_PAIR *k;
   k = lookup_associated_info (&e->extra_info, key);
-  if (!k || !k->string)
+  if (!k)
     return 0;
-  return k->string;
+  else
+    {
+      if (k->type != extra_string)
+        {
+          char *msg;
+          xasprintf (&msg, "Bad type for lookup_extra_string: %s: %d",
+                     key, k->type);
+          fatal (msg);
+          free (msg);
+        }
+      if (!k->string)
+        return (0);
+      return k->string;
+    }
 }
 
 KEY_PAIR *
@@ -230,8 +243,11 @@ lookup_extra_integer (const ELEMENT *e, char *key, int 
*ret)
     }
   if (k->type != extra_integer)
     {
-      *ret = -2;
-      return 0;
+      char *msg;
+      xasprintf (&msg, "Bad type for lookup_extra_integer: %s: %d",
+                 key, k->type);
+      fatal (msg);
+      free (msg);
     }
   *ret = 0;
   return (int)k->integer;
@@ -244,7 +260,17 @@ lookup_extra_contents (ELEMENT *e, char *key, int create)
   ELEMENT_LIST *e_list = 0;
   KEY_PAIR *k = lookup_extra (e, key);
   if (k)
-    e_list = k->list;
+    {
+      if (k->type != extra_contents)
+        {
+          char *msg;
+          xasprintf (&msg, "Bad type for lookup_extra_contents: %s: %d",
+                     key, k->type);
+          fatal (msg);
+          free (msg);
+        }
+      e_list = k->list;
+    }
   else if (create)
     {
       e_list = new_list ();



reply via email to

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