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 Oct 2023 04:37:23 -0400 (EDT)

branch: master
commit 8e4b9296d74c35357317a7736ec1ef27956d1ebe
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Oct 29 09:32:25 2023 +0100

    Move code around, change in comments, no change in code
---
 tp/TODO                                |  2 ++
 tp/Texinfo/TranslationsNonXS.pm        |  2 +-
 tp/Texinfo/XS/main/utils.c             | 64 ++++++++++++++++++++++------------
 tp/Texinfo/XS/parsetexi/indices.c      | 24 +++++++------
 tp/Texinfo/XS/parsetexi/indices.h      |  8 +++--
 tp/Texinfo/XS/parsetexi/macro.c        |  3 +-
 tp/Texinfo/XS/parsetexi/macro.h        |  1 +
 tp/Texinfo/XS/parsetexi/parser.c       |  2 ++
 tp/Texinfo/XS/parsetexi/parser.h       | 11 +++---
 tp/Texinfo/XS/parsetexi/source_marks.c | 41 ++++++++++------------
 tp/Texinfo/XS/parsetexi/source_marks.h |  2 +-
 11 files changed, 94 insertions(+), 66 deletions(-)

diff --git a/tp/TODO b/tp/TODO
index e8dbab44e0..e234a409e7 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -10,6 +10,8 @@ This is the todo list for texi2any
 Before next release
 ===================
 
+inline element_type_name from parser.c
+
 check $(native_tools) variable in Makefile.am does not seems to be
 set and seems useless.
 
diff --git a/tp/Texinfo/TranslationsNonXS.pm b/tp/Texinfo/TranslationsNonXS.pm
index 5e9af44afe..575d7b2c78 100644
--- a/tp/Texinfo/TranslationsNonXS.pm
+++ b/tp/Texinfo/TranslationsNonXS.pm
@@ -449,7 +449,7 @@ if (0) {
   gdt('{name} of {class}', undef, undef);
 }
 
-# In a handful of cases, we delay storing the contents of the
+# For some @def* commands, we delay storing the contents of the
 # index entry until now to avoid needing Texinfo::Translations::gdt
 # in the main code of ParserNonXS.pm.
 sub complete_indices($$)
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index ced84acddd..0e1a285c61 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -166,6 +166,8 @@ isascii_upper (int c)
   return (((c & ~0x7f) == 0) && isupper(c));
 }
 
+
+/* operations on strings considered as multibytes.  Use libunistring */
 /* count characters, not bytes. */
 size_t
 count_multibyte (const char *text)
@@ -222,6 +224,8 @@ width_multibyte (const char *text)
   return result;
 }
 
+
+/* encoding and decoding. Use iconv. */
 /* ENCODING should always be lower cased */
 ENCODING_CONVERSION *
 get_encoding_conversion (char *encoding,
@@ -439,6 +443,9 @@ encode_string (char *input_string, char *encoding, int 
*status,
   return result;
 }
 
+
+/* code related to the EXPANDED_FORMAT structure holding informations on the
+   expanded formats (html, info, tex...) */
 void
 clear_expanded_formats (EXPANDED_FORMAT *formats)
 {
@@ -496,6 +503,7 @@ format_expanded_p (EXPANDED_FORMAT *formats, char *format)
   return 0;
 }
 
+
 /* Return the parent if in an item_line command, @*table */
 ELEMENT *
 item_line_parent (ELEMENT *current)
@@ -522,6 +530,8 @@ get_label_element (ELEMENT *e)
   return 0;
 }
 
+
+/* index related code used both in parsing and conversion */
 /* NAME is the name of an index, e.g. "cp" */
 INDEX *
 indices_info_index_by_name (INDEX **indices_information, char *name)
@@ -542,6 +552,8 @@ ultimate_index (INDEX *index)
   return index;
 }
 
+
+/* text parsing functions used in diverse situations */
 /* Read a name used for @set, @value and translations arguments. */
 char *
 read_flag_name (char **ptr)
