[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 29 Sep 2024 08:34:55 -0400 (EDT) |
branch: master
commit 38e714b4fe9806fb3f62a9f1dbab9199049c2022
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jun 24 22:50:49 2024 +0200
* tp/Texinfo/XS/main/build_perl_info.c (build_perl_directions): rename
e as e_l, set an ELEMENT called e for more readable code.
* tp/Texinfo/XS/main/debug.c (print_associate_info_debug): add
extra_index_entry and extra_directions. Minor code improvements.
* tp/Texinfo/XS/main/debug.c (print_element_debug_details): access
extra_info only if not text element. Minor changes.
---
ChangeLog | 11 ++++++++
tp/Texinfo/XS/convert/convert_html.c | 4 +++
tp/Texinfo/XS/main/build_perl_info.c | 17 ++++++------
tp/Texinfo/XS/main/debug.c | 50 ++++++++++++++++++++++++++----------
tp/Texinfo/XS/parsetexi/parser.c | 2 +-
5 files changed, 61 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8ea7ecea8f..e9b2610d81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-06-24 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/build_perl_info.c (build_perl_directions): rename
+ e as e_l, set an ELEMENT called e for more readable code.
+
+ * tp/Texinfo/XS/main/debug.c (print_associate_info_debug): add
+ extra_index_entry and extra_directions. Minor code improvements.
+
+ * tp/Texinfo/XS/main/debug.c (print_element_debug_details): access
+ extra_info only if not text element. Minor changes.
+
2024-06-24 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/convert_to_text.h (TEXT_OPTIONS): use size_t for
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 758268781e..e549b81124 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -18518,6 +18518,10 @@ convert_to_html_internal (CONVERTER *self, const
ELEMENT *element,
text_append_n (&debug_str, " text(EMPTY)", 12);
}
text_append (&debug_str, "\n");
+ /*
+ text_printf (&debug_str, "DETAILS: %s",
+ print_element_debug_details (element, 0));
+ */
fprintf (stderr, "%s", debug_str.text);
free (debug_str.text);
}
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index fe3ed072d7..5c7d025fe7 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -224,7 +224,7 @@ build_perl_container (ELEMENT *e, int avoid_recursion)
}
static SV *
-build_perl_directions (const ELEMENT_LIST *e, int avoid_recursion)
+build_perl_directions (const ELEMENT_LIST *e_l, int avoid_recursion)
{
SV *sv;
HV *hv;
@@ -237,19 +237,20 @@ build_perl_directions (const ELEMENT_LIST *e, int
avoid_recursion)
for (d = 0; d < directions_length; d++)
{
- if (e->list[d])
+ if (e_l->list[d])
{
const char *key = direction_names[d];
- if (!e->list[d]->hv)
+ ELEMENT *e = e_l->list[d];
+ if (!e->hv)
{
- if (e->list[d]->parent)
- e->list[d]->hv = newHV ();
+ if (e->parent)
+ e->hv = newHV ();
else
{
/* NOTE This should not happen, all the elements are in-tree.
*/
static TEXT message;
- char *debug_str = print_element_debug (e->list[d], 1);
+ char *debug_str = print_element_debug (e, 1);
text_init (&message);
text_printf (&message,
"BUG: build_perl_directions oot %s: %s\n", key, debug_str);
@@ -260,11 +261,11 @@ build_perl_directions (const ELEMENT_LIST *e, int
avoid_recursion)
free (message.text);
/* Out-of-tree element */
/* WARNING: This is possibly recursive. */
- element_to_perl_hash (e->list[d], avoid_recursion);
+ element_to_perl_hash (e, avoid_recursion);
}
}
hv_store (hv, key, strlen (key),
- newRV_inc ((SV *) e->list[d]->hv), 0);
+ newRV_inc ((SV *) e->hv), 0);
}
}
return sv;
diff --git a/tp/Texinfo/XS/main/debug.c b/tp/Texinfo/XS/main/debug.c
index 72bcd1e100..080dbf2526 100644
--- a/tp/Texinfo/XS/main/debug.c
+++ b/tp/Texinfo/XS/main/debug.c
@@ -26,6 +26,8 @@
#include "types_data.h"
#include "extra.h"
#include "builtin_commands.h"
+/* for directions_length and direction_names */
+#include "utils.h"
#include "debug.h"
const char *
@@ -121,7 +123,6 @@ char *
print_associate_info_debug (const ASSOCIATED_INFO *info)
{
TEXT text;
- char *result;
int i;
text_init (&text);
@@ -134,7 +135,7 @@ print_associate_info_debug (const ASSOCIATED_INFO *info)
switch (info->info[i].type)
{
case extra_deleted:
- text_printf (&text, "deleted");
+ text_append (&text, "deleted");
break;
case extra_integer:
text_printf (&text, "integer: %d", k->k.integer);
@@ -163,6 +164,13 @@ print_associate_info_debug (const ASSOCIATED_INFO *info)
}
break;
}
+ case extra_index_entry:
+ {
+ const INDEX_ENTRY_LOCATION *entry_loc = k->k.index_entry;
+ text_printf (&text, "index_entry: %s, %d",
+ entry_loc->index_name, entry_loc->number);
+ break;
+ }
case extra_contents:
{
int j;
@@ -177,6 +185,24 @@ print_associate_info_debug (const ASSOCIATED_INFO *info)
}
break;
}
+ case extra_directions:
+ {
+ int d;
+ const ELEMENT_LIST *l = k->k.list;
+ text_append (&text, "directions: ");
+ for (d = 0; d < directions_length; d++)
+ {
+ if (l->list[d])
+ {
+ const char *d_key = direction_names[d];
+ const ELEMENT *e = l->list[d];
+ char *element_str = print_element_debug (e, 0);
+ text_printf (&text, "%s->%s|", d_key, element_str);
+ free (element_str);
+ }
+ }
+ break;
+ }
case extra_container:
{
int j;
@@ -191,7 +217,6 @@ print_associate_info_debug (const ASSOCIATED_INFO *info)
}
break;
}
- /* FIXME extra_index_entry not shown */
default:
text_printf (&text, "UNKNOWN (%d)", info->info[i].type);
break;
@@ -199,9 +224,7 @@ print_associate_info_debug (const ASSOCIATED_INFO *info)
text_append (&text, "\n");
}
- result = strdup (text.text);
- free (text.text);
- return result;
+ return text.text;
}
char *
@@ -209,21 +232,23 @@ print_element_debug_details (const ELEMENT *e, int
print_parent)
{
char *string = print_element_debug (e, print_parent);
TEXT text;
- char *result;
text_init (&text);
text_append (&text, string);
- text_append (&text, "\n");
+ free (string);
+ text_append_n (&text, "\n", 1);
- if (e->e.c->extra_info.info_number > 0)
+ if (!(type_data[e->type].flags & TF_text)
+ && e->e.c->extra_info.info_number > 0)
{
char *associated_info_str;
- text_append (&text, " EXTRA\n");
+ text_append_n (&text, " EXTRA\n", 7);
associated_info_str = print_associate_info_debug (&e->e.c->extra_info);
text_append (&text, associated_info_str);
free (associated_info_str);
}
+ /* TODO could print extra flags */
/* TODO could print elt_info and string_info arrays
if (e->e.c->info_info.info_number > 0)
{
@@ -231,9 +256,6 @@ print_element_debug_details (const ELEMENT *e, int
print_parent)
}
*/
- free (string);
- result = strdup (text.text);
- free (text.text);
- return result;
+ return text.text;
}
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index b9eea3cc99..3f9db9de32 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -414,7 +414,7 @@ register_global_command (ELEMENT *current)
}
/* setup a Texinfo tree with document_root as root and before_node_section
- as first content. Used for all the tree except for those obtained by
+ as first content. Used for the trees, except for those obtained by
parse_texi_line/parse_string. */
ELEMENT *
setup_document_root_and_before_node_section (void)