texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/main/utils.c (item_line_parent):


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/utils.c (item_line_parent): use element_builtin_cmd.
Date: Sun, 14 Jan 2024 11:15:45 -0500

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 a3f1cbe113 * tp/Texinfo/XS/main/utils.c (item_line_parent): use 
element_builtin_cmd.
a3f1cbe113 is described below

commit a3f1cbe113818d426b0424810077e95d0da2b11d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 14 17:15:44 2024 +0100

    * tp/Texinfo/XS/main/utils.c (item_line_parent): use
    element_builtin_cmd.
    
    * tp/Texinfo/XS/main/utils.c (informative_command_value): if there is
    only one rawline argument, returns it.  Return a newly allocated
    text only if there is more than one argument.  In that case, the
    returned text won't be freed, but this is not an issue as it could
    only happen with @set, which is ignored.
    
    Add, modify, change status of TODO/FIXME.
---
 ChangeLog                                          | 13 +++++++
 tp/Texinfo/XS/convert/build_html_perl_state.c      | 13 +------
 tp/Texinfo/XS/convert/call_html_perl_function.c    |  3 ++
 tp/Texinfo/XS/convert/get_html_perl_info.c         |  3 ++
 tp/Texinfo/XS/main/call_perl_function.c            |  5 +++
 tp/Texinfo/XS/main/errors.c                        |  2 +-
 tp/Texinfo/XS/main/get_perl_info.c                 |  3 ++
 tp/Texinfo/XS/main/translations.c                  |  7 ++--
 tp/Texinfo/XS/main/utils.c                         | 43 ++++++++++++++--------
 .../XS/structuring_transfo/transformations.c       |  8 ++--
 tp/maintain/regenerate_C_options_info.pl           |  3 ++
 11 files changed, 70 insertions(+), 33 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f9fc4adb97..85dd07895c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-01-14  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/utils.c (item_line_parent): use
+       element_builtin_cmd.
+
+       * tp/Texinfo/XS/main/utils.c (informative_command_value): if there is
+       only one rawline argument, returns it.  Return a newly allocated
+       text only if there is more than one argument.  In that case, the
+       returned text won't be freed, but this is not an issue as it could
+       only happen with @set, which is ignored.
+
+       Add, modify, change status of TODO/FIXME.
+
 2024-01-14  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs: add warn
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c 
b/tp/Texinfo/XS/convert/build_html_perl_state.c
index d5ca052589..b7db00f076 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -48,14 +48,8 @@
 
 #define LOCALEDIR DATADIR "/locale"
 
-  /* TODO the following NOTE could be obsolete, as this code is now part
-     of a library that is not linked against Gnulib.  However, XS dynamic
-     shared object link against both the library this code is part of and
-     another library that does not use perl headers and do not link against
-     perl libraries but links against Gnulib. */
-
   /* NOTE: Do not call 'malloc' or 'free' in any function called in this file.
-     Since this file (build_perl_info.c) includes the Perl headers,
+     Since this file (build_html_perl_state.c) includes the Perl headers,
      we get the Perl redefinitions, which we do not want, as we don't use
      them throughout the rest of the program. */
 
@@ -290,6 +284,7 @@ build_html_translated_names (HV *hv, CONVERTER *converter)
       const char *type_name = special_unit_info_type_names[string_type];
       char *key;
       HV *special_unit_hv = newHV ();
+      /* TODO do not call xasprintf/free?  See NOTE at the beginning */
       xasprintf (&key, "%s_tree", type_name);
       hv_store (special_unit_info_hv, key, strlen (key),
                 newRV_noinc ((SV *) special_unit_hv), 0);
