[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/build_perl_info.c (store_sou
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/build_perl_info.c (store_source_mark_list), tp/Texinfo/XS/main/tree_types.h (SM_TYPES_LIST), tp/Texinfo/XS/parsetexi/source_marks.c (register_source_mark) (source_marks_reset_counters): remove SM_type_none from SM_TYPES_LIST and use SM_TYPES_LIST more to avoid repetitive code. |
Date: |
Sun, 29 Oct 2023 05:10:58 -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 b98ce98e1d * tp/Texinfo/XS/main/build_perl_info.c
(store_source_mark_list), tp/Texinfo/XS/main/tree_types.h (SM_TYPES_LIST),
tp/Texinfo/XS/parsetexi/source_marks.c (register_source_mark)
(source_marks_reset_counters): remove SM_type_none from SM_TYPES_LIST and use
SM_TYPES_LIST more to avoid repetitive code.
b98ce98e1d is described below
commit b98ce98e1ddc0318e45daae5497027e8227f2664
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Oct 29 10:11:01 2023 +0100
* tp/Texinfo/XS/main/build_perl_info.c (store_source_mark_list),
tp/Texinfo/XS/main/tree_types.h (SM_TYPES_LIST),
tp/Texinfo/XS/parsetexi/source_marks.c (register_source_mark)
(source_marks_reset_counters): remove SM_type_none from SM_TYPES_LIST
and use SM_TYPES_LIST more to avoid repetitive code.
---
ChangeLog | 8 ++++
tp/Texinfo/XS/main/build_perl_info.c | 23 ++++------
tp/Texinfo/XS/main/tree_types.h | 2 +-
tp/Texinfo/XS/parsetexi/source_marks.c | 83 +++++++++-------------------------
4 files changed, 39 insertions(+), 77 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2a9da93737..afc426b669 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-10-29 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/build_perl_info.c (store_source_mark_list),
+ tp/Texinfo/XS/main/tree_types.h (SM_TYPES_LIST),
+ tp/Texinfo/XS/parsetexi/source_marks.c (register_source_mark)
+ (source_marks_reset_counters): remove SM_type_none from SM_TYPES_LIST
+ and use SM_TYPES_LIST more to avoid repetitive code.
+
2023-10-29 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): use
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 27a50e0dec..d6719db920 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -411,23 +411,16 @@ store_source_mark_list (ELEMENT *e)
break;
}
-#define SAVE_S_M_TYPE(X) \
- case SM_type_ ## X: \
- sv = newSVpv_utf8 (#X, 0);\
- STORE("sourcemark_type", sv); \
- break;
-
switch (s_mark->type)
{
- SAVE_S_M_TYPE (include)
- SAVE_S_M_TYPE (setfilename)
- SAVE_S_M_TYPE (delcomment)
- SAVE_S_M_TYPE (defline_continuation)
- SAVE_S_M_TYPE (macro_expansion)
- SAVE_S_M_TYPE (linemacro_expansion)
- SAVE_S_M_TYPE (value_expansion)
- SAVE_S_M_TYPE (ignored_conditional_block)
- SAVE_S_M_TYPE (expanded_conditional_command)
+#define sm_type(X) \
+ case SM_type_ ## X: \
+ sv = newSVpv_utf8 (#X, 0);\
+ STORE("sourcemark_type", sv); \
+ break;
+
+ SM_TYPES_LIST
+#undef sm_type
/* for SM_type_none */
default:
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index e61809ae62..2a02db942e 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -39,7 +39,6 @@ enum extra_type {
be there to avoid using 0, for a code easier to debug */
#define SM_TYPES_LIST \
- sm_type(none) \
sm_type(include) \
sm_type(setfilename) \
sm_type(delcomment) \
@@ -51,6 +50,7 @@ enum extra_type {
sm_type(expanded_conditional_command) \
enum source_mark_type {
+ SM_type_none,
#define sm_type(name) SM_type_ ## name,
SM_TYPES_LIST
#undef sm_type
diff --git a/tp/Texinfo/XS/parsetexi/source_marks.c
b/tp/Texinfo/XS/parsetexi/source_marks.c
index bebb35486b..544065080d 100644
--- a/tp/Texinfo/XS/parsetexi/source_marks.c
+++ b/tp/Texinfo/XS/parsetexi/source_marks.c
@@ -27,15 +27,10 @@
#include "manipulate_tree.h"
#include "source_marks.h"
-int include_counter = 0;
-int setfilename_counter = 0;
-int delcomment_counter = 0;
-int defline_continuation_counter = 0;
-int macro_expansion_counter = 0;
-int linemacro_expansion_counter = 0;
-int value_expansion_counter = 0;
-int ignored_conditional_block_counter = 0;
-int expanded_conditional_command_counter = 0;
+#define sm_type(name) \
+static int name##_counter = 0;
+ SM_TYPES_LIST
+#undef sm_type
/* it isn't much readable to use here the SM_TYPES_LIST macro defined
in a header file, but the table should be allocated in files using
@@ -105,50 +100,22 @@ register_source_mark (ELEMENT *e, SOURCE_MARK
*source_mark)
{
if (source_mark->counter == -1)
{
- if (source_mark->type == SM_type_include)
+ switch (source_mark->type)
{
- include_counter++;
- source_mark->counter = include_counter;
- }
- else if (source_mark->type == SM_type_setfilename)
- {
- setfilename_counter++;
- source_mark->counter = setfilename_counter;
- }
- else if (source_mark->type == SM_type_delcomment)
- {
- delcomment_counter++;
- source_mark->counter = delcomment_counter;
- }
- else if (source_mark->type == SM_type_defline_continuation)
- {
- defline_continuation_counter++;
- source_mark->counter = defline_continuation_counter;
- }
- else if (source_mark->type == SM_type_macro_expansion)
- {
- macro_expansion_counter++;
- source_mark->counter = macro_expansion_counter;
- }
- else if (source_mark->type == SM_type_linemacro_expansion)
- {
- linemacro_expansion_counter++;
- source_mark->counter = linemacro_expansion_counter;
- }
- else if (source_mark->type == SM_type_value_expansion)
- {
- value_expansion_counter++;
- source_mark->counter = value_expansion_counter;
- }
- else if (source_mark->type == SM_type_ignored_conditional_block)
- {
- ignored_conditional_block_counter++;
- source_mark->counter = ignored_conditional_block_counter;
- }
- else if (source_mark->type == SM_type_expanded_conditional_command)
- {
- expanded_conditional_command_counter++;
- source_mark->counter = expanded_conditional_command_counter;
+#define sm_type(name) \
+ case SM_type_##name: \
+ { \
+ name##_counter++; \
+ source_mark->counter = name##_counter; \
+ } \
+ break;
+
+ SM_TYPES_LIST
+
+#undef sm_type
+ default:
+ /* do nothing; just silence -Wswitch about SM_type_none */
+ break;
}
}
@@ -174,14 +141,8 @@ transfer_source_marks (ELEMENT *from_e, ELEMENT *e)
void
source_marks_reset_counters (void)
{
- include_counter = 0;
- setfilename_counter = 0;
- delcomment_counter = 0;
- defline_continuation_counter = 0;
- macro_expansion_counter = 0;
- linemacro_expansion_counter = 0;
- value_expansion_counter = 0;
- ignored_conditional_block_counter = 0;
- expanded_conditional_command_counter = 0;
+#define sm_type(name) name##_counter = 0;
+ SM_TYPES_LIST
+#undef sm_type
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/build_perl_info.c (store_source_mark_list), tp/Texinfo/XS/main/tree_types.h (SM_TYPES_LIST), tp/Texinfo/XS/parsetexi/source_marks.c (register_source_mark) (source_marks_reset_counters): remove SM_type_none from SM_TYPES_LIST and use SM_TYPES_LIST more to avoid repetitive code.,
Patrice Dumas <=