@@ -690,6 +702,8 @@ normalize_encoding_name (char *text, int *possible_encoding)
   return normalized_text;
 }
 
+
+/* index related functions used in diverse situations, not only in parser */
 void
 wipe_index (INDEX *idx)
 {
@@ -712,17 +726,8 @@ wipe_index_names (INDEX **index_names)
   free (index_names);
 }
 
-/* options */
-
-OPTIONS *
-new_options (void)
-{
-  OPTIONS *options = (OPTIONS *) malloc (sizeof (OPTIONS));
-  initialize_options (options);
-  return options;
-}
-
-
+
+/* string lists */
 /* include directories and include file */
 
 void
@@ -835,6 +840,8 @@ destroy_strings_list (STRING_LIST *strings)
   free (strings);
 }
 
+
+/* code related to document global info used both in parser and other codes */
 void
 delete_global_info (GLOBAL_INFO *global_info_ref)
 {
@@ -987,15 +994,6 @@ in_preamble (ELEMENT *element)
   return 0;
 }
 
-CONVERTER *
-new_converter (void)
-{
-  CONVERTER *converter
-   = (CONVERTER *) malloc (sizeof (CONVERTER));
-  memset (converter, 0, sizeof (CONVERTER));
-  return converter;
-}
-
 /*
   COMMAND_LOCATION is 'last', 'preamble' or 'preamble_or_first'
   'preamble' means setting sequentially to the values in the preamble.
@@ -1065,7 +1063,29 @@ set_global_document_command (CONVERTER *self, enum 
command_id cmd,
   return element;
 }
 
-/* in Common.pm */
+
+/* options and converters */
+OPTIONS *
+new_options (void)
+{
+  OPTIONS *options = (OPTIONS *) malloc (sizeof (OPTIONS));
+  initialize_options (options);
+  return options;
+}
+
+CONVERTER *
+new_converter (void)
+{
+  CONVERTER *converter
+   = (CONVERTER *) malloc (sizeof (CONVERTER));
+  memset (converter, 0, sizeof (CONVERTER));
+  return converter;
+}
+
+
+/* misc functions used in general in structuring and in conversion */
+
+/* corresponding perl function in Common.pm */
 /* the returned level will be < 0 if the command is not supposed
    to be associated to a level. */
 int
@@ -1088,7 +1108,7 @@ section_level (ELEMENT *section)
   return level;
 }
 
-/* from Common.pm */
+/* corresponding perl function in Common.pm */
 int
 is_content_empty (ELEMENT *tree, int do_not_ignore_index_entries)
 {
diff --git a/tp/Texinfo/XS/parsetexi/indices.c 
b/tp/Texinfo/XS/parsetexi/indices.c
index a2478e7f48..1b558b3dc8 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -121,6 +121,7 @@ add_index_internal (char *name, int in_code)
 }
 
 
+
 /* Add a user defined index with the name NAME */
 void
 add_index (char *name, int in_code)
@@ -137,15 +138,6 @@ add_index (char *name, int in_code)
   free (cmdname);
 }
 
-/* reset indices without unallocating them nor the list of indices */
-void
-forget_indices (void)
-{
-  index_names = 0;
-  number_of_indices = 0;
-  space_for_indices = 0;
-}
-
 void
 init_index_commands (void)
 {
@@ -349,8 +341,17 @@ set_non_ignored_space_in_index_before_command (ELEMENT 
*content)
     }
 }
 
-
 
+
+/* reset indices without unallocating them nor the list of indices */
+void
+forget_indices (void)
+{
+  index_names = 0;
+  number_of_indices = 0;
+  space_for_indices = 0;
+}
+
 void
 resolve_indices_merged_in (void)
 {
@@ -367,6 +368,9 @@ resolve_indices_merged_in (void)
     }
 }
 
