[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/utils.c (section_level), tp
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/utils.c (section_level), tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block) (end_line_misc_line), tp/Texinfo/XS/parsetexi/handle_commands.c (handle_other_command), tp/Texinfo/XS/parsetexi/separator.c (handle_comma): use lookup_extra_* functions with a specific type and dynaic type checking, when possible. |
Date: |
Sun, 26 Nov 2023 08:21:39 -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 37db08acdd * tp/Texinfo/XS/main/utils.c (section_level),
tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block)
(end_line_misc_line), tp/Texinfo/XS/parsetexi/handle_commands.c
(handle_other_command), tp/Texinfo/XS/parsetexi/separator.c (handle_comma): use
lookup_extra_* functions with a specific type and dynaic type checking, when
possible.
37db08acdd is described below
commit 37db08acddc2ad6deac11e1b6f17ac7754ac78ed
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 26 14:21:31 2023 +0100
* tp/Texinfo/XS/main/utils.c (section_level),
tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block)
(end_line_misc_line), tp/Texinfo/XS/parsetexi/handle_commands.c
(handle_other_command), tp/Texinfo/XS/parsetexi/separator.c
(handle_comma): use lookup_extra_* functions with a specific type and
dynaic type checking, when possible.
* tp/Texinfo/XS/parsetexi/macro.c: reindent.
* tp/Texinfo/XS/parsetexi/separator.c (handle_open_brace): use a
variable name for clearer code.
---
ChangeLog | 14 ++++++++++++++
tp/Texinfo/XS/main/utils.c | 7 ++++---
tp/Texinfo/XS/parsetexi/end_line.c | 18 +++++++++---------
tp/Texinfo/XS/parsetexi/handle_commands.c | 13 ++++++-------
tp/Texinfo/XS/parsetexi/macro.c | 10 +++-------
tp/Texinfo/XS/parsetexi/separator.c | 22 +++++++++++-----------
6 files changed, 47 insertions(+), 37 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7b41967a76..978f64ce6d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-11-26 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/utils.c (section_level),
+ tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block)
+ (end_line_misc_line), tp/Texinfo/XS/parsetexi/handle_commands.c
+ (handle_other_command), tp/Texinfo/XS/parsetexi/separator.c
+ (handle_comma): use lookup_extra_* functions with a specific type and
+ dynaic type checking, when possible.
+
+ * tp/Texinfo/XS/parsetexi/macro.c: reindent.
+
+ * tp/Texinfo/XS/parsetexi/separator.c (handle_open_brace): use a
+ variable name for clearer code.
+
2023-11-25 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/debug.c (print_associate_info_debug),
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index b562cb6e28..3298e5e377 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -1123,10 +1123,11 @@ int
section_level (const ELEMENT *section)
{
int level = command_structuring_level[section->cmd];
- KEY_PAIR *k_level_modifier = lookup_extra (section, "level_modifier");
- if (k_level_modifier && level >= 0)
+ int status;
+ int section_modifier = lookup_extra_integer (section, "level_modifier",
+ &status);
+ if (!status && level >= 0)
{
- int section_modifier = k_level_modifier->integer;
level -= section_modifier;
if (level < min_level)
if (command_structuring_level[section->cmd] < min_level)
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index 380355a058..7bdc8fa836 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -773,9 +773,9 @@ end_line_starting_block (ELEMENT *current)
&& (k = lookup_extra (current->parent, "columnfractions")))
{
ELEMENT *misc_cmd = k->element;
- ELEMENT *misc_args;
+ ELEMENT *misc_args = lookup_extra_element (misc_cmd, "misc_args");
- if ((misc_args = lookup_extra_element (misc_cmd, "misc_args")))
+ if (misc_args)
{
add_extra_integer (current->parent, "max_columns",
misc_args->contents.number);
@@ -1003,7 +1003,7 @@ end_line_starting_block (ELEMENT *current)
add_extra_element (current, "command_as_argument", e);
}
else if (command_data(command).data == BLOCK_item_line
- && !lookup_extra (current, "command_as_argument"))
+ && !lookup_extra_element (current, "command_as_argument"))
{
ELEMENT *e;
@@ -1514,7 +1514,7 @@ end_line_misc_line (ELEMENT *current)
check_register_target_element_label (label_element, current);
if (current_part
- && !lookup_extra (current_part, "part_associated_section"))
+ && !lookup_extra_element (current_part, "part_associated_section"))
{
/* we only associate a part to the following node if the
part is not already associate to a sectioning command,
@@ -1567,9 +1567,9 @@ end_line_misc_line (ELEMENT *current)
if ((command_flags(current) & CF_index_entry_command
|| current->cmd == CM_subentry))
{
- if (lookup_extra (current, "sortas")
- || lookup_extra (current, "seealso")
- || lookup_extra (current, "seeentry"))
+ if (lookup_extra_string (current, "sortas")
+ || lookup_extra_element (current, "seealso")
+ || lookup_extra_element (current, "seeentry"))
set_non_ignored_space_in_index_before_command(current->args.list[0]);
}
}
@@ -1695,7 +1695,7 @@ end_line_misc_line (ELEMENT *current)
{
if (current_node)
{
- if (!lookup_extra (current_node, "associated_section"))
+ if (!lookup_extra_element (current_node, "associated_section"))
{
add_extra_element
(current_node, "associated_section", current);
@@ -1723,7 +1723,7 @@ end_line_misc_line (ELEMENT *current)
{
current_part = current;
if (current_node
- && !lookup_extra (current_node, "associated_section"))
+ && !lookup_extra_element (current_node, "associated_section"))
{
line_warn ("@node precedes @part, but parts may not be "
"associated with nodes");
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index b3700958c5..969e1e9a05 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -416,13 +416,12 @@ handle_other_command (ELEMENT *current, char **line_inout,
/* In a @multitable */
else if ((parent = item_multitable_parent (current)))
{
- int max_columns = 0;
- KEY_PAIR *k_max_columns;
-
- k_max_columns = lookup_extra (parent, "max_columns");
- if (k_max_columns)
- max_columns = k_max_columns->integer;
-
+ int status;
+ /* no need to check status, as max_columns would be set to 0 if
+ is was not found, which is correct. max_columns not found is
+ not possible, anyway, so it does not matter at all. */
+ int max_columns = lookup_extra_integer (parent, "max_columns",
+ &status);
if (max_columns == 0)
{
line_warn ("@%s in empty multitable",
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index 7fd73c1257..5e2a4387ac 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -451,12 +451,9 @@ funexit:
void
set_toplevel_braces_nr (COUNTER *counter, ELEMENT* element)
{
- int toplevel_braces_nr = counter_value (counter,
- element);
+ int toplevel_braces_nr = counter_value (counter, element);
if (toplevel_braces_nr)
- add_extra_integer (element,
- "toplevel_braces_nr",
- toplevel_braces_nr);
+ add_extra_integer (element, "toplevel_braces_nr", toplevel_braces_nr);
counter_pop (counter);
}
@@ -629,8 +626,7 @@ expand_linemacro_arguments (ELEMENT *macro, char
**line_inout,
}
funexit:
- set_toplevel_braces_nr (&count_toplevel_braces,
- argument_content);
+ set_toplevel_braces_nr (&count_toplevel_braces, argument_content);
for (i = 0; i < current->args.number; i++)
{
ELEMENT *argument_content = current->args.list[i]->contents.list[0];
diff --git a/tp/Texinfo/XS/parsetexi/separator.c
b/tp/Texinfo/XS/parsetexi/separator.c
index 5bfd6dd4ed..b6c7c3bbf5 100644
--- a/tp/Texinfo/XS/parsetexi/separator.c
+++ b/tp/Texinfo/XS/parsetexi/separator.c
@@ -102,6 +102,7 @@ handle_open_brace (ELEMENT *current, char **line_inout)
{
#define float floatxx
ELEMENT *float;
+ char *caption_cmdname = command_name(command);
nesting_context.caption++;
if (!current->parent->parent
|| current->parent->parent->cmd != CM_float)
@@ -113,25 +114,25 @@ handle_open_brace (ELEMENT *current, char **line_inout)
{
line_error ("@%s is not meaningful outside "
"`@float' environment",
- command_name(command));
+ caption_cmdname);
float = 0;
}
else
- line_warn ("@%s should be right below `@float'",
- command_name(command));
+ line_warn ("@%s should be right below `@float'",
+ caption_cmdname);
}
else
float = current->parent->parent;
if (float)
{
- if (lookup_extra (float, command_name(command)))
+ if (lookup_extra_element (float, caption_cmdname))
line_warn ("ignoring multiple @%s",
- command_name(command));
+ caption_cmdname);
else
{
add_extra_element (current->parent, "float", float);
- add_extra_element (float, command_name(command),
- current->parent);
+ add_extra_element (float, caption_cmdname,
+ current->parent);
}
}
#undef float
@@ -604,10 +605,9 @@ handle_comma (ELEMENT *current, char **line_inout)
if (command_data(current->cmd).data == BRACE_inline)
{
- KEY_PAIR *k_format;
int expandp = 0;
- k_format = lookup_extra (current, "format");
- if (!k_format)
+ char *format = lookup_extra_string (current, "format");
+ if (!format)
{
ELEMENT *arg = 0;
char *inline_type = 0;
@@ -787,7 +787,7 @@ handle_comma (ELEMENT *current, char **line_inout)
text_append (&e->text, ""); /* See comment in parser.c:merge_text */
add_to_element_contents (current, e);
add_extra_element (e, "spaces_associated_command", current);
-
+
funexit:
*line_inout = line;
return current;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/utils.c (section_level), tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block) (end_line_misc_line), tp/Texinfo/XS/parsetexi/handle_commands.c (handle_other_command), tp/Texinfo/XS/parsetexi/separator.c (handle_comma): use lookup_extra_* functions with a specific type and dynaic type checking, when possible.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/XS/main/debug.c (print_associate_info_debug), tp/Texinfo/XS/main/extra.c (lookup_extra_integer), tp/Texinfo/XS/main/manipulate_tree.c (increase_ref_counter) (get_copy_ref), tp/Texinfo/XS/main/tree_types.h (KEY_PAIR), tp/Texinfo/XS/main/utils.c (section_level), tp/Texinfo/XS/parsetexi/handle_commands.c (handle_other_command) (handle_line_command): use int for the integer field in KEY_PAIR values union. Update declarations and remove casts.
- Next by Date:
[no subject]
- Previous by thread:
branch master updated: * tp/Texinfo/XS/main/debug.c (print_associate_info_debug), tp/Texinfo/XS/main/extra.c (lookup_extra_integer), tp/Texinfo/XS/main/manipulate_tree.c (increase_ref_counter) (get_copy_ref), tp/Texinfo/XS/main/tree_types.h (KEY_PAIR), tp/Texinfo/XS/main/utils.c (section_level), tp/Texinfo/XS/parsetexi/handle_commands.c (handle_other_command) (handle_line_command): use int for the integer field in KEY_PAIR values union. Update declarations and remove casts.
- Next by thread:
master updated (37db08acdd -> acada79767)
- Index(es):