[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_tex
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file) (parse_texi_piece, parse_string, parse_texi_text): in Parsetexi.xs, define directly parse_texi_file instead of parse_file, parse_texi_piece instead of parse_piece, parse_texi_text instead of parse_text and check arguments in parse_string. Remove parse_texi_file, parse_texi_piece and parse_texi_text from Parsetexi.pm. |
Date: |
Sun, 20 Oct 2024 08:03:18 -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 cae93b98be * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_line),
tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file) (parse_texi_piece,
parse_string, parse_texi_text): in Parsetexi.xs, define directly
parse_texi_file instead of parse_file, parse_texi_piece instead of parse_piece,
parse_texi_text instead of parse_text and check arguments in parse_string.
Remove parse_texi_file, parse_texi_piece and parse_texi_text from Parsetexi.pm.
cae93b98be is described below
commit cae93b98beea3ee623ef8a9693f5700634fee8cd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Oct 20 14:03:11 2024 +0200
* tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_line),
tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file)
(parse_texi_piece, parse_string, parse_texi_text): in Parsetexi.xs,
define directly parse_texi_file instead of parse_file,
parse_texi_piece instead of parse_piece, parse_texi_text instead of
parse_text and check arguments in parse_string. Remove
parse_texi_file, parse_texi_piece and parse_texi_text from
Parsetexi.pm.
---
ChangeLog | 11 ++++
tp/Texinfo/XS/main/get_perl_info.c | 1 +
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 54 +------------------
tp/Texinfo/XS/parsetexi/Parsetexi.xs | 101 +++++++++++++++++++++++------------
4 files changed, 79 insertions(+), 88 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 051f80f45d..72e0e4cdbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-10-20 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_line),
+ tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file)
+ (parse_texi_piece, parse_string, parse_texi_text): in Parsetexi.xs,
+ define directly parse_texi_file instead of parse_file,
+ parse_texi_piece instead of parse_piece, parse_texi_text instead of
+ parse_text and check arguments in parse_string. Remove
+ parse_texi_file, parse_texi_piece and parse_texi_text from
+ Parsetexi.pm.
+
2024-10-20 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/parsetexi/Parsetexi.xs: remove now unused XS
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index 3c8ec063f8..6ff48fc97c 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -268,6 +268,7 @@ get_sv_output_units (const DOCUMENT *document,
return output_units;
}
+/* retrieve C stored configuration from parser and set it */
void
apply_sv_parser_conf (SV *parser_sv)
{
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 004cf12111..7b6e3751d4 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -40,12 +40,7 @@ use warnings;
# To check if there is no erroneous autovivification
#no autovivification qw(fetch delete exists store strict);
-use Storable qw(dclone); # standard in 5.007003
-use Encode qw(decode);
-
-use Texinfo::Common;
use Texinfo::Report;
-use Texinfo::Document;
# Initialize the parser
# The last argument, optional, is a hash provided by the user to change
@@ -139,58 +134,11 @@ sub parser (;$)
return $parser;
}
-sub parse_texi_file ($$)
-{
- my $self = shift;
- my $input_file_path = shift;
-
- return undef if (!defined($self));
-
- # the file is already a byte string, taken as is from the command
- # line. The encoding was detected as COMMAND_LINE_ENCODING.
- my $document = parse_file($self, $input_file_path);
- return $document;
-}
-
-
-# Used in tests under tp/t.
-sub parse_texi_piece($$;$$)
-{
- my ($self, $text, $line_nr, $no_store) = @_;
-
- return undef if (!defined($text) or !defined($self));
-
- $line_nr = 1 if (not defined($line_nr));
-
- my $document = parse_piece($self, $text, $line_nr, $no_store);
-
- return $document;
-}
-
-# Used in tests under tp/t.
-sub parse_texi_text($$;$)
-{
- my ($self, $text, $line_nr) = @_;
-
- return undef if (!defined($text) or !defined($self));
-
- $line_nr = 1 if (not defined($line_nr));
-
- my $document = parse_text($self, $text, $line_nr);
-
- return $document;
-}
-
sub parse_texi_line($$;$$)
{
my ($self, $text, $line_nr, $no_store) = @_;
-
- return undef if (!defined($text) or !defined($self));
-
- $line_nr = 1 if (not defined($line_nr));
-
my $document = parse_string($self, $text, $line_nr, $no_store);
-
+ return undef if (!defined($document));
return $document->tree();
}
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
index 17962516da..8ee0c3491e 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
@@ -82,71 +82,102 @@ register_parser_conf (SV *parser)
hv_store (hv_in, key, strlen (key),
newSViv ((IV) parser_conf->descriptor), 0);
-# file path, can be in any encoding
+# the file is already a byte string, taken as is from the command line.
+# The encoding was detected as COMMAND_LINE_ENCODING.
SV *
-parse_file (SV *parser, input_file_path)
+parse_texi_file (SV *parser, input_file_path)
char *input_file_path = (char *)SvPVbyte_nolen ($arg);
PREINIT:
- int status;
size_t document_descriptor = 0;
CODE:
- 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 */
+ if (!SvOK(parser))
+ RETVAL = newSV (0);
+ else
{
- remove_document_descriptor (document_descriptor);
- RETVAL = newSV (0);
+ 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 */
+ {
+ remove_document_descriptor (document_descriptor);
+ RETVAL = newSV (0);
+ }
+ else
+ RETVAL = get_document (document_descriptor);
}
- else
- RETVAL = get_document (document_descriptor);
OUTPUT:
RETVAL
-# note that giving optional arguments, like: int no_store=0
-# would have been nice, but in that case an undef value cannot be passed
-# and leads to a perl warning
+# Used in tests under tp/t.
SV *
-parse_piece (SV *parser, string, int line_nr, ...)
- char *string = (char *)SvPVutf8_nolen ($arg);
+parse_texi_piece (SV *parser, SV *string_sv, ...)
PREINIT:
size_t document_descriptor = 0;
int no_store = 0;
+ int line_nr = 1;
CODE:
- if (items > 3 && SvOK(ST(3)))
- no_store = SvIV (ST(3));
- apply_sv_parser_conf (parser);
- document_descriptor = parse_piece (string, line_nr);
- RETVAL = get_or_build_document (parser, document_descriptor, no_store);
+ if (!SvOK(string_sv) || !SvOK(parser))
+ RETVAL = newSV (0);
+ else
+ {
+ char *string = (char *)SvPVutf8_nolen (string_sv);
+ if (items > 2 && SvOK(ST(2)))
+ line_nr = SvIV (ST(2));
+ if (items > 3 && SvOK(ST(3)))
+ no_store = SvIV (ST(3));
+ apply_sv_parser_conf (parser);
+ document_descriptor = parse_piece (string, line_nr);
+ RETVAL = get_or_build_document (parser, document_descriptor,
+ no_store);
+ }
OUTPUT:
RETVAL
SV *
-parse_string (SV *parser, string, int line_nr, ...)
- char *string = (char *)SvPVutf8_nolen ($arg);
+parse_string (SV *parser, SV *string_sv, ...)
PREINIT:
size_t document_descriptor = 0;
int no_store = 0;
+ int line_nr = 1;
CODE:
- if (items > 3 && SvOK(ST(3)))
- no_store = SvIV (ST(3));
- apply_sv_parser_conf (parser);
- document_descriptor = parse_string (string, line_nr);
- RETVAL = get_or_build_document (parser, document_descriptor, no_store);
+ if (!SvOK(string_sv) || !SvOK(parser))
+ RETVAL = newSV (0);
+ else
+ {
+ char *string = (char *)SvPVutf8_nolen (string_sv);
+ if (items > 2 && SvOK(ST(2)))
+ line_nr = SvIV (ST(2));
+ if (items > 3 && SvOK(ST(3)))
+ no_store = SvIV (ST(3));
+ apply_sv_parser_conf (parser);
+ document_descriptor = parse_string (string, line_nr);
+ RETVAL = get_or_build_document (parser, document_descriptor,
+ no_store);
+ }
OUTPUT:
RETVAL
+# Used in tests under tp/t.
SV *
-parse_text (SV *parser, string, int line_nr)
- char *string = (char *)SvPVutf8_nolen ($arg);
+parse_texi_text (SV *parser, SV *string_sv, ...)
PREINIT:
size_t document_descriptor = 0;
+ int line_nr = 1;
CODE:
- apply_sv_parser_conf (parser);
- document_descriptor = parse_text (string, line_nr);
- RETVAL = get_or_build_document (parser, document_descriptor, 0);
+ if (!SvOK(string_sv) || !SvOK(parser))
+ RETVAL = newSV (0);
+ else
+ {
+ char *string = (char *)SvPVutf8_nolen (string_sv);
+ if (items > 2 && SvOK(ST(2)))
+ line_nr = SvIV (ST(2));
+ apply_sv_parser_conf (parser);
+ document_descriptor = parse_text (string, line_nr);
+ RETVAL = get_or_build_document (parser, document_descriptor, 0);
+ }
OUTPUT:
RETVAL
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file) (parse_texi_piece, parse_string, parse_texi_text): in Parsetexi.xs, define directly parse_texi_file instead of parse_file, parse_texi_piece instead of parse_piece, parse_texi_text instead of parse_text and check arguments in parse_string. Remove parse_texi_file, parse_texi_piece and parse_texi_text from Parsetexi.pm.,
Patrice Dumas <=