[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 647cdfcc653bdb2a640005d6ec75d41f385fdb11
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Aug 12 09:38:47 2024 +0200
* tp/Texinfo/XS/main/tree.c (list_set_empty_contents)
(remove_from_element_list, remove_from_const_element_list)
(remove_from_contents, remove_from_args): use size_t for indices.
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 | 8 ++++++++
tp/Texinfo/XS/main/extra.c | 2 +-
tp/Texinfo/XS/main/tree.c | 23 +++++++++--------------
tp/Texinfo/XS/main/tree.h | 10 +++++-----
4 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6a7b99e277..85dbc7b01f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-08-12 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/tree.c (list_set_empty_contents)
+ (remove_from_element_list, remove_from_const_element_list)
+ (remove_from_contents, remove_from_args): use size_t for indices.
+ 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/main/tree.c (insert_into_element_list)
diff --git a/tp/Texinfo/XS/main/extra.c b/tp/Texinfo/XS/main/extra.c
index 6f424f8da5..9161060113 100644
--- a/tp/Texinfo/XS/main/extra.c
+++ b/tp/Texinfo/XS/main/extra.c
@@ -19,7 +19,7 @@
#include <stdio.h>
#include "tree_types.h"
-/* for new_list list_set_empty_contents */
+/* for new_list */
#include "tree.h"
/* for fatal and directions_length */
#include "utils.h"
diff --git a/tp/Texinfo/XS/main/tree.c b/tp/Texinfo/XS/main/tree.c
index 2d6eb432bc..d14ec324c1 100644
--- a/tp/Texinfo/XS/main/tree.c
+++ b/tp/Texinfo/XS/main/tree.c
@@ -483,10 +483,11 @@ insert_list_slice_into_contents (ELEMENT *to, int where,
ELEMENT_LIST *from,
}
/* ensure that there are n slots, and void them */
+/* Unused */
void
-list_set_empty_contents (ELEMENT_LIST *e_list, int n)
+list_set_empty_contents (ELEMENT_LIST *e_list, size_t n)
{
- int i;
+ size_t i;
if (n <= 0)
return;
@@ -500,14 +501,11 @@ list_set_empty_contents (ELEMENT_LIST *e_list, int n)
}
ELEMENT *
-remove_from_element_list (ELEMENT_LIST *list, int where)
+remove_from_element_list (ELEMENT_LIST *list, size_t where)
{
ELEMENT *removed;
- if (where < 0)
- where = list->number + where;
-
- if (where < 0 || where > list->number -1)
+ if (where > list->number -1)
fatal ("element list index out of bounds");
removed = list->list[where];
@@ -519,14 +517,11 @@ remove_from_element_list (ELEMENT_LIST *list, int where)
}
const ELEMENT *
-remove_from_const_element_list (CONST_ELEMENT_LIST *list, int where)
+remove_from_const_element_list (CONST_ELEMENT_LIST *list, size_t where)
{
const ELEMENT *removed;
- if (where < 0)
- where = list->number + where;
-
- if (where < 0 || where > list->number -1)
+ if (where > list->number -1)
fatal ("element list index out of bounds");
removed = list->list[where];
@@ -538,14 +533,14 @@ remove_from_const_element_list (CONST_ELEMENT_LIST *list,
int where)
}
ELEMENT *
-remove_from_contents (ELEMENT *parent, int where)
+remove_from_contents (ELEMENT *parent, size_t where)
{
ELEMENT_LIST *list = &parent->e.c->contents;
return remove_from_element_list (list, where);
}
ELEMENT *
-remove_from_args (ELEMENT *parent, int where)
+remove_from_args (ELEMENT *parent, size_t where)
{
ELEMENT_LIST *list = &parent->e.c->args;
return remove_from_element_list (list, where);
diff --git a/tp/Texinfo/XS/main/tree.h b/tp/Texinfo/XS/main/tree.h
index bee5c03ad8..f02cc23b37 100644
--- a/tp/Texinfo/XS/main/tree.h
+++ b/tp/Texinfo/XS/main/tree.h
@@ -31,12 +31,12 @@ void insert_list_slice_into_contents (ELEMENT *to, int idx,
ELEMENT_LIST *from,
int start, int end);
void insert_list_slice_into_args (ELEMENT *to, int where, ELEMENT_LIST *from,
int start, int end);
-void list_set_empty_contents (ELEMENT_LIST *e_list, int n);
-ELEMENT *remove_from_element_list (ELEMENT_LIST *list, int where);
+void list_set_empty_contents (ELEMENT_LIST *e_list, size_t n);
+ELEMENT *remove_from_element_list (ELEMENT_LIST *list, size_t where);
const ELEMENT *remove_from_const_element_list (CONST_ELEMENT_LIST *list,
- int where);
-ELEMENT *remove_from_contents (ELEMENT *parent, int where);
-ELEMENT *remove_from_args (ELEMENT *parent, int where);
+ size_t where);
+ELEMENT *remove_from_contents (ELEMENT *parent, size_t where);
+ELEMENT *remove_from_args (ELEMENT *parent, size_t where);
void remove_slice_from_contents (ELEMENT *parent, int start, int end);
ELEMENT *last_args_child (const ELEMENT *current);
ELEMENT *last_contents_child (const ELEMENT *current);