[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/build_perl_info.c (get_or_bu
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/build_perl_info.c (get_or_build_document), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file) (errors): if a handle on a document is returned, do not set a registrar but instead keep with last_document_descriptor key a way to find the document where parser errors are registered for the next call to parser->errors. |
Date: |
Sun, 20 Oct 2024 11:49:55 -0400 |
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 84ab5b55ff * tp/Texinfo/XS/main/build_perl_info.c
(get_or_build_document), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file)
(errors): if a handle on a document is returned, do not set a registrar but
instead keep with last_document_descriptor key a way to find the document where
parser errors are registered for the next call to parser->errors.
84ab5b55ff is described below
commit 84ab5b55ff4853659b22bc39fed10aa578d81806
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Oct 20 17:49:49 2024 +0200
* tp/Texinfo/XS/main/build_perl_info.c (get_or_build_document),
tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file)
(errors): if a handle on a document is returned, do not set a
registrar but instead keep with last_document_descriptor key a
way to find the document where parser errors are registered for the
next call to parser->errors.
---
ChangeLog | 9 ++++++++
tp/Texinfo/XS/main/build_perl_info.c | 22 +++++++++++++-----
tp/Texinfo/XS/parsetexi/Parsetexi.xs | 45 ++++++++++++++++++++++++++++--------
3 files changed, 61 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index edac89d379..62459b1b7d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-10-20 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/build_perl_info.c (get_or_build_document),
+ tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file)
+ (errors): if a handle on a document is returned, do not set a
+ registrar but instead keep with last_document_descriptor key a
+ way to find the document where parser errors are registered for the
+ next call to parser->errors.
+
2024-10-20 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/parsetexi/Parsetexi.pm,
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 6b052bbd69..aabbb41c84 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1941,14 +1941,24 @@ get_or_build_document (SV *parser_sv, size_t
document_descriptor, int no_store)
{
dTHX;
- /* get hold of errors before calling build_document, as if no_store is set
- they will be destroyed. */
- pass_document_parser_errors_to_registrar (document_descriptor, parser_sv);
-
if (!no_store)
- return get_document (document_descriptor);
+ {
+ /* Keep an information on the document descriptor to be able to get the
+ parser errors */
+ HV *parser_hv = (HV *) SvRV (parser_sv);
+ hv_store (parser_hv, "last_document_descriptor",
+ strlen ("last_document_descriptor"),
+ newSViv (document_descriptor), 0);
+ return get_document (document_descriptor);
+ }
else
- return build_document (document_descriptor, 1);
+ {
+ /* get hold of errors before calling build_document, as they will be
+ destroyed since no_store is set. */
+ pass_document_parser_errors_to_registrar (document_descriptor,
+ parser_sv);
+ return build_document (document_descriptor, 1);
+ }
}
/* Currently unused, but could be */
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
index 3bce6e16e9..6bcbd3b69b 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
@@ -97,16 +97,19 @@ parse_texi_file (SV *parser, input_file_path)
int status;
apply_sv_parser_conf (parser);
document_descriptor = parse_file (input_file_path, &status);
- pass_document_parser_errors_to_registrar (document_descriptor,
- parser);
if (status)
/* if the input file could not be opened */
{
+ pass_document_parser_errors_to_registrar (document_descriptor,
+ parser);
remove_document_descriptor (document_descriptor);
RETVAL = newSV (0);
}
else
- RETVAL = get_document (document_descriptor);
+ {
+ RETVAL
+ = get_or_build_document (parser, document_descriptor, 0);
+ }
}
OUTPUT:
RETVAL
@@ -296,26 +299,50 @@ void
parser_conf_set_accept_internalvalue (int value)
# two possibilities
+# - errors should be in the last parsed document->parser_error_messages
# - 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;
+ SV **last_document_descriptor_sv;
HV *parser_hv;
PPCODE:
parser_hv = (HV *)SvRV (parser_sv);
- registrar_sv = hv_fetch (parser_hv, "registrar", strlen ("registrar"),
- 0);
+ last_document_descriptor_sv = hv_fetch (parser_hv,
+ "last_document_descriptor", strlen ("last_document_descriptor"), 0);
- if (registrar_sv)
+ if (last_document_descriptor_sv)
+ {
+ AV *av;
+ size_t document_descriptor = SvIV (*last_document_descriptor_sv);
+ DOCUMENT *document = retrieve_document (document_descriptor);
+ if (document)
+ {
+ ERROR_MESSAGE_LIST *error_messages
+ = &document->parser_error_messages;
+ av = build_errors (error_messages->list,
+ error_messages->number);
+ error_nrs_sv = newSViv (error_messages->error_nrs);
+ }
+ else
+ {
+ /* This could theoretically happen if the document is destroyed before
+ getting the parser errors */
+ av = newAV ();
+ error_nrs_sv = newSViv (0);
+ }
+ errors_warnings_sv = newRV_noinc ((SV *) av);
+ }
+ else
{
- HV *registrar_hv = (HV *)SvRV (*registrar_sv);
SV **registrar_errors_warnings_sv;
SV **registrar_error_nrs_sv;
AV *empty_errors_warnings = newAV ();
+ SV **registrar_sv = hv_fetch (parser_hv, "registrar",
+ strlen ("registrar"), 0);
+ HV *registrar_hv = (HV *)SvRV (*registrar_sv);
registrar_errors_warnings_sv
= hv_fetch (registrar_hv, "errors_warnings",
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/build_perl_info.c (get_or_build_document), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file) (errors): if a handle on a document is returned, do not set a registrar but instead keep with last_document_descriptor key a way to find the document where parser errors are registered for the next call to parser->errors.,
Patrice Dumas <=