[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_debug_show_source_m
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_debug_show_source_mark) (_place_source_mark, _merge_text), tp/Texinfo/XS/parsetexi/source_marks.c (source_mark_name) place_source_mark), tp/Texinfo/XS/parsetexi/tree_types.h (source_marks_names): more similar code in perl parser than in XS parser, same source marks debug message in XS parser than in perl parser. |
Date: |
Sat, 08 Jul 2023 06:47:46 -0400 |
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 2b3ffa1ccb * tp/Texinfo/ParserNonXS.pm (_debug_show_source_mark)
(_place_source_mark, _merge_text), tp/Texinfo/XS/parsetexi/source_marks.c
(source_mark_name) place_source_mark), tp/Texinfo/XS/parsetexi/tree_types.h
(source_marks_names): more similar code in perl parser than in XS parser, same
source marks debug message in XS parser than in perl parser.
2b3ffa1ccb is described below
commit 2b3ffa1ccb029583caacde990915d466375c82cd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jul 8 12:47:34 2023 +0200
* tp/Texinfo/ParserNonXS.pm (_debug_show_source_mark)
(_place_source_mark, _merge_text),
tp/Texinfo/XS/parsetexi/source_marks.c (source_mark_name)
place_source_mark), tp/Texinfo/XS/parsetexi/tree_types.h
(source_marks_names): more similar code in perl parser than in XS
parser, same source marks debug message in XS parser than in perl
parser.
* tp/Texinfo/XS/parsetexi/api.c (store_source_mark_list),
tp/Texinfo/XS/parsetexi/tree_types.h (enum source_mark_status): remove
unused SM_status_fail source mark status.
---
ChangeLog | 14 ++++++++++++++
tp/Texinfo/ParserNonXS.pm | 19 +++++++++---------
tp/Texinfo/XS/parsetexi/api.c | 1 -
tp/Texinfo/XS/parsetexi/source_marks.c | 22 ++++++++++++++++-----
tp/Texinfo/XS/parsetexi/tree_types.h | 35 +++++++++++++++++++++++-----------
5 files changed, 65 insertions(+), 26 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 98bb464bdd..524a3cef8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-07-08 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_debug_show_source_mark)
+ (_place_source_mark, _merge_text),
+ tp/Texinfo/XS/parsetexi/source_marks.c (source_mark_name)
+ place_source_mark), tp/Texinfo/XS/parsetexi/tree_types.h
+ (source_marks_names): more similar code in perl parser than in XS
+ parser, same source marks debug message in XS parser than in perl
+ parser.
+
+ * tp/Texinfo/XS/parsetexi/api.c (store_source_mark_list),
+ tp/Texinfo/XS/parsetexi/tree_types.h (enum source_mark_status): remove
+ unused SM_status_fail source mark status.
+
2023-07-08 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (%parser_state_initialization, _next_text)
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 779a8273d8..cc77ddce12 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -1171,8 +1171,8 @@ sub _debug_show_source_mark
my $source_mark = shift;
return "$source_mark->{'sourcemark_type'} c: "
.(defined($source_mark->{'counter'}) ? $source_mark->{'counter'}: 'UNDEF')
- .", ".(defined($source_mark->{'position'})
- ? $source_mark->{'position'}: 'UNDEF')." "
+ ." p: ".(defined($source_mark->{'position'})
+ ? $source_mark->{'position'}: 0)." "
.(defined($source_mark->{'status'}) ? $source_mark->{'status'}: 'UNDEF');
}
@@ -1181,8 +1181,8 @@ sub _place_source_mark
my ($self, $element, $source_mark) = @_;
# for debug
- my $add_element = 'no-add';
- delete $source_mark->{'position'};
+ my $add_element_string = 'no-add';
+ $source_mark->{'position'} = 0;
# the element that holds the source mark
my $mark_element;
if ($element->{'contents'} and scalar(@{$element->{'contents'}}) > 0) {
@@ -1197,11 +1197,14 @@ sub _place_source_mark
$mark_element = {'parent' => $element, 'text' => ''};
$element->{'contents'} = [] unless (defined($element->{'contents'}));
push @{$element->{'contents'}}, $mark_element;
- $add_element = 'add';
+ $add_element_string = 'add';
+ }
+ if ($source_mark->{'position'} == 0) {
+ delete $source_mark->{'position'};
}
- print STDERR "MARK: "._debug_show_source_mark($source_mark)
- ." $add_element ".Texinfo::Common::debug_print_element($mark_element)
+ print STDERR "MARK "._debug_show_source_mark($source_mark)
+ ." $add_element_string ".Texinfo::Common::debug_print_element($mark_element)
.' '.Texinfo::Common::debug_print_element($element)."\n"
if ($self->{'DEBUG'});
;
@@ -2203,8 +2206,6 @@ sub _merge_text {
while (scalar(@{$transfer_marks_element->{'source_marks'}})) {
my $source_mark = shift @{$transfer_marks_element->{'source_marks'}};
if ($additional_length) {
- $source_mark->{'position'} = 0
- if (not defined($source_mark->{'position'}));
$source_mark->{'position'} += $additional_length;
}
push @{$last_child->{'source_marks'}}, $source_mark;
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index f5178a2606..52bc6f82b9 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -466,7 +466,6 @@ store_source_mark_list (ELEMENT *e)
{
SAVE_S_M_STATUS (start)
SAVE_S_M_STATUS (end)
- SAVE_S_M_STATUS (fail)
}
#define SAVE_S_M_TYPE(X) \
diff --git a/tp/Texinfo/XS/parsetexi/source_marks.c
b/tp/Texinfo/XS/parsetexi/source_marks.c
index 5a071101fb..e603924a03 100644
--- a/tp/Texinfo/XS/parsetexi/source_marks.c
+++ b/tp/Texinfo/XS/parsetexi/source_marks.c
@@ -31,6 +31,12 @@ int value_expansion_counter = 0;
int ignored_conditional_block_counter = 0;
int expanded_conditional_command_counter = 0;
+char *
+source_mark_name(enum source_mark_type type)
+{
+ return source_marks_names[type];
+}
+
SOURCE_MARK *
new_source_mark (enum source_mark_type type)
{
@@ -81,6 +87,8 @@ void
place_source_mark (ELEMENT *e, SOURCE_MARK *source_mark)
{
ELEMENT *mark_element;
+ /* for debug string */
+ char *add_element_string = "no-add";
source_mark->position = 0;
if (e->contents.number > 0)
@@ -97,13 +105,16 @@ place_source_mark (ELEMENT *e, SOURCE_MARK *source_mark)
/* set empty text to have merge_text work as expected */
text_append (&mark_element->text, "");
add_to_element_contents (e, mark_element);
+ add_element_string = "add";
}
- debug_nonl ("MARKS: %d c: %d, %d %d ", source_mark->type,
- source_mark->counter, source_mark->position,
- source_mark->status);
- debug_print_element (mark_element, 1);
- debug("");
+ debug ("MARK %s c: %d p: %d %s %s %s %s",
source_mark_name(source_mark->type),
+ source_mark->counter, source_mark->position,
+ source_mark->status == SM_status_start ? "start"
+ : source_mark->status == SM_status_end ? "end"
+ : "SM_status UNKNOWN", add_element_string,
+ print_element_debug(mark_element, 0),
+ print_element_debug(e, 0));
add_source_mark (source_mark, mark_element);
}
@@ -244,3 +255,4 @@ relocate_source_marks (SOURCE_MARK_LIST *source_mark_list,
ELEMENT *new_e,
}
return end_position;
}
+
diff --git a/tp/Texinfo/XS/parsetexi/tree_types.h
b/tp/Texinfo/XS/parsetexi/tree_types.h
index 4cb5222da4..06d5188114 100644
--- a/tp/Texinfo/XS/parsetexi/tree_types.h
+++ b/tp/Texinfo/XS/parsetexi/tree_types.h
@@ -36,23 +36,36 @@ enum extra_type {
/* the *_none enums are not necessarily used, they may also
be there to avoid using 0, for a code easier to debug */
-enum source_mark_type { SM_type_none,
- SM_type_include,
- SM_type_setfilename,
- SM_type_delcomment,
- SM_type_defline_continuation,
- SM_type_macro_expansion,
- SM_type_linemacro_expansion,
- SM_type_value_expansion,
- SM_type_ignored_conditional_block,
- SM_type_expanded_conditional_command
+
+#define SM_TYPES_LIST \
+ sm_type(none) \
+ sm_type(include) \
+ sm_type(setfilename) \
+ sm_type(delcomment) \
+ sm_type(defline_continuation) \
+ sm_type(macro_expansion) \
+ sm_type(linemacro_expansion) \
+ sm_type(value_expansion) \
+ sm_type(ignored_conditional_block) \
+ sm_type(expanded_conditional_command) \
+
+enum source_mark_type {
+ #define sm_type(name) SM_type_ ## name,
+ SM_TYPES_LIST
+ #undef sm_type
+};
+
+static char *source_marks_names[SM_type_expanded_conditional_command + 1] =
+{
+ #define sm_type(name) [SM_type_ ## name] = #name,
+ SM_TYPES_LIST
+ #undef sm_type
};
enum source_mark_status {
SM_status_none,
SM_status_start,
SM_status_end,
- SM_status_fail,
};
typedef struct KEY_PAIR {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_debug_show_source_mark) (_place_source_mark, _merge_text), tp/Texinfo/XS/parsetexi/source_marks.c (source_mark_name) place_source_mark), tp/Texinfo/XS/parsetexi/tree_types.h (source_marks_names): more similar code in perl parser than in XS parser, same source marks debug message in XS parser than in perl parser.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/ParserNonXS.pm (%parser_state_initialization, _next_text) (_handle_macro): register the number of expanded macros in a scalar and go through input to check if a macro is being expanded instead of keeping a stack of expanded macros, also to be more similar with XS parser.
- Next by Date:
branch master updated: * tp/Texinfo/Common.pm (debug_command_name, debug_print_element), tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/debug.c (debug_command_name) (print_element_debug), tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): escape \n and \t in command name in debug messages for better readability.
- Previous by thread:
branch master updated: * tp/Texinfo/ParserNonXS.pm (%parser_state_initialization, _next_text) (_handle_macro): register the number of expanded macros in a scalar and go through input to check if a macro is being expanded instead of keeping a stack of expanded macros, also to be more similar with XS parser.
- Next by thread:
branch master updated: * tp/Texinfo/Common.pm (debug_command_name, debug_print_element), tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/debug.c (debug_command_name) (print_element_debug), tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): escape \n and \t in command name in debug messages for better readability.
- Index(es):