[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/floats.c (add_to_listoffloat
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/floats.c (add_to_listoffloats_list) (float_list_to_listoffloats_list, destroy_listoffloats_list), tp/Texinfo/XS/main/tree_types.h (LISTOFFLOATS_TYPE), tp/Texinfo/XS/structuring_transfo/structuring.c (number_floats): use ELEMENT_LIST for float_list in listoffloats data, directly and not as a pointer. Change add_to_listoffloats_list to return the listoffloats type if found, and create a new one otherwise. |
Date: |
Sun, 12 Nov 2023 16:20:21 -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 52af47ab1f * tp/Texinfo/XS/main/floats.c (add_to_listoffloats_list)
(float_list_to_listoffloats_list, destroy_listoffloats_list),
tp/Texinfo/XS/main/tree_types.h (LISTOFFLOATS_TYPE),
tp/Texinfo/XS/structuring_transfo/structuring.c (number_floats): use
ELEMENT_LIST for float_list in listoffloats data, directly and not as a
pointer. Change add_to_listoffloats_list to return the listoffloats type if
found, and create a new one otherwise.
52af47ab1f is described below
commit 52af47ab1f4be85e441b07a3024cdfae151ffb5b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 12 22:20:15 2023 +0100
* tp/Texinfo/XS/main/floats.c (add_to_listoffloats_list)
(float_list_to_listoffloats_list, destroy_listoffloats_list),
tp/Texinfo/XS/main/tree_types.h (LISTOFFLOATS_TYPE),
tp/Texinfo/XS/structuring_transfo/structuring.c (number_floats):
use ELEMENT_LIST for float_list in listoffloats data, directly and not
as a pointer. Change add_to_listoffloats_list to return the
listoffloats type if found, and create a new one otherwise.
---
ChangeLog | 10 ++++
tp/Texinfo/XS/main/floats.c | 69 +++++++++++++------------
tp/Texinfo/XS/main/tree_types.h | 2 +-
tp/Texinfo/XS/structuring_transfo/structuring.c | 4 +-
4 files changed, 48 insertions(+), 37 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 26500e21e3..7a15ed88ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-11-12 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/floats.c (add_to_listoffloats_list)
+ (float_list_to_listoffloats_list, destroy_listoffloats_list),
+ tp/Texinfo/XS/main/tree_types.h (LISTOFFLOATS_TYPE),
+ tp/Texinfo/XS/structuring_transfo/structuring.c (number_floats):
+ use ELEMENT_LIST for float_list in listoffloats data, directly and not
+ as a pointer. Change add_to_listoffloats_list to return the
+ listoffloats type if found, and create a new one otherwise.
+
2023-11-12 Patrice Dumas <pertusus@free.fr>
Separate types for list of floats and list of listoffloats
diff --git a/tp/Texinfo/XS/main/floats.c b/tp/Texinfo/XS/main/floats.c
index 168e20f822..ca116dcd47 100644
--- a/tp/Texinfo/XS/main/floats.c
+++ b/tp/Texinfo/XS/main/floats.c
@@ -50,22 +50,7 @@ add_to_float_record_list (FLOAT_RECORD_LIST *float_records,
char *type,
float_records->number++;
}
-void
-add_to_listoffloats_list (LISTOFFLOATS_TYPE_LIST *listoffloats_list, char
*type,
- ELEMENT *element)
-{
- if (listoffloats_list->number == listoffloats_list->space)
- {
- listoffloats_list->float_types
- = realloc (listoffloats_list->float_types,
- (listoffloats_list->space += 5) * sizeof
(LISTOFFLOATS_TYPE));
- }
- listoffloats_list->float_types[listoffloats_list->number].type = strdup
(type);
- listoffloats_list->float_types[listoffloats_list->number].float_list =
element;
- listoffloats_list->number++;
-}
-
-LISTOFFLOATS_TYPE *
+static LISTOFFLOATS_TYPE *
find_float_type (LISTOFFLOATS_TYPE_LIST *listoffloats_list, char *float_type)
{
size_t i;
@@ -78,6 +63,30 @@ find_float_type (LISTOFFLOATS_TYPE_LIST *listoffloats_list,
char *float_type)
return 0;
}
+static LISTOFFLOATS_TYPE *
+add_to_listoffloats_list (LISTOFFLOATS_TYPE_LIST *listoffloats_list, char
*type)
+{
+ LISTOFFLOATS_TYPE * result = find_float_type (listoffloats_list, type);
+
+ if (result)
+ return result;
+
+ if (listoffloats_list->number == listoffloats_list->space)
+ {
+ listoffloats_list->float_types
+ = realloc (listoffloats_list->float_types,
+ (listoffloats_list->space += 5) * sizeof
(LISTOFFLOATS_TYPE));
+ }
+
+ result = &listoffloats_list->float_types[listoffloats_list->number];
+ memset (result, 0, sizeof (LISTOFFLOATS_TYPE));
+ result->type = strdup (type);
+
+ listoffloats_list->number++;
+
+ return result;
+}
+
LISTOFFLOATS_TYPE_LIST *
float_list_to_listoffloats_list (FLOAT_RECORD_LIST *floats_list)
{
@@ -96,22 +105,12 @@ float_list_to_listoffloats_list (FLOAT_RECORD_LIST
*floats_list)
{
FLOAT_RECORD *float_record = &floats_list->list[i];
char *float_type = float_record->type;
- ELEMENT *listoffloats_floats;
-
- LISTOFFLOATS_TYPE *listoffloats_type_record = find_float_type
(result,
-
float_type);
- /* add a new container of floats by float_type */
- if (!listoffloats_type_record)
- {
- listoffloats_floats = new_element (ET_NONE);
- add_to_listoffloats_list (result, float_type,
- listoffloats_floats);
- }
- else
- listoffloats_floats = listoffloats_type_record->float_list;
-
- add_to_contents_as_array (listoffloats_floats,
- float_record->element);
+
+ LISTOFFLOATS_TYPE *listoffloats_type
+ = add_to_listoffloats_list (result, float_type);
+
+ add_to_element_list (&listoffloats_type->float_list,
+ float_record->element);
}
}
return result;
@@ -123,8 +122,10 @@ destroy_listoffloats_list (LISTOFFLOATS_TYPE_LIST
*listoffloats_list)
size_t i;
for (i = 0; i < listoffloats_list->number; i++)
{
- free (listoffloats_list->float_types[i].type);
- destroy_element (listoffloats_list->float_types[i].float_list);
+ LISTOFFLOATS_TYPE *listoffloats_type
+ = &listoffloats_list->float_types[i];
+ free (listoffloats_type->type);
+ free (listoffloats_type->float_list.list);
}
free (listoffloats_list->float_types);
free (listoffloats_list);
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index 1b06a8f731..6825115bd7 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -266,7 +266,7 @@ typedef struct {
typedef struct {
char *type;
- ELEMENT *float_list;
+ ELEMENT_LIST float_list;
} LISTOFFLOATS_TYPE;
typedef struct {
diff --git a/tp/Texinfo/XS/structuring_transfo/structuring.c
b/tp/Texinfo/XS/structuring_transfo/structuring.c
index 1e3e050bd6..a7c98dbb07 100644
--- a/tp/Texinfo/XS/structuring_transfo/structuring.c
+++ b/tp/Texinfo/XS/structuring_transfo/structuring.c
@@ -1588,10 +1588,10 @@ number_floats (DOCUMENT *document)
int nr_in_chapter = 0;
ELEMENT *current_chapter = 0;
size_t j;
- for (j = 0; j < listoffloats->float_list->contents.number; j++)
+ for (j = 0; j < listoffloats->float_list.number; j++)
{
static TEXT number;
- ELEMENT *float_elt = listoffloats->float_list->contents.list[j];
+ ELEMENT *float_elt = listoffloats->float_list.list[j];
char *normalized = lookup_extra_string (float_elt, "normalized");
ELEMENT *up;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/floats.c (add_to_listoffloats_list) (float_list_to_listoffloats_list, destroy_listoffloats_list), tp/Texinfo/XS/main/tree_types.h (LISTOFFLOATS_TYPE), tp/Texinfo/XS/structuring_transfo/structuring.c (number_floats): use ELEMENT_LIST for float_list in listoffloats data, directly and not as a pointer. Change add_to_listoffloats_list to return the listoffloats type if found, and create a new one otherwise.,
Patrice Dumas <=