[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/DocumentXS.xs, tp/Texinfo/XS
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/DocumentXS.xs, tp/Texinfo/XS/main/build_perl_info.c: remove pass_document_errors. |
Date: |
Thu, 07 Mar 2024 16:48:08 -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 c7a2be6022 * tp/Texinfo/XS/main/DocumentXS.xs,
tp/Texinfo/XS/main/build_perl_info.c: remove pass_document_errors.
c7a2be6022 is described below
commit c7a2be6022c141d9a8f6003db9aaaeb341a39363
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Mar 7 22:48:10 2024 +0100
* tp/Texinfo/XS/main/DocumentXS.xs,
tp/Texinfo/XS/main/build_perl_info.c: remove pass_document_errors.
* tp/Texinfo/XS/main/build_perl_info.c: move functions around.
---
ChangeLog | 7 +
tp/Texinfo/XS/main/DocumentXS.xs | 17 --
tp/Texinfo/XS/main/build_perl_info.c | 291 ++++++++++++++++-------------------
tp/Texinfo/XS/main/build_perl_info.h | 1 -
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 4 +-
5 files changed, 144 insertions(+), 176 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a0d781392e..40c0d99e04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-03-07 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/DocumentXS.xs,
+ tp/Texinfo/XS/main/build_perl_info.c: remove pass_document_errors.
+
+ * tp/Texinfo/XS/main/build_perl_info.c: move functions around.
+
2024-03-07 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (registrar),
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index bcebf3fd00..5f29518e51 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -102,23 +102,6 @@ remove_document (SV *document_in)
if (document)
remove_document_descriptor (document->descriptor);
-# Currently unused
-SV *
-pass_document_errors (SV *document_in)
- PREINIT:
- HV *document_hv;
- const char *key = "document_descriptor";
- SV** document_descriptor_sv;
- CODE:
- document_hv = (HV *) SvRV (document_in);
- document_descriptor_sv = hv_fetch (document_hv, key, strlen (key), 0);
- if (document_descriptor_sv && SvOK (*document_descriptor_sv))
- RETVAL = pass_document_errors (SvIV (*document_descriptor_sv));
- else
- RETVAL = newSV (0);
- OUTPUT:
- RETVAL
-
void
document_errors (SV *document_in)
PREINIT:
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index caa1c8e59f..33f55d1481 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1203,27 +1203,147 @@ build_errors (ERROR_MESSAGE *error_list, size_t
error_number)
return av;
}
-/* build perl errors list and clear XS document errors */
-/* Currently unused */
+/* add C messages to a Texinfo::Report object, like
+ Texinfo::Report::add_formatted_message does.
+ NOTE probably not useful for converters as errors need to be passed
+ explicitely both from Perl and XS.
+
+ Also return $report->{'errors_warnings'} in ERRORS_WARNINGS_OUT and
+ $report->{'error_nrs'} in ERRORS_NRS_OUT, even if ERROR_MESSAGES is
+ 0, to avoid the need to fetch them from report_hv if calling code
+ is interested in those SV.
+ */
+static void
+add_formatted_error_messages (ERROR_MESSAGE_LIST *error_messages,
+ HV *report_hv, SV **errors_warnings_out,
+ SV **error_nrs_out)
+{
+ SV **errors_warnings_sv;
+ SV **error_nrs_sv;
+ int i;
+
+ dTHX;
+
+
+ *errors_warnings_out = 0;
+ *error_nrs_out = 0;
+
+ if (!report_hv)
+ {
+ fprintf (stderr, "add_formatted_error_messages: BUG: no perl report\n");
+ return;
+ }
+
+ errors_warnings_sv = hv_fetch (report_hv, "errors_warnings",
+ strlen ("errors_warnings"), 0);
+
+ error_nrs_sv = hv_fetch (report_hv, "error_nrs",
+ strlen ("error_nrs"), 0);
+
+ if (errors_warnings_sv && SvOK (*errors_warnings_sv))
+ {
+ int error_nrs = 0;
+ if (error_nrs_sv && SvOK (*error_nrs_sv))
+ {
+ error_nrs = SvIV (*error_nrs_sv);
+ *error_nrs_out = *error_nrs_sv;
+ }
+ *errors_warnings_out = *errors_warnings_sv;
+
+ if (!error_messages)
+ {
+ /* TODO if this message appears in output, it should probably
+ be removed, as this situation is allowed from DocumentXS.xs
+ document_errors */
+ fprintf (stderr,
+ "add_formatted_error_messages: NOTE: no error_messages\n");
+ return;
+ }
+ else
+ {
+ AV *av = (AV *)SvRV (*errors_warnings_sv);
+
+ for (i = 0; i < error_messages->number; i++)
+ {
+ ERROR_MESSAGE error_msg = error_messages->list[i];
+ SV *sv = convert_error (error_msg);
+
+ if (error_msg.type == MSG_error && !error_msg.continuation)
+ error_nrs++;
+ av_push (av, sv);
+ }
+
+ if (error_nrs)
+ {
+ if (error_nrs_sv && SvOK (*error_nrs_sv))
+ {
+ sv_setiv(*error_nrs_sv, error_nrs);
+ }
+ else
+ {
+ SV *new_error_nrs_sv = newSViv (error_nrs);
+ hv_store (report_hv, "error_nrs",
+ strlen ("error_nrs"), new_error_nrs_sv, 0);
+ *error_nrs_out = new_error_nrs_sv;
+ }
+ }
+ }
+ }
+ else
+ {
+ /* warn if it does not looks like a Texinfo::Report object, as
+ it is likely that the error messages are going to disappear */
+ fprintf (stderr, "BUG? no 'errors_warnings'. Not a Perl
Texinfo::Report?\n");
+ }
+
+ clear_error_message_list (error_messages);
+}
+
+/* ERROR_MESSAGES can be 0, in that case the function is used to get
+ the perl references but they are not modified */
SV *
-pass_document_errors (size_t document_descriptor)
+pass_errors_to_registrar (ERROR_MESSAGE_LIST *error_messages, SV *object_sv,
+ SV **errors_warnings_out, SV **error_nrs_out)
{
- AV *av_document_errors_list;
- DOCUMENT *document = 0;
+ HV *object_hv;
+ SV **registrar_sv;
+ const char *registrar_key = "registrar";
dTHX;
- document = retrieve_document (document_descriptor);
+ object_hv = (HV *) SvRV (object_sv);
- if (!document)
- return newSV (0);
+ registrar_sv = hv_fetch (object_hv, registrar_key,
+ strlen (registrar_key), 0);
+ if (registrar_sv && SvOK (*registrar_sv))
+ {
+ HV *report_hv = (HV *) SvRV (*registrar_sv);
+ add_formatted_error_messages (error_messages, report_hv,
+ errors_warnings_out, error_nrs_out);
+ return newRV_inc ((SV *) report_hv);
+ }
+ *errors_warnings_out = 0;
+ *error_nrs_out = 0;
+ return newSV (0);
+}
- av_document_errors_list = build_errors (document->error_messages->list,
- document->error_messages->number);
+void
+pass_document_parser_errors_to_registrar (int document_descriptor,
+ SV *parser_sv)
+{
+ DOCUMENT *document;
+ SV *errors_warnings_sv = 0;
+ SV *error_nrs_sv = 0;
+
+ dTHX;
- clear_document_errors (document->descriptor);
+ document = retrieve_document (document_descriptor);
+
+ if (!document)
+ return;
- return newRV_inc ((SV *) av_document_errors_list);
+ pass_errors_to_registrar (document->parser_error_messages, parser_sv,
+ &errors_warnings_sv, &error_nrs_sv);
}
@@ -1410,6 +1530,8 @@ rebuild_document (SV *document_in, int no_store)
}
}
+
+
static void
output_unit_to_perl_hash (OUTPUT_UNIT *output_unit)
{
@@ -1664,6 +1786,8 @@ rebuild_output_units_list (SV *output_units_sv, size_t
output_units_descriptor)
}
}
+
+
SV *
get_conf (CONVERTER *converter, const char *option_name)
{
@@ -1674,149 +1798,6 @@ get_conf (CONVERTER *converter, const char *option_name)
return newSV (0);
}
-/* add C messages to a Texinfo::Report object, like
- Texinfo::Report::add_formatted_message does.
- NOTE probably not useful for converters as errors need to be passed
- explicitely both from Perl and XS.
-
- Also return $report->{'errors_warnings'} in ERRORS_WARNINGS_OUT and
- $report->{'error_nrs'} in ERRORS_NRS_OUT, even if ERROR_MESSAGES is
- 0, to avoid the need to fetch them from report_hv if calling code
- is interested in those SV.
- */
-static void
-add_formatted_error_messages (ERROR_MESSAGE_LIST *error_messages,
- HV *report_hv, SV **errors_warnings_out,
- SV **error_nrs_out)
-{
- SV **errors_warnings_sv;
- SV **error_nrs_sv;
- int i;
-
- dTHX;
-
-
- *errors_warnings_out = 0;
- *error_nrs_out = 0;
-
- if (!report_hv)
- {
- fprintf (stderr, "add_formatted_error_messages: BUG: no perl report\n");
- return;
- }
-
- errors_warnings_sv = hv_fetch (report_hv, "errors_warnings",
- strlen ("errors_warnings"), 0);
-
- error_nrs_sv = hv_fetch (report_hv, "error_nrs",
- strlen ("error_nrs"), 0);
-
- if (errors_warnings_sv && SvOK (*errors_warnings_sv))
- {
- int error_nrs = 0;
- if (error_nrs_sv && SvOK (*error_nrs_sv))
- {
- error_nrs = SvIV (*error_nrs_sv);
- *error_nrs_out = *error_nrs_sv;
- }
- *errors_warnings_out = *errors_warnings_sv;
-
- if (!error_messages)
- {
- /* TODO if this message appears in output, it should probably
- be removed, as this situation is allowed from DocumentXS.xs
- document_errors */
- fprintf (stderr,
- "add_formatted_error_messages: NOTE: no error_messages\n");
- return;
- }
- else
- {
- AV *av = (AV *)SvRV (*errors_warnings_sv);
-
- for (i = 0; i < error_messages->number; i++)
- {
- ERROR_MESSAGE error_msg = error_messages->list[i];
- SV *sv = convert_error (error_msg);
-
- if (error_msg.type == MSG_error && !error_msg.continuation)
- error_nrs++;
- av_push (av, sv);
- }
-
- if (error_nrs)
- {
- if (error_nrs_sv && SvOK (*error_nrs_sv))
- {
- sv_setiv(*error_nrs_sv, error_nrs);
- }
- else
- {
- SV *new_error_nrs_sv = newSViv (error_nrs);
- hv_store (report_hv, "error_nrs",
- strlen ("error_nrs"), new_error_nrs_sv, 0);
- *error_nrs_out = new_error_nrs_sv;
- }
- }
- }
- }
- else
- {
- /* warn if it does not looks like a Texinfo::Report object, as
- it is likely that the error messages are going to disappear */
- fprintf (stderr, "BUG? no 'errors_warnings'. Not a Perl
Texinfo::Report?\n");
- }
-
- clear_error_message_list (error_messages);
-}
-
-/* ERROR_MESSAGES can be 0, in that case the function is used to get
- the perl references but they are not modified */
-SV *
-pass_errors_to_registrar (ERROR_MESSAGE_LIST *error_messages, SV *object_sv,
- SV **errors_warnings_out, SV **error_nrs_out)
-{
- HV *object_hv;
- SV **registrar_sv;
- const char *registrar_key = "registrar";
-
- dTHX;
-
- object_hv = (HV *) SvRV (object_sv);
-
- registrar_sv = hv_fetch (object_hv, registrar_key,
- strlen (registrar_key), 0);
- if (registrar_sv && SvOK (*registrar_sv))
- {
- HV *report_hv = (HV *) SvRV (*registrar_sv);
- add_formatted_error_messages (error_messages, report_hv,
- errors_warnings_out, error_nrs_out);
- return newRV_inc ((SV *) report_hv);
- }
- *errors_warnings_out = 0;
- *error_nrs_out = 0;
- return newSV (0);
-}
-
-void
-pass_document_parser_errors_to_registrar (int document_descriptor,
- SV *parser_sv)
-{
- DOCUMENT *document;
- SV *errors_warnings_sv = 0;
- SV *error_nrs_sv = 0;
-
- dTHX;
-
- document = retrieve_document (document_descriptor);
-
- if (!document)
- return;
-
- pass_errors_to_registrar (document->parser_error_messages, parser_sv,
- &errors_warnings_sv, &error_nrs_sv);
-}
-
AV *
build_integer_stack (const INTEGER_STACK *integer_stack)
{
diff --git a/tp/Texinfo/XS/main/build_perl_info.h
b/tp/Texinfo/XS/main/build_perl_info.h
index d831c636bc..e857d6d579 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -49,7 +49,6 @@ HV *build_global_commands (GLOBAL_COMMANDS
*global_commands_ref);
void pass_document_parser_errors_to_registrar (int document_descriptor,
SV *parser_sv);
-SV *pass_document_errors (size_t document_descriptor);
SV *pass_errors_to_registrar (ERROR_MESSAGE_LIST *error_messages,
SV *object_sv,
SV **errors_warnings_out, SV **error_nrs_out);
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 72b1452009..f38de7fbb7 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -200,6 +200,7 @@ sub _get_parser_info($$;$$) {
my $no_build = shift;
my $no_store = shift;
+ # make sure that the parser Texinfo::Report registrar is setup
my ($parser_registrar, $configuration_information)
= _get_parser_error_registrar($self);
@@ -214,9 +215,6 @@ sub _get_parser_info($$;$$) {
$document = build_document ($document_descriptor, $no_store);
}
- #Texinfo::Translations::complete_indices ($self,
- # $document->indices_information());
-
# additional info relevant in perl only.
my $perl_encoding
= Texinfo::Common::get_perl_encoding($document->{'commands_info'},
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/DocumentXS.xs, tp/Texinfo/XS/main/build_perl_info.c: remove pass_document_errors.,
Patrice Dumas <=