texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Patrice Dumas
Date: Sun, 29 Sep 2024 06:22:57 -0400 (EDT)

branch: master
commit e7331b7860aeb5ab443cc4c272730c178097bc15
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Jun 17 22:09:07 2024 +0200

    * tp/Texinfo/XS/parsetexi/parser.c (merge_text),
    tp/Texinfo/XS/parsetexi/source_marks.c (transfer_source_marks): add an
    added length argument to transfer_source_marks, to use the function in
    merge_text when merging with existing text.  Update
    transfer_source_marks callers.
---
 ChangeLog                              |  8 ++++++++
 tp/Texinfo/XS/parsetexi/close.c        |  2 +-
 tp/Texinfo/XS/parsetexi/end_line.c     |  2 +-
 tp/Texinfo/XS/parsetexi/menus.c        |  2 +-
 tp/Texinfo/XS/parsetexi/parser.c       | 15 +++------------
 tp/Texinfo/XS/parsetexi/source_marks.c |  6 ++++--
 tp/Texinfo/XS/parsetexi/source_marks.h |  2 +-
 7 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ad6f84bc8c..60c71bfb97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-06-17  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/parsetexi/parser.c (merge_text),
+       tp/Texinfo/XS/parsetexi/source_marks.c (transfer_source_marks): add an
+       added length argument to transfer_source_marks, to use the function in
+       merge_text when merging with existing text.  Update
+       transfer_source_marks callers.
+
 2024-06-17  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/parsetexi/parser.c (abort_empty_line): call with a
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index db0c4027ff..4508e776e1 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -150,7 +150,7 @@ remove_empty_content (ELEMENT *current)
       if (!(type_data[child_element->type].flags & TF_at_command)
           && is_container_empty (child_element))
         {
-          transfer_source_marks (child_element, current);
+          transfer_source_marks (child_element, current, 0);
 
           debug_nonl ("REMOVE empty child ");
           debug_parser_print_element (child_element, 0); debug_nonl (" from ");
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c 
b/tp/Texinfo/XS/parsetexi/end_line.c
index 1faf894968..382c3d478d 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -1886,7 +1886,7 @@ end_line (ELEMENT *current)
           current = e;
           e = new_text_element (ET_after_menu_description_line);
           text_append (e->e.text, empty_line->e.text->text);
-          transfer_source_marks (empty_line, e);
+          transfer_source_marks (empty_line, e, 0);
           destroy_element (empty_line);
           add_to_element_contents (current, e);
 
diff --git a/tp/Texinfo/XS/parsetexi/menus.c b/tp/Texinfo/XS/parsetexi/menus.c
index 59ed266391..2d97542a61 100644
--- a/tp/Texinfo/XS/parsetexi/menus.c
+++ b/tp/Texinfo/XS/parsetexi/menus.c
@@ -178,7 +178,7 @@ handle_menu_entry_separators (ELEMENT **current_inout, 
const char **line_inout)
       menu_entry = new_element (ET_menu_entry);
       leading_text = new_text_element (ET_menu_entry_leading_text);
       /* transfer source marks from removed menu star to leading text */
-      transfer_source_marks (menu_star_element, leading_text);
+      transfer_source_marks (menu_star_element, leading_text, 0);
       destroy_element (menu_star_element);
       entry_name = new_element (ET_menu_entry_name);
       add_to_element_contents (current, menu_entry);
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 687851b184..f04c79c905 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -838,17 +838,8 @@ merge_text (ELEMENT *current, const char *text, size_t 
len_text,
         {
           size_t additional_length
             = count_multibyte (last_element->e.text->text);
-          SOURCE_MARK_LIST *s_mark_list
-             = transfer_marks_element->source_mark_list;
-          int i;
-          for (i = 0; i < s_mark_list->number; i++)
-            {
-              SOURCE_MARK *source_mark = s_mark_list->list[i];
-              if (additional_length > 0)
-                source_mark->position += additional_length;
-              add_source_mark (source_mark, last_element);
-            }
-          free_element_source_mark_list (transfer_marks_element);
+          transfer_source_marks (transfer_marks_element,
+                                 last_element, additional_length);
         }
 
       if (global_parser_conf.debug)
@@ -870,7 +861,7 @@ merge_text (ELEMENT *current, const char *text, size_t 
len_text,
      new_text:
       e = new_text_element (ET_normal_text);
       if (transfer_marks_element)
-        transfer_source_marks (transfer_marks_element, e);
+        transfer_source_marks (transfer_marks_element, e, 0);
       text_append_n (e->e.text, text, len_text);
       add_to_element_contents (current, e);
       if (global_parser_conf.debug)
diff --git a/tp/Texinfo/XS/parsetexi/source_marks.c 
b/tp/Texinfo/XS/parsetexi/source_marks.c
index bd2920d284..690cef6739 100644
--- a/tp/Texinfo/XS/parsetexi/source_marks.c
+++ b/tp/Texinfo/XS/parsetexi/source_marks.c
@@ -104,7 +104,7 @@ register_source_mark (ELEMENT *e, SOURCE_MARK *source_mark)
 }
 
 void
-transfer_source_marks (ELEMENT *from_e, ELEMENT *e)
+transfer_source_marks (ELEMENT *from_e, ELEMENT *e, size_t added_len)
 {
   SOURCE_MARK_LIST *source_mark_list = from_e->source_mark_list;
   if (source_mark_list)
@@ -112,7 +112,9 @@ transfer_source_marks (ELEMENT *from_e, ELEMENT *e)
       size_t i;
       for (i = 0; i < source_mark_list->number; i++)
         {
-          add_source_mark (source_mark_list->list[i], e);
+          SOURCE_MARK *source_mark = source_mark_list->list[i];
+          source_mark->position += added_len;
+          add_source_mark (source_mark, e);
         }
       free_element_source_mark_list (from_e);
     }
diff --git a/tp/Texinfo/XS/parsetexi/source_marks.h 
b/tp/Texinfo/XS/parsetexi/source_marks.h
index f00d609bce..2306966d7f 100644
--- a/tp/Texinfo/XS/parsetexi/source_marks.h
+++ b/tp/Texinfo/XS/parsetexi/source_marks.h
@@ -21,7 +21,7 @@
 SOURCE_MARK *new_source_mark (enum source_mark_type type);
 void place_source_mark (ELEMENT *e, SOURCE_MARK *source_mark);
 void register_source_mark (ELEMENT *e, SOURCE_MARK *source_mark);
-void transfer_source_marks (ELEMENT *from_e, ELEMENT *e);
+void transfer_source_marks (ELEMENT *from_e, ELEMENT *e, size_t added_len);
 
 void source_marks_reset_counters (void);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]