texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Tue, 29 Oct 2024 11:22:54 -0400 (EDT)

branch: master
commit 5b4bce7970cfb0450516b1a6753ad692f340f469
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Oct 29 15:54:40 2024 +0100

    * tp/Texinfo/Convert/HTML.pm (run_stage_handlers),
    tp/Texinfo/XS/convert/call_html_perl_function.c (call_stage_handler),
    tp/Texinfo/XS/convert/convert_html.c (html_run_stage_handlers),
    tp/Texinfo/XS/convert/replace_perl_call_html_function.c
    (call_stage_handler): check the stage handler return value and error
    out if it is not numeric.  Add an error status argument to
    call_stage_handler to get the specific error in
    html_run_stage_handlers.
---
 ChangeLog                                               | 11 +++++++++++
 tp/Texinfo/Convert/HTML.pm                              |  8 ++++++--
 tp/Texinfo/XS/convert/call_html_perl_function.c         | 12 ++++++++++--
 tp/Texinfo/XS/convert/call_html_perl_function.h         |  2 +-
 tp/Texinfo/XS/convert/convert_html.c                    | 11 ++++++++++-
 tp/Texinfo/XS/convert/replace_perl_call_html_function.c |  3 ++-
 6 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c614fc275a..7878ae3fce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-10-29  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (run_stage_handlers),
+       tp/Texinfo/XS/convert/call_html_perl_function.c (call_stage_handler),
+       tp/Texinfo/XS/convert/convert_html.c (html_run_stage_handlers),
+       tp/Texinfo/XS/convert/replace_perl_call_html_function.c
+       (call_stage_handler): check the stage handler return value and error
+       out if it is not numeric.  Add an error status argument to
+       call_stage_handler to get the specific error in
+       html_run_stage_handlers.
+
 2024-10-29  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/hashmap.c (clear_registered_ids_c_hashmap):
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index f2a6b43f9d..c97f62ca8f 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -12464,8 +12464,12 @@ sub run_stage_handlers($$$$)
       print STDERR "RUN handler $handler_idx: stage $stage, priority 
$priority\n";
     }
     my $status = &{$handler}($converter, $document, $stage);
-    $status = -$converter->get_conf('HANDLER_FATAL_ERROR_LEVEL') -1
-      if (!defined($status));
+    if (!defined($status) or ref($status) ne '' or $status !~ /^\d+$/) {
+      $converter->converter_document_error(
+       sprintf(__("handler %d of stage %s priority %s: non-numeric status"),
+                      $handler_idx, $stage, $priority));
+      $status = $converter->get_conf('HANDLER_FATAL_ERROR_LEVEL') +1;
+    }
     if ($status != 0) {
       if ($status < 0) {
         $converter->converter_document_error(
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c 
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index 41634d615d..6545baa5f9 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -2345,7 +2345,7 @@ call_latex_convert_to_latex_math (CONVERTER *self, const 
ELEMENT *element)
 
 int
 call_stage_handler (CONVERTER *self, void *stage_handler_sv,
-                    const char *stage_name)
+                    const char *stage_name, int *error_status)
 {
   int count;
   SV *document_sv = 0;
@@ -2354,6 +2354,8 @@ call_stage_handler (CONVERTER *self, void 
*stage_handler_sv,
 
   dTHX;
 
+  *error_status = 0;
+
   if (self->document)
     {
       SV **document_ref_sv = hv_fetch (self->hv, "document",
@@ -2392,7 +2394,13 @@ call_stage_handler (CONVERTER *self, void 
*stage_handler_sv,
 
 
   result_sv = POPs;
-  status = (int) SvIV (result_sv);
+  if (!SvOK (result_sv) || SvROK (result_sv) || !looks_like_number(result_sv))
+    {
+      status = -self->conf->HANDLER_FATAL_ERROR_LEVEL.o.integer - 1;
+      *error_status = 1;
+    }
+  else
+    status = (int) SvIV (result_sv);
 
   PUTBACK;
 
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.h 
b/tp/Texinfo/XS/convert/call_html_perl_function.h
index 548e65403a..a6e2f72d59 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.h
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.h
@@ -146,7 +146,7 @@ FORMATTED_BUTTON_INFO *call_button_direction_function 
(CONVERTER *self,
                              int direction, const ELEMENT *element);
 
 int call_stage_handler (CONVERTER *self, void *stage_handler_sv,
-                        const char *stage_name);
+                        const char *stage_name, int *error_status);
 
 char *call_latex_convert_to_latex_math (CONVERTER *self,
                                         const ELEMENT *element);
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 9f82c7e824..de12e22941 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -723,8 +723,17 @@ html_run_stage_handlers (CONVERTER *self,
 
           if (stage_handler->sv)
             {
+              int error_status = 0;
               call_status = call_stage_handler (self, stage_handler->sv,
-                                                stage_name);
+                                                stage_name, &error_status);
+              if (error_status == 1)
+                {
+                  message_list_document_error (&self->error_messages,
+                                                   self->conf, 0,
+                 "handler %d of stage %s priority %s: non-numeric status",
+                              (int) i+1, stage_name, stage_handler->priority);
+                }
+
               if (call_status != 0)
                 {
                   if (call_status < 0)
diff --git a/tp/Texinfo/XS/convert/replace_perl_call_html_function.c 
b/tp/Texinfo/XS/convert/replace_perl_call_html_function.c
index 1a51d1db08..d80c836dd0 100644
--- a/tp/Texinfo/XS/convert/replace_perl_call_html_function.c
+++ b/tp/Texinfo/XS/convert/replace_perl_call_html_function.c
@@ -331,8 +331,9 @@ call_button_direction_function (CONVERTER *self,
 
 int
 call_stage_handler(CONVERTER *self, void *stage_handler_sv,
-                        const char *stage_name)
+                        const char *stage_name, int *error_status)
 {
+  *error_status = 0;
   return 0;
 }
 



reply via email to

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