@@ -367,10 +362,6 @@ void
 build_html_formatting_state (CONVERTER *converter, unsigned long flags)
 {
   HV *hv;
-  /*
-  SV **files_information_sv;
-  HV *files_information_hv;
-   */
   int i;
 
   dTHX;
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c 
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index f50b08e176..a810a01407 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -42,6 +42,9 @@
 #include "build_html_perl_state.h"
 #include "call_html_perl_function.h"
 
+ /* TODO the NOTE in build_perl_info.c about not using malloc/free should
+    be relevant for this file */
+
 /* NOTE newSVpv_utf8 is used for file names because extensions may be supplied
    by the user, the base file name may be ASCII, the extension may not.  Also,
    in some cases, file name could be TOP_NODE_FILE_TARGET. */
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c 
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 4a7ae17c28..f2405420bc 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -52,6 +52,9 @@ FIXME add an initialization of translations?
 #include "build_perl_info.h"
 #include "get_html_perl_info.h"
 
+ /* TODO the NOTE in build_perl_info.c about not using malloc/free should
+    be relevant for this file */
+
 /* Following is HTML specific */
 static SV **
 register_formatting_reference_default (char *type_string,
diff --git a/tp/Texinfo/XS/main/call_perl_function.c 
b/tp/Texinfo/XS/main/call_perl_function.c
index 0c2fe9e87d..60c657bf34 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -37,6 +37,11 @@
 #include "build_perl_info.h"
 #include "call_perl_function.h"
 
+ /* The NOTE in build_perl_info.c about not using malloc/free should
+    be relevant for this file
+    TODO there are calls to strndup.  Is it ok?
+  */
+
 char *
 call_nodenamenormalization_unicode_to_transliterate (char *text)
 {
diff --git a/tp/Texinfo/XS/main/errors.c b/tp/Texinfo/XS/main/errors.c
index 99eebd875e..46f38a52a3 100644
--- a/tp/Texinfo/XS/main/errors.c
+++ b/tp/Texinfo/XS/main/errors.c
@@ -283,7 +283,7 @@ message_list_command_error (ERROR_MESSAGE_LIST 
*error_messages,
                            &e->source_info, format, v);
 }
 
-/* FIXME continuation? */
+/* TODO a continuation argument may need to be added. */
 void
 message_list_document_error (ERROR_MESSAGE_LIST *error_messages,
                              OPTIONS *conf,
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index d137193fec..7e31377282 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -54,6 +54,9 @@ FIXME add an initialization of translations?
 #include "converter.h"
 #include "get_perl_info.h"
 
+ /* TODO the NOTE in build_perl_info.c about not using malloc/free should
+    be relevant for this file */
+
 #define FETCH(key) key##_sv = hv_fetch (element_hv, #key, strlen(#key), 0);
 
 static void
diff --git a/tp/Texinfo/XS/main/translations.c 
b/tp/Texinfo/XS/main/translations.c
index 4b626fb637..8eecea96a8 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -490,9 +490,10 @@ replace_convert_substrings (OPTIONS *options, char 
*translated_string,
    */
   parser_set_accept_internalvalue (1);
 
-  /* FIXME implement setting configuration.  This may not be needed when
-     called from a parser without reset_parser being called, but would be
-     when called from a converter */
+  /* TODO implement setting configuration.  This may not be needed when
+     called from a parser without reset_parser being called, but could be
+     when called from a converter.  As long as only DEBUG is passed
+     this is not really problematic. */
   /*
   # general customization relevant for parser
   if ($customization_information) {
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 61ff9067eb..ab870af220 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -193,7 +193,7 @@ isascii_upper (int c)
 size_t
 count_multibyte (const char *text)
 {
-  /* FIXME error checking? */
+  /* TODO error checking? Or cast (uint8_t *) instead of conversion? */
   uint8_t *u8_text = u8_strconv_from_encoding (text, "UTF-8",
                                                  iconveh_question_mark);
   size_t result = u8_mbsnlen (u8_text, u8_strlen (u8_text));
@@ -209,7 +209,7 @@ to_upper_or_lower_multibyte (const char *text, int 
lower_or_upper)
   char *result;
   size_t lengthp;
   uint8_t *u8_result;
-  /* FIXME error checking? */
+  /* TODO error checking? Or cast (uint8_t *) instead of conversion? */
   uint8_t *u8_text = u8_strconv_from_encoding (text, "UTF-8",
                                                iconveh_question_mark);
   if (lower_or_upper > 0)
@@ -235,10 +235,10 @@ width_multibyte (const char *text)
   const char *p = strrchr (text, '\n');
   if (!p)
     p = text;
-  /* FIXME error checking? */
+  /* TODO error checking? Or cast (uint8_t *) instead of conversion? */
   uint8_t *u8_text = u8_strconv_from_encoding (p, "UTF-8",
                                                  iconveh_question_mark);
-  /* FIXME the libunistring documentation described encoding as
+  /* NOTE the libunistring documentation described encoding as
      The encoding argument identifies the encoding (e.g. "ISO-8859-2"
      for Polish).  Looking at the code, it seems that it is only
      used to determine if it is a CJK encoding in a list of upper-case
@@ -586,12 +586,15 @@ set_expanded_formats_from_options (EXPANDED_FORMAT 
*formats,
 ELEMENT *
 item_line_parent (ELEMENT *current)
 {
+  enum command_id cmd;
+
   if (current->type == ET_before_item && current->parent)
     current = current->parent;
 
-  /* FIXME could it be possible that current is a user defined command? */
-  /* if (command_data(current->cmd).data == BLOCK_item_line) */
-  if (builtin_command_data[current->cmd].data == BLOCK_item_line)
+  /* this code handles current being a user defined command even tough
+     it is not clear that it may happen */
+  cmd = element_builtin_cmd (current);
+  if (builtin_command_data[cmd].data == BLOCK_item_line)
     return current;
 
   return 0;
@@ -1087,27 +1090,37 @@ informative_command_value (const ELEMENT *element)
     {
       if (builtin_command_data[cmd].args_number <= 0)
         return "1";
-      /* FIXME is it possible to have args.number > 1? */
+      /* NOTE only @set, which should be ignored, can have args.number > 1.
+         We handle this case with TEXT text, but do not free memory
+         as should be, as this case should never happen. 
+       */
       else if (element->args.number > 0)
         {
           TEXT text;
           int i;
-          int text_seen = 0;
-          text_init (&text);
+          char *text_seen = 0;
           for (i = 0; i < element->args.number; i++)
             {
               ELEMENT *arg = element->args.list[i];
               if (arg->text.end)
                 {
                   if (!text_seen)
-                    text_seen = 1;
+                    text_seen = arg->text.text;
                   else
-                    text_append (&text, " ");
-                  text_append (&text, arg->text.text);
+                    {
+                      text_init (&text);
+                      text_append (&text, text_seen);
+                      text_append (&text, " ");
+                      text_append (&text, arg->text.text);
+                    }
                 }
             }
-          /* FIXME to be freed */
-          return text.text;
+          if (text.end)
+            /* NOTE would need to be freed, but this case cannot happen,
+               so we leave it like that, see the comment above. */
+            return text.text;
+          else
+            return text_seen;
         }
     }
   text_arg = lookup_extra_string (element, "text_arg");
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c 
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index 536700f639..d0da00a5c7 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -1162,7 +1162,7 @@ regenerate_master_menu (DOCUMENT *document, int 
use_sections)
               ELEMENT *removed = remove_from_contents (menu, detailmenu_index);
               replace_element_in_list (
                  &document->global_commands->detailmenu, removed, master_menu);
-              /* FIXME are the new entries added to internal refs?
+              /* TODO are the new entries added to internal refs?
                  Note that if they are not, it is possible that this has
                  no impact as the associated entry in menu may be
                  in internal refs, and maybe it is enough.
@@ -1274,7 +1274,8 @@ protect_node_after_label_in_tree (ELEMENT *tree)
   return modify_tree (tree, &protect_node_after_label, 0);
 }
 
-/* $customization_information in argument in perl */
+/* NOTE in perl there is a customization_information, but here we use the
+   document for error registration and customization */
 ELEMENT_LIST *
 protect_hashchar_at_line_beginning_internal (const char *type,
                                              ELEMENT *current,
@@ -1449,7 +1450,8 @@ protect_hashchar_at_line_beginning_internal (const char 
*type,
   return 0;
 }
 
-/* FIXME $customization_information in perl */
+/* NOTE in perl there is a customization_information, but here we use the
+   document for error registration and customization */
 ELEMENT *
 protect_hashchar_at_line_beginning (DOCUMENT *document)
 {
diff --git a/tp/maintain/regenerate_C_options_info.pl 
b/tp/maintain/regenerate_C_options_info.pl
index f1eac6bea2..3c2d344594 100755
--- a/tp/maintain/regenerate_C_options_info.pl
+++ b/tp/maintain/regenerate_C_options_info.pl
@@ -299,6 +299,9 @@ foreach my $category (sort(keys(%option_categories))) {
       if ($type eq 'bytes') {
         $SV_function_type = 'byte';
       }
+      # TODO the generated file includes perl headers.  The NOTE in
+      # build_perl_info.c about not using malloc/free should be relevant for
+      # the generated file.
       print GET "      free (options->$option.string);
       if (SvOK (value))
         options->$option.string = strdup (SvPV${SV_function_type}_nolen 
(value));



reply via email to

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