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, 4 Oct 2024 06:06:18 -0400 (EDT)

branch: master
commit 7b4bffad129bb3e184cb4d4d5873e5fd88197efd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 11 09:32:04 2024 +0200

    * tp/Texinfo/XS/teximakehtml.c (add_new_option_strlist_value): copy
    strings.
    
    * tp/Texinfo/XS/teximakehtml.c (main): free parser_options.
    
    * tp/Texinfo/XS/convert/texinfo.c (txi_handle_parser_error_messages)
    (txi_handle_document_error_messages)
    (txi_handle_converter_error_messages): add wrappers for
    handle_error_messages to be used directly on document and converter.
    
    * tp/Texinfo/XS/teximakehtml.c (main): call txi_handle_*error_messages
    and exit 1 if there were errors.  Remove print_errors.
---
 ChangeLog                       | 15 +++++++++++
 tp/TODO                         |  8 +++++-
 tp/Texinfo/XS/convert/texinfo.c | 33 +++++++++++++++++++++++
 tp/Texinfo/XS/convert/texinfo.h | 10 +++++++
 tp/Texinfo/XS/teximakehtml.c    | 59 ++++++++++++++---------------------------
 5 files changed, 85 insertions(+), 40 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 17c0e8791d..84e266e52c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-08-11  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/teximakehtml.c (add_new_option_strlist_value): copy
+       strings.
+
+       * tp/Texinfo/XS/teximakehtml.c (main): free parser_options.
+
+       * tp/Texinfo/XS/convert/texinfo.c (txi_handle_parser_error_messages)
+       (txi_handle_document_error_messages)
+       (txi_handle_converter_error_messages): add wrappers for
+       handle_error_messages to be used directly on document and converter.
+
+       * tp/Texinfo/XS/teximakehtml.c (main): call txi_handle_*error_messages
+       and exit 1 if there were errors.  Remove print_errors.
+
 2024-08-11  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/build_perl_info.c (add_formatted_error_messages),
diff --git a/tp/TODO b/tp/TODO
index feab91561b..a068bbc32b 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -887,7 +887,13 @@ SUM: 98
 
 Setting flags
 our_CFLAGS='-g -O0 -Wformat-security -Wstrict-prototypes -Wall 
-Wno-parentheses -Wno-missing-braces'
-our_CFLAGS='-g -O0 -Wformat-security -Wstrict-prototypes -Wall 
-Wno-parentheses -Wno-missing-braces -fstack-protector-all -Wstack-protector 
-fno-omit-frame-pointer'
+# Without -Wstack-protector there is no message on functions not protected.
+# All these are in gnulib or gettext for now.
+# -fno-omit-frame-pointer is better for debugging with valgrind, but has
+# some speed penalty
+# some features are only enabled at -O2, but sometime -O0 is better
+# for debugging with valgrind
+our_CFLAGS='-g -O2 -D_FORTIFY_SOURCE=2 -Wformat-security -Wstrict-prototypes 
-Wall -Wno-parentheses -Wno-missing-braces -Wno-unused-parameter 
-fstack-protector-all -Wextra -Wno-sign-compare -fno-omit-frame-pointer'
 ./configure "CFLAGS=$our_CFLAGS" "PERL_EXT_CFLAGS=$our_CFLAGS"
 unset our_CFLAGS
 
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index 8780bb872f..9ecf24cf7c 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -29,6 +29,7 @@
 #include "document_types.h"
 #include "api.h"
 #include "conf.h"
+#include "errors.h"
 /* parse_file_path */
 #include "utils.h"
 #include "document.h"
@@ -424,3 +425,35 @@ txi_html_output (CONVERTER *converter, DOCUMENT *document)
   return result;
 }
 
