[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Fri, 4 Oct 2024 06:29:43 -0400 (EDT) |
branch: master
commit f16628c7324285527bc52c90f01170ace723436b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Aug 12 09:26:19 2024 +0200
* tp/Texinfo/XS/main/tree.c (insert_into_element_list)
(insert_into_contents, insert_into_args): have indices be size_t.
Remove the possibility to add at the end with a negative index, it is
not used and the caller should be able to compute the index.
---
ChangeLog | 7 +++++++
tp/Texinfo/XS/main/tree.c | 11 ++++-------
tp/Texinfo/XS/main/tree.h | 6 +++---
tp/Texinfo/XS/structuring_transfo/transformations.c | 2 +-
4 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 73462f25fb..6a7b99e277 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-08-12 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/tree.c (insert_into_element_list)
+ (insert_into_contents, insert_into_args): have indices be size_t.
+ Remove the possibility to add at the end with a negative index, it is
+ not used and the caller should be able to compute the index.
+
2024-08-12 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/converter.c (retrieve_converter)
diff --git a/tp/Texinfo/XS/main/tree.c b/tp/Texinfo/XS/main/tree.c
index e83f7816bf..2d6eb432bc 100644
--- a/tp/Texinfo/XS/main/tree.c
+++ b/tp/Texinfo/XS/main/tree.c
@@ -404,14 +404,11 @@ add_to_element_args (ELEMENT *parent, ELEMENT *e)
/* Add the element E into the LIST at index WHERE. */
void
-insert_into_element_list (ELEMENT_LIST *list, ELEMENT *e, int where)
+insert_into_element_list (ELEMENT_LIST *list, ELEMENT *e, size_t where)
{
reallocate_list (list);
- if (where < 0)
- where = list->number + where;
-
- if (where < 0 || where > list->number)
+ if (where > list->number)
fatal ("elements list index out of bounds");
memmove (&list->list[where + 1], &list->list[where],
@@ -422,7 +419,7 @@ insert_into_element_list (ELEMENT_LIST *list, ELEMENT *e,
int where)
/* Add the element E into the contents of PARENT at index WHERE. */
void
-insert_into_contents (ELEMENT *parent, ELEMENT *e, int where)
+insert_into_contents (ELEMENT *parent, ELEMENT *e, size_t where)
{
ELEMENT_LIST *list = &parent->e.c->contents;
insert_into_element_list (list, e, where);
@@ -431,7 +428,7 @@ insert_into_contents (ELEMENT *parent, ELEMENT *e, int
where)
/* Add the element E into the arguments of PARENT at index WHERE. */
void
-insert_into_args (ELEMENT *parent, ELEMENT *e, int where)
+insert_into_args (ELEMENT *parent, ELEMENT *e, size_t where)
{
ELEMENT_LIST *list = &parent->e.c->args;
insert_into_element_list (list, e, where);
diff --git a/tp/Texinfo/XS/main/tree.h b/tp/Texinfo/XS/main/tree.h
index 37fa561638..bee5c03ad8 100644
--- a/tp/Texinfo/XS/main/tree.h
+++ b/tp/Texinfo/XS/main/tree.h
@@ -18,9 +18,9 @@ void add_to_element_list (ELEMENT_LIST *list, ELEMENT *e);
void add_to_element_contents (ELEMENT *parent, ELEMENT *e);
void add_to_contents_as_array (ELEMENT *parent, ELEMENT *e);
void add_to_element_args (ELEMENT *parent, ELEMENT *e);
-void insert_into_element_list (ELEMENT_LIST *list, ELEMENT *e, int where);
-void insert_into_contents (ELEMENT *parent, ELEMENT *e, int where);
-void insert_into_args (ELEMENT *parent, ELEMENT *e, int where);
+void insert_into_element_list (ELEMENT_LIST *list, ELEMENT *e, size_t where);
+void insert_into_contents (ELEMENT *parent, ELEMENT *e, size_t where);
+void insert_into_args (ELEMENT *parent, ELEMENT *e, size_t where);
ELEMENT *remove_element_from_list (ELEMENT_LIST *list, const ELEMENT *e);
void add_element_if_not_in_list (ELEMENT_LIST *list, ELEMENT *e);
void insert_list_slice_into_list (ELEMENT_LIST *to, int where,
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index f8d927db4f..fd0dbdf361 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -1197,7 +1197,7 @@ regenerate_master_menu (DOCUMENT *document, int
use_sections)
for (i = 0; i < menus->number; i++)
{
- size_t detailmenu_index = 0;
+ size_t detailmenu_index;
/* cast to remove const to be able to replace the detailmenu */
ELEMENT *menu = (ELEMENT *)menus->list[i];
for (detailmenu_index = 0; detailmenu_index < menu->e.c->contents.number;