+/* complete some @def* index information that require translations.
+   Done in a separate function and not inside the main parser loop because
+   it requires parsing Texinfo code in gdt_tree too */
 void
 complete_indices (int document_descriptor)
 {
diff --git a/tp/Texinfo/XS/parsetexi/indices.h 
b/tp/Texinfo/XS/parsetexi/indices.h
index 669faee5ba..623cee4320 100644
--- a/tp/Texinfo/XS/parsetexi/indices.h
+++ b/tp/Texinfo/XS/parsetexi/indices.h
@@ -12,9 +12,11 @@ void add_index (char *name, int in_code);
 INDEX *index_of_command (enum command_id cmd);
 void enter_index_entry (enum command_id index_type_cmd,
                         ELEMENT *current);
-void resolve_indices_merged_in (void);
-INDEX *ultimate_index (INDEX *index);
-void forget_indices (void);
 void set_non_ignored_space_in_index_before_command (ELEMENT *content);
+
+void forget_indices (void);
+
+void resolve_indices_merged_in (void);
 void complete_indices (int document_descriptor);
+
 #endif
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index 1a7e82ab1a..b1d06132fb 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -1123,8 +1123,9 @@ fetch_value (char *name)
     return "1";
   return 0;
 }
-
 
+
+/* @definfoenclose */
 static INFO_ENCLOSE *infoencl_list;
 static size_t infoencl_number;
 static size_t infoencl_space;
diff --git a/tp/Texinfo/XS/parsetexi/macro.h b/tp/Texinfo/XS/parsetexi/macro.h
index 5a36dea80c..9d9f62d764 100644
--- a/tp/Texinfo/XS/parsetexi/macro.h
+++ b/tp/Texinfo/XS/parsetexi/macro.h
@@ -47,6 +47,7 @@ void store_value (char *name, char *value);
 char *fetch_value (char *name);
 void clear_value (char *name);
 void wipe_values (void);
+
 INFO_ENCLOSE *lookup_infoenclose (enum command_id cmd);
 void add_infoenclose (enum command_id cmd, char *begin, char *end);
 
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index cfa8f027bd..19a0616a4f 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -456,6 +456,8 @@ setup_document_root_and_before_node_section ()
   return before_node_section;
 }
 
+/* Put everything before @setfilename in a special type and separate
+   a preamble for informative commands */
 void
 rearrange_tree_beginning (ELEMENT *before_node_section)
 {
diff --git a/tp/Texinfo/XS/parsetexi/parser.h b/tp/Texinfo/XS/parsetexi/parser.h
index 9857cff087..1d1086a635 100644
--- a/tp/Texinfo/XS/parsetexi/parser.h
+++ b/tp/Texinfo/XS/parsetexi/parser.h
@@ -76,12 +76,17 @@ typedef struct {
     SOURCE_MARK *source_mark;
 } CONDITIONAL_STACK_ITEM;
 
+ELEMENT *setup_document_root_and_before_node_section (void);
 int parse_texi (ELEMENT *root_elt, ELEMENT *current_elt);
+int parse_texi_document (void);
+void set_documentlanguage_override (char *value);
+void set_accept_internalvalue (int value);
+
 void push_conditional_stack (enum command_id cond, SOURCE_MARK *source_mark);
 CONDITIONAL_STACK_ITEM *pop_conditional_stack (void);
 CONDITIONAL_STACK_ITEM *top_conditional_stack (void);
 extern size_t conditional_number;
-int parse_texi_document (void);
+
 int abort_empty_line (ELEMENT **current_inout, char *additional);
 ELEMENT *end_paragraph (ELEMENT *current,
                         enum command_id closed_block_command,
@@ -105,8 +110,6 @@ ELEMENT *begin_paragraph (ELEMENT *current);
 int is_end_current_command (ELEMENT *current, char **line,
                             enum command_id *end_cmd);
 void set_documentlanguage (char *);
-void set_documentlanguage_override (char *value);
-void set_accept_internalvalue (int value);
 char *element_type_name (ELEMENT *e);
 int check_space_element (ELEMENT *e);
 void gather_spaces_after_cmd_before_arg (ELEMENT *current);
@@ -139,8 +142,6 @@ void wipe_parser_global_info (void);
 
 extern COUNTER count_remaining_args, count_items, count_cells;
 
-ELEMENT *setup_document_root_and_before_node_section (void);
-
 /* In multitable.c */
 ELEMENT *item_multitable_parent (ELEMENT *current);
 void gather_previous_item (ELEMENT *current, enum command_id next_command);
diff --git a/tp/Texinfo/XS/parsetexi/source_marks.c 
b/tp/Texinfo/XS/parsetexi/source_marks.c
index e517430c4d..bebb35486b 100644
--- a/tp/Texinfo/XS/parsetexi/source_marks.c
+++ b/tp/Texinfo/XS/parsetexi/source_marks.c
@@ -42,18 +42,11 @@ int expanded_conditional_command_counter = 0;
    it only if static (or in only one file if extern) */
 static char *source_marks_names[SM_type_expanded_conditional_command + 1] =
 {
-  /* #define sm_type(name) [SM_type_ ## name] = #name, */
   #define sm_type(name) #name,
     SM_TYPES_LIST
   #undef sm_type
 };
 
-char *
-source_mark_name(enum source_mark_type type)
-{
-  return source_marks_names[type];
-}
-
 SOURCE_MARK *
 new_source_mark (enum source_mark_type type)
 {
@@ -68,21 +61,6 @@ new_source_mark (enum source_mark_type type)
   return source_mark;
 }
 
-void
-transfer_source_marks (ELEMENT *from_e, ELEMENT *e)
-{
-  SOURCE_MARK_LIST *source_mark_list = &(from_e->source_mark_list);
-  if (source_mark_list->number)
-    {
-      int i;
-      for (i = 0; i < source_mark_list->number; i++)
-        {
-          add_source_mark (source_mark_list->list[i], e);
-        }
-      source_mark_list->number = 0;
-    }
-}
-
 /* ELEMENT should be the parent container. */
 void
 place_source_mark (ELEMENT *e, SOURCE_MARK *source_mark)
@@ -109,7 +87,8 @@ place_source_mark (ELEMENT *e, SOURCE_MARK *source_mark)
       add_element_string = "add";
     }
 
-  debug_nonl ("MARK %s c: %d p: %d %s %s ", 
source_mark_name(source_mark->type),
+  debug_nonl ("MARK %s c: %d p: %d %s %s ",
+         source_marks_names[source_mark->type],
          source_mark->counter, source_mark->position,
          source_mark->status == SM_status_start ? "start"
           : source_mark->status == SM_status_end ? "end"
@@ -176,6 +155,22 @@ register_source_mark (ELEMENT *e, SOURCE_MARK *source_mark)
   place_source_mark (e, source_mark);
 }
 
+void
+transfer_source_marks (ELEMENT *from_e, ELEMENT *e)
+{
+  SOURCE_MARK_LIST *source_mark_list = &(from_e->source_mark_list);
+  if (source_mark_list->number)
+    {
+      int i;
+      for (i = 0; i < source_mark_list->number; i++)
+        {
+          add_source_mark (source_mark_list->list[i], e);
+        }
+      source_mark_list->number = 0;
+    }
+}
+
+
 void
 source_marks_reset_counters (void)
 {
diff --git a/tp/Texinfo/XS/parsetexi/source_marks.h 
b/tp/Texinfo/XS/parsetexi/source_marks.h
index 063df426f0..51a74013de 100644
--- a/tp/Texinfo/XS/parsetexi/source_marks.h
+++ b/tp/Texinfo/XS/parsetexi/source_marks.h
@@ -20,9 +20,9 @@
 
 SOURCE_MARK *new_source_mark (enum source_mark_type type);
 void register_source_mark (ELEMENT *e, SOURCE_MARK *source_mark);
-void source_marks_reset_counters (void);
 void transfer_source_marks (ELEMENT *from_e, ELEMENT *e);
 void place_source_mark (ELEMENT *e, SOURCE_MARK *source_mark);
 
+void source_marks_reset_counters (void);
 
 #endif



reply via email to

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