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, 20 Oct 2024 10:43:12 -0400 (EDT)

branch: master
commit ba095798808ef788737b399510ac49be74bfa1b9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Oct 20 16:43:04 2024 +0200

    * tp/Texinfo/XS/parsetexi/Parsetexi.pm,
    tp/Texinfo/XS/parsetexi/Parsetexi.xs (errors): implement errors in XS,
    remove from Parsetexi.pm.
---
 ChangeLog                            |  6 +++++
 tp/Texinfo/XS/parsetexi/Parsetexi.pm | 14 ------------
 tp/Texinfo/XS/parsetexi/Parsetexi.xs | 44 ++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7a93f57890..edac89d379 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-10-20  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/parsetexi/Parsetexi.pm,
+       tp/Texinfo/XS/parsetexi/Parsetexi.xs (errors): implement errors in XS,
+       remove from Parsetexi.pm.
+
 2024-10-20  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/build_perl_info.c (new_texinfo_report): fix
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm 
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 749cd93dab..dee6b14ed2 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -133,20 +133,6 @@ sub parser (;$)
   return $parser;
 }
 
-sub errors($)
-{
-  my $self = shift;
-  my $registrar = $self->{'registrar'};
-  if (!$registrar) {
-    return undef;
-  }
-  my ($error_warnings_list, $error_count) = $registrar->errors();
-
-  $registrar->clear();
-
-  return ($error_warnings_list, $error_count);
-}
-
 1;
 __END__
 
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.xs 
b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
index 4fec771f13..3bce6e16e9 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
@@ -295,3 +295,47 @@ parser_conf_set_DEBUG (int i)
 void
 parser_conf_set_accept_internalvalue (int value)
 
+# two possibilities
+#   - errors were put in a registrar key in the parser
+#   - TODO: errors are still in the last parsed document->parser_error_messages
+void
+errors (SV *parser_sv)
+    PREINIT:
+        SV *errors_warnings_sv = 0;
+        SV *error_nrs_sv = 0;
+        SV **registrar_sv;
+        HV *parser_hv;
+    PPCODE:
+        parser_hv = (HV *)SvRV (parser_sv);
+        registrar_sv = hv_fetch (parser_hv, "registrar", strlen ("registrar"),
+                                 0);
+
+        if (registrar_sv)
+          {
+            HV *registrar_hv = (HV *)SvRV (*registrar_sv);
+            SV **registrar_errors_warnings_sv;
+            SV **registrar_error_nrs_sv;
+            AV *empty_errors_warnings = newAV ();
+
+            registrar_errors_warnings_sv
+                    = hv_fetch (registrar_hv, "errors_warnings",
+                                           strlen ("errors_warnings"), 0);
+            errors_warnings_sv = *registrar_errors_warnings_sv;
+            SvREFCNT_inc (errors_warnings_sv);
+            registrar_error_nrs_sv = hv_fetch (registrar_hv, "error_nrs",
+                                               strlen ("error_nrs"), 0);
+            error_nrs_sv = *registrar_error_nrs_sv;
+            SvREFCNT_inc (error_nrs_sv);
+
+            /* registrar->clear() */
+            hv_store (registrar_hv, "errors_warnings",
+                      strlen ("errors_warnings"),
+                      newRV_noinc ((SV *) empty_errors_warnings), 0);
+            hv_store (registrar_hv, "errors_nrs",
+                      strlen ("errors_nrs"), newSViv (0), 0);
+          }
+
+        EXTEND(SP, 2);
+        PUSHs(sv_2mortal(errors_warnings_sv));
+        PUSHs(sv_2mortal(error_nrs_sv));
+



reply via email to

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