texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Fri, 23 Feb 2024 06:35:02 -0500 (EST)

branch: master
commit b0c4a76e571db1ffeba39a75783c15fdd7d2de5c
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Feb 23 12:30:20 2024 +0100

    * tp/Texinfo/XS/convert/get_html_perl_info.c
    (html_get_shared_conversion_state): check if index_nr is not 0.
    
    * tp/Texinfo/XS/convert/convert_html.c,
    tp/Texinfo/XS/convert/get_html_perl_info.c,
    tp/Texinfo/XS/main/converter_types.h (SORTED_INDEX_NAMES),
    tp/Texinfo/XS/main/get_perl_info.c: add static and const.
---
 ChangeLog                                  | 10 +++++++++
 tp/Texinfo/XS/convert/convert_html.c       |  6 ++---
 tp/Texinfo/XS/convert/get_html_perl_info.c |  4 ++--
 tp/Texinfo/XS/main/converter_types.h       |  2 +-
 tp/Texinfo/XS/main/get_perl_info.c         | 36 +++++++++++++++---------------
 tp/Texinfo/XS/main/get_perl_info.h         |  2 +-
 6 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 80e73925a3..6b80c0eef9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-02-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/get_html_perl_info.c
+       (html_get_shared_conversion_state): check if index_nr is not 0.
+
+       * tp/Texinfo/XS/convert/convert_html.c,
+       tp/Texinfo/XS/convert/get_html_perl_info.c,
+       tp/Texinfo/XS/main/converter_types.h (SORTED_INDEX_NAMES),
+       tp/Texinfo/XS/main/get_perl_info.c: add static and const.
+
 2024-02-23  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/node_name_normalization.c
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 170dd2c5b7..a801807f25 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -4702,7 +4702,7 @@ prepare_index_entries_targets (CONVERTER *self)
         = (int **) malloc (self->sorted_index_names.number * sizeof (int *));
       for (i = 0; i < self->sorted_index_names.number; i++)
         {
-          INDEX *idx = self->sorted_index_names.list[i];
+          const INDEX *idx = self->sorted_index_names.list[i];
           self->shared_conversion_state.formatted_index_entries[i] = 0;
           /* TODO should always be true */
           if (idx->entries_number > 0)
@@ -12627,7 +12627,7 @@ convert_printindex_command (CONVERTER *self, const enum 
command_id cmd,
           int *formatted_index_entry_nr;
           char *multiple_pass_str;
           size_t entry_index_nr;
-          INDEX *entry_index;
+          const INDEX *entry_index;
           ELEMENT *seeentry;
           ELEMENT *seealso;
           char *new_normalized_entry_levels[SUBENTRIES_MAX_LEVEL +1];
@@ -16618,7 +16618,7 @@ html_initialize_output_state (CONVERTER *self, char 
*context)
 
       /* store only non empty indices in sorted_index_names */
       self->sorted_index_names.number = non_empty_index_nr;
-      self->sorted_index_names.list = (INDEX **)
+      self->sorted_index_names.list = (const INDEX **)
          malloc (self->sorted_index_names.number * sizeof (INDEX *));
       for (j = 0; j < index_nr; j++)
         {
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c 
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index e81ecd873a..1591e6ae42 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -1348,7 +1348,7 @@ find_index_entry_numbers_index_entry_sv (CONVERTER 
*converter,
 {
   HV *index_entry_hv;
   SV **index_name_sv;
-  char *index_name = 0;
+  const char *index_name = 0;
 
   dTHX;
 
@@ -1524,7 +1524,7 @@ html_get_shared_conversion_state (CONVERTER *converter, 
SV *converter_in,
       int entry_number
         = find_index_entry_numbers_index_entry_sv (converter,
                                                 args_sv[0], &index_nr);
-      if (entry_number <= 0)
+      if (entry_number <= 0 || index_nr == 0)
         fatal ("index entry not found");
 
       return newSViv(converter->shared_conversion_state
diff --git a/tp/Texinfo/XS/main/converter_types.h 
b/tp/Texinfo/XS/main/converter_types.h
index 3be684d6da..878f04897f 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -649,7 +649,7 @@ typedef struct JSLICENSE_CATEGORY_LIST {
 /* contains only indices with entries */
 typedef struct SORTED_INDEX_NAMES {
     size_t number;
-    INDEX **list;
+    const INDEX **list;
 } SORTED_INDEX_NAMES;
 
 typedef struct CONVERTER {
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index cb0e3873fd..c83c8cd43e 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -638,7 +638,7 @@ find_index_entry_sv (const SV *index_entry_sv, INDEX 
**index_names,
   SV **index_name_sv;
   SV **entry_number_sv;
   int entry_idx_in_index;
-  char *entry_index_name = 0;
+  const char *entry_index_name = 0;
   const INDEX *idx;
 
   dTHX;
@@ -658,7 +658,7 @@ find_index_entry_sv (const SV *index_entry_sv, INDEX 
**index_names,
       xasprintf (&msg, "%s: no entry info\n", warn_str);
       fatal (msg);
     }
-  entry_index_name = (char *) SvPVutf8_nolen (*index_name_sv);
+  entry_index_name = (const char *) SvPVutf8_nolen (*index_name_sv);
   *entry_number = SvIV (*entry_number_sv);
   entry_idx_in_index = *entry_number - 1;
 
@@ -1221,18 +1221,17 @@ html_get_direction_icons_sv (CONVERTER *converter,
     }
 }
 
-INDEX_ENTRY *
+static const INDEX_ENTRY *
 find_sorted_index_names_index_entry_extra_index_entry_sv (
-                                       SORTED_INDEX_NAMES *sorted_index_names,
-                                       const SV *extra_index_entry_sv)
+                                  const SORTED_INDEX_NAMES *sorted_index_names,
+                                  const SV *extra_index_entry_sv)
 {
   AV *extra_index_entry_av;
   SV **index_name_sv;
-  char *index_name = 0;
+  const char *index_name = 0;
 
   dTHX;
 
-
   extra_index_entry_av = (AV *) SvRV (extra_index_entry_sv);
 
   index_name_sv = av_fetch (extra_index_entry_av, 0, 0);
@@ -1260,7 +1259,7 @@ find_sorted_index_names_index_entry_extra_index_entry_sv (
   return 0;
 }
 
-INDEX_ENTRY *
+static const INDEX_ENTRY *
 find_document_index_entry_extra_index_entry_sv (const DOCUMENT *document,
                                              const SV *extra_index_entry_sv)
 {
@@ -1300,12 +1299,12 @@ find_document_index_entry_extra_index_entry_sv (const 
DOCUMENT *document,
 /* if there is a converter with sorted index names, use the
    sorted index names, otherwise use the index information from
    a document */
-static INDEX_ENTRY *
+static const INDEX_ENTRY *
 find_element_extra_index_entry_sv (const DOCUMENT *document,
-                                   CONVERTER *converter,
+                                   const CONVERTER *converter,
                                    const SV *extra_index_entry_sv)
 {
-  INDEX_ENTRY *index_entry;
+  const INDEX_ENTRY *index_entry;
   if (!converter || !converter->document || !converter->document->index_names)
     {
       if (document)
@@ -1431,13 +1430,13 @@ const ELEMENT *
 find_subentry_index_command_sv (const DOCUMENT *document, HV *element_hv)
 {
   HV *current_parent = element_hv;
-  SV *current_sv = 0;
+  const SV *current_sv = 0;
 
   dTHX;
 
   while (1)
     {
-      SV *subentry_parent_sv = subentry_hv_parent (current_parent);
+      const SV *subentry_parent_sv = subentry_hv_parent (current_parent);
       if (subentry_parent_sv)
         {
           current_parent = (HV *) SvRV (subentry_parent_sv);
@@ -1468,8 +1467,9 @@ find_subentry_index_command_sv (const DOCUMENT *document, 
HV *element_hv)
    when going through the elements associated to indices to setup
    index entries sort strings.
  */
-const ELEMENT *find_index_entry_associated_hv (INDEX_ENTRY *index_entry,
-                                               HV *element_hv)
+static const ELEMENT *
+find_index_entry_associated_hv (const INDEX_ENTRY *index_entry,
+                                const HV *element_hv)
 {
   if (index_entry->entry_associated_element
       && index_entry->entry_associated_element->hv == element_hv)
@@ -1497,7 +1497,7 @@ const ELEMENT *find_index_entry_associated_hv 
(INDEX_ENTRY *index_entry,
    Only for global commands, commands with indices, and sectioning root
    commands */
 const ELEMENT *
-find_element_from_sv (CONVERTER *converter, const DOCUMENT *document_in,
+find_element_from_sv (const CONVERTER *converter, const DOCUMENT *document_in,
                       const SV *element_sv, int output_units_descriptor)
 {
   enum command_id cmd = 0;
@@ -1587,7 +1587,7 @@ find_element_from_sv (CONVERTER *converter, const 
DOCUMENT *document_in,
       EXTRA(associated_index_entry)
       if (associated_index_entry_sv)
         {
-          INDEX_ENTRY *index_entry
+          const INDEX_ENTRY *index_entry
                = find_element_extra_index_entry_sv (document,
                                                     converter,
                                               *associated_index_entry_sv);
@@ -1603,7 +1603,7 @@ find_element_from_sv (CONVERTER *converter, const 
DOCUMENT *document_in,
       EXTRA(index_entry)
       if (index_entry_sv)
         {
-          INDEX_ENTRY *index_entry
+          const INDEX_ENTRY *index_entry
                      = find_element_extra_index_entry_sv (document,
                                                           converter,
                                                           *index_entry_sv);
diff --git a/tp/Texinfo/XS/main/get_perl_info.h 
b/tp/Texinfo/XS/main/get_perl_info.h
index 7c9068b23c..2d8f49f55d 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -59,7 +59,7 @@ void html_get_direction_icons_sv (CONVERTER *converter,
                              DIRECTION_ICON_LIST *direction_icons,
                              SV *icons_sv);
 
-const ELEMENT *find_element_from_sv (CONVERTER *converter,
+const ELEMENT *find_element_from_sv (const CONVERTER *converter,
                                      const DOCUMENT *document_in,
                           const SV *element_sv, int output_units_descriptor);
 #endif



reply via email to

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