+
+
+/* functions for high level interface hiding some defails of the data */
+
+size_t
+txi_handle_parser_error_messages (DOCUMENT *document, int no_warn,
+                                  int use_filename,
+                                  const char *message_encoding)
+{
+  return handle_error_messages (&document->parser_error_messages, no_warn,
+                         use_filename, message_encoding);
+}
+
+size_t
+txi_handle_document_error_messages (DOCUMENT *document, int no_warn,
+                                    int use_filename,
+                                    const char *message_encoding)
+{
+  return handle_error_messages (&document->error_messages, no_warn,
+                         use_filename, message_encoding);
+
+}
+
+size_t
+txi_handle_converter_error_messages (CONVERTER *converter, int no_warn,
+                                    int use_filename,
+                                    const char *message_encoding)
+{
+  return handle_error_messages (&converter->error_messages, no_warn,
+                         use_filename, message_encoding);
+
+}
diff --git a/tp/Texinfo/XS/convert/texinfo.h b/tp/Texinfo/XS/convert/texinfo.h
index 0b949a96fc..efa0d70bbc 100644
--- a/tp/Texinfo/XS/convert/texinfo.h
+++ b/tp/Texinfo/XS/convert/texinfo.h
@@ -44,4 +44,14 @@ void txi_converter (CONVERTER *converter,
 
 char *txi_html_output (CONVERTER *converter, DOCUMENT *document);
 
+size_t txi_handle_parser_error_messages (DOCUMENT *document, int no_warn,
+                                       int use_filename,
+                                       const char *message_encoding);
+size_t txi_handle_document_error_messages (DOCUMENT *document, int no_warn,
+                                         int use_filename,
+                                         const char *message_encoding);
+size_t txi_handle_converter_error_messages (CONVERTER *converter, int no_warn,
+                                          int use_filename,
+                                          const char *message_encoding);
+
 #endif
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 7b6f0142e1..6d9e8558c7 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -44,39 +44,6 @@
 
 #define LOCALEDIR DATADIR "/locale"
 
-static void
-print_errors (ERROR_MESSAGE_LIST *error_messages)
-{
-  int i;
-
-  TEXT text;
-  text_init (&text);
-
-  for (i = 0; i < error_messages->number; i++)
-    {
-      const ERROR_MESSAGE *error_msg = &error_messages->list[i];
-      text_reset (&text);
-      if (error_msg->source_info.file_name)
-        {
-          text_append (&text, error_msg->source_info.file_name);
-          text_append_n (&text, ":", 1);
-        }
-      if (error_msg->source_info.line_nr > 0)
-        {
-          text_printf (&text, "%d:", error_msg->source_info.line_nr);
-        }
-
-      if (text.end > 0)
-        text_append_n (&text, " ", 1);
-
-      text_append (&text, error_msg->error_line);
-      fprintf (stderr, "%s", text.text);
-    }
-  free (text.text);
-
-  clear_error_message_list (error_messages);
-}
-
 /* this function is quite generic, it could be added to utils.c */
 static void
 add_button_option (OPTIONS_LIST *options_list, OPTION **sorted_options,
@@ -98,11 +65,11 @@ add_button_option (OPTIONS_LIST *options_list, OPTION 
**sorted_options,
 static OPTION *
 add_new_option_strlist_value (OPTIONS_LIST *options_list,
                   enum global_option_type type, const char *name,
-                  STRING_LIST *strlist)
+                  const STRING_LIST *strlist)
 {
   OPTION *option = new_option (type, name, 0);
 
-  option->o.strlist = strlist;
+  copy_strings (option->o.strlist, strlist);
 
   options_list_add_option (options_list, option);
 
@@ -119,6 +86,7 @@ static char *parser_EXPANDED_FORMATS_array[] = {"HTML", 
"tex"};
 static STRING_LIST parser_EXPANDED_FORMATS
   = {parser_EXPANDED_FORMATS_array, 2, 2};
 
+
 int
 main (int argc, char *argv[])
 {
@@ -135,6 +103,8 @@ main (int argc, char *argv[])
   BUTTON_SPECIFICATION_LIST *custom_node_footer_buttons;
   OPTIONS_LIST parser_options;
   OPTIONS_LIST convert_options;
+  size_t errors_count = 0;
+  size_t errors_nr;
 
   /*
   const char *texinfo_text;
@@ -183,18 +153,22 @@ main (int argc, char *argv[])
   txi_parser (input_file_path, locale_encoding, expanded_formats, &values,
               &parser_options);
 
+  free_options_list (&parser_options);
+
   /* Texinfo document tree parsing */
   document_descriptor = parse_file (input_file_path, &status);
   document = retrieve_document (document_descriptor);
 
   if (status)
     {
-      print_errors (&document->parser_error_messages);
+      txi_handle_parser_error_messages (document, 0, 1, locale_encoding);
       remove_document_descriptor (document_descriptor);
       exit (1);
     }
 
-  print_errors (&document->parser_error_messages);
+  errors_nr
+    = txi_handle_parser_error_messages (document, 0, 1, locale_encoding);
+  errors_count += errors_nr;
 
   /*
   texinfo_text = convert_to_texinfo (document->tree);
@@ -210,7 +184,9 @@ main (int argc, char *argv[])
                      | STTF_nodes_tree | STTF_floats
                      | STTF_setup_index_entries_sort_strings, 0);
 
-  print_errors (&document->error_messages);
+  errors_nr
+    += txi_handle_document_error_messages (document, 0, 1, locale_encoding);
+  errors_count += errors_nr;
 
   /* create converter and generic converter initializations */
   converter_descriptor = new_converter ();
@@ -240,10 +216,15 @@ main (int argc, char *argv[])
   result = txi_html_output (converter, document);
   free (result);
 
-  print_errors (&converter->error_messages);
+  errors_nr
+    = txi_handle_converter_error_messages (converter, 0, 1, locale_encoding);
+  errors_count += errors_nr;
 
   /* destroy converter */
   html_free_converter (converter);
   /* destroy document */
   remove_document_descriptor (document_descriptor);
+
+  if (errors_count > 0)
+    exit (1);
 }



reply via email to

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