[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser, p
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser, parse_texi_piece) (parse_texi_text, parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_piece, parse_piece) (parse_string, parse_text, parser_add_expanded_format) (parser_set_input_file_name_encoding, parser_set_locale_encoding) (parser_set_documentlanguage_override): do not encode to UTF-8 in Perl code and get binary strings in XS, instead use SvPVutf8 to get string and convert to UTF-8 in XS. |
Date: |
Sun, 19 May 2024 14:49:40 -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 3654c5967a * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser,
parse_texi_piece) (parse_texi_text, parse_texi_line),
tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_piece, parse_piece) (parse_string,
parse_text, parser_add_expanded_format) (parser_set_input_file_name_encoding,
parser_set_locale_encoding) (parser_set_documentlanguage_override): do not
encode to UTF-8 in Perl code and get binary strings in XS, instead use SvPVutf8
to get string and convert to UTF-8 in XS.
3654c5967a is described below
commit 3654c5967ad369e04a6e7416612e75d3c3f388b5
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun May 19 20:49:40 2024 +0200
* tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser, parse_texi_piece)
(parse_texi_text, parse_texi_line),
tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_piece, parse_piece)
(parse_string, parse_text, parser_add_expanded_format)
(parser_set_input_file_name_encoding, parser_set_locale_encoding)
(parser_set_documentlanguage_override): do not encode to UTF-8 in Perl
code and get binary strings in XS, instead use SvPVutf8 to get string
and convert to UTF-8 in XS.
* tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser): check on keys
independentely of values, i.e. do not test in one condition the key name
and whether the value is defined, use only the key name in the first
condition and test afterwards if the value is defined.
* tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser),
tp/Texinfo/XS/parsetexi/Parsetexi.xs: change in spacing.
---
ChangeLog | 19 +++++++++++++
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 54 ++++++++++++++++--------------------
tp/Texinfo/XS/parsetexi/Parsetexi.xs | 30 ++++++++++----------
3 files changed, 58 insertions(+), 45 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e49e7e4839..ab278987bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2024-05-19 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser, parse_texi_piece)
+ (parse_texi_text, parse_texi_line),
+ tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_piece, parse_piece)
+ (parse_string, parse_text, parser_add_expanded_format)
+ (parser_set_input_file_name_encoding, parser_set_locale_encoding)
+ (parser_set_documentlanguage_override): do not encode to UTF-8 in Perl
+ code and get binary strings in XS, instead use SvPVutf8 to get string
+ and convert to UTF-8 in XS.
+
+ * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser): check on keys
+ independentely of values, i.e. do not test in one condition the key name
+ and whether the value is defined, use only the key name in the first
+ condition and test afterwards if the value is defined.
+
+ * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser),
+ tp/Texinfo/XS/parsetexi/Parsetexi.xs: change in spacing.
+
2024-05-19 Patrice Dumas <pertusus@free.fr>
Remove memory leaks (valgrind)
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 6b29e3cd26..431614a508 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -91,41 +91,39 @@ sub parser (;$$)
# configuration is set afterwards.
my $debug = 0;
$debug = $parser->{'DEBUG'} if ($parser->{'DEBUG'});
- reset_parser ($debug);
+ reset_parser($debug);
# (re)set debug in any case, assuming that undef DEBUG is no debug
- parser_set_debug ($debug);
+ parser_set_debug($debug);
if (defined($conf)) {
- foreach my $key (keys (%$conf)) {
+ foreach my $key (keys(%$conf)) {
if ($key eq 'INCLUDE_DIRECTORIES') {
# the directories from the command line or the input file name
# are already byte strings (or ascii). The encoding was detected
# as COMMAND_LINE_ENCODING, but it is not used in the XS parser.
foreach my $d (@{$conf->{'INCLUDE_DIRECTORIES'}}) {
- parser_add_include_directory ($d);
+ parser_add_include_directory($d);
}
} elsif ($key eq 'values') {
parser_store_values($conf->{'values'});
} elsif ($key eq 'EXPANDED_FORMATS') {
- parser_clear_expanded_formats ();
+ parser_clear_expanded_formats();
for my $f (@{$conf->{$key}}) {
- my $utf8_bytes = Encode::encode('utf-8', $f);
- parser_add_expanded_format ($utf8_bytes);
+ parser_add_expanded_format($f);
}
} elsif ($key eq 'documentlanguage') {
if (defined ($conf->{$key})) {
- my $utf8_bytes = Encode::encode('utf-8', $conf->{$key});
- parser_set_documentlanguage_override ($utf8_bytes);
+ parser_set_documentlanguage_override($conf->{$key});
}
} elsif ($key eq 'FORMAT_MENU') {
if ($conf->{$key} and $conf->{$key} eq 'menu') {
- conf_set_show_menu (1);
+ conf_set_show_menu(1);
} else {
- conf_set_show_menu (0);
+ conf_set_show_menu(0);
}
} elsif ($key eq 'IGNORE_SPACE_AFTER_BRACED_COMMAND_NAME') {
- conf_set_IGNORE_SPACE_AFTER_BRACED_COMMAND_NAME ($conf->{$key});
+ conf_set_IGNORE_SPACE_AFTER_BRACED_COMMAND_NAME($conf->{$key});
} elsif ($key eq 'CPP_LINE_DIRECTIVES') {
conf_set_CPP_LINE_DIRECTIVES($conf->{$key});
} elsif ($key eq 'MAX_MACRO_CALL_NESTING') {
@@ -135,13 +133,15 @@ sub parser (;$$)
} elsif ($key eq 'NO_USER_COMMANDS') {
conf_set_NO_USER_COMMANDS($conf->{$key});
} elsif ($key eq 'DOC_ENCODING_FOR_INPUT_FILE_NAME') {
- parser_set_DOC_ENCODING_FOR_INPUT_FILE_NAME ($conf->{$key});
- } elsif ($key eq 'INPUT_FILE_NAME_ENCODING' and defined($conf->{$key})) {
- my $utf8_bytes = Encode::encode('utf-8', $conf->{$key});
- parser_set_input_file_name_encoding ($utf8_bytes);
- } elsif ($key eq 'LOCALE_ENCODING' and defined($conf->{$key})) {
- my $utf8_bytes = Encode::encode('utf-8', $conf->{$key});
- parser_set_locale_encoding ($utf8_bytes);
+ parser_set_DOC_ENCODING_FOR_INPUT_FILE_NAME($conf->{$key});
+ } elsif ($key eq 'INPUT_FILE_NAME_ENCODING') {
+ if (defined($conf->{$key})) {
+ parser_set_input_file_name_encoding($conf->{$key});
+ }
+ } elsif ($key eq 'LOCALE_ENCODING') {
+ if (defined($conf->{$key})) {
+ parser_set_locale_encoding($conf->{$key});
+ }
} elsif ($key eq 'accept_internalvalue' and $conf->{$key}) {
parser_set_accept_internalvalue(1);
} elsif ($key eq 'registrar' or $key eq 'COMMAND_LINE_ENCODING'
@@ -218,8 +218,8 @@ sub parse_texi_file ($$)
# TODO instead of using fileparse here, reimplement fileparse
# in XS, or use a file name parsing code from somewhere else?
my ($basename, $directories, $suffix) = fileparse($input_file_path);
- my $document_descriptor = parse_file ($input_file_path,
- $basename, $directories);
+ my $document_descriptor = parse_file($input_file_path,
+ $basename, $directories);
if (!$document_descriptor) {
my ($parser_registrar, $configuration_information)
= _get_parser_error_registrar($self);
@@ -248,9 +248,7 @@ sub parse_texi_piece($$;$$)
$line_nr = 1 if (not defined($line_nr));
- # pass a binary UTF-8 encoded string to C code
- my $utf8_bytes = Encode::encode('utf-8', $text);
- my $document_descriptor = parse_piece($utf8_bytes, $line_nr);
+ my $document_descriptor = parse_piece($text, $line_nr);
my $document = _get_parser_info($self, $document_descriptor, $no_store);
@@ -266,9 +264,7 @@ sub parse_texi_text($$;$)
$line_nr = 1 if (not defined($line_nr));
- # pass a binary UTF-8 encoded string to C code
- my $utf8_bytes = Encode::encode('utf-8', $text);
- my $document_descriptor = parse_text($utf8_bytes, $line_nr);
+ my $document_descriptor = parse_text($text, $line_nr);
my $document = _get_parser_info($self, $document_descriptor);
@@ -283,9 +279,7 @@ sub parse_texi_line($$;$$)
$line_nr = 1 if (not defined($line_nr));
- # pass a binary UTF-8 encoded string to C code
- my $utf8_bytes = Encode::encode('utf-8', $text);
- my $document_descriptor = parse_string($utf8_bytes, $line_nr);
+ my $document_descriptor = parse_string($text, $line_nr);
my $document = _get_parser_info($self, $document_descriptor, $no_store);
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
index 7eff083c9f..50bae2b384 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
@@ -54,31 +54,31 @@ PROTOTYPES: ENABLE
int
init (texinfo_uninstalled, builddir)
int texinfo_uninstalled
- char *builddir = (char *)SvPVbyte_nolen($arg);
+ char *builddir = (char *)SvPVbyte_nolen ($arg);
void
reset_parser (int debug_output)
# file path, can be in any encoding
int
-parse_file(filename, input_file_name, input_directory)
- char *filename = (char *)SvPVbyte_nolen($arg);
- char *input_file_name = (char *)SvPVbyte_nolen($arg);
- char *input_directory = (char *)SvPVbyte_nolen($arg);
+parse_file (filename, input_file_name, input_directory)
+ char *filename = (char *)SvPVbyte_nolen ($arg);
+ char *input_file_name = (char *)SvPVbyte_nolen ($arg);
+ char *input_directory = (char *)SvPVbyte_nolen ($arg);
int
-parse_piece(string, line_nr)
- char *string = (char *)SvPVbyte_nolen($arg);
+parse_piece (string, line_nr)
+ char *string = (char *)SvPVutf8_nolen ($arg);
int line_nr
int
-parse_string(string, line_nr)
- char *string = (char *)SvPVbyte_nolen($arg);
+parse_string (string, line_nr)
+ char *string = (char *)SvPVutf8_nolen ($arg);
int line_nr
int
-parse_text(string, line_nr)
- char *string = (char *)SvPVbyte_nolen($arg);
+parse_text (string, line_nr)
+ char *string = (char *)SvPVutf8_nolen ($arg);
int line_nr
# note that giving optional arguments, like: int no_store=0
@@ -137,7 +137,7 @@ parser_clear_expanded_formats ()
void
parser_add_expanded_format (format)
- char *format = (char *)SvPVbyte_nolen($arg);
+ char *format = (char *)SvPVutf8_nolen ($arg);
void
conf_set_show_menu (int i)
@@ -162,15 +162,15 @@ parser_set_DOC_ENCODING_FOR_INPUT_FILE_NAME (int i)
void
parser_set_input_file_name_encoding (value)
- char *value = (char *)SvPVbyte_nolen($arg);
+ char *value = (char *)SvPVutf8_nolen ($arg);
void
parser_set_locale_encoding (value)
- char *value = (char *)SvPVbyte_nolen($arg);
+ char *value = (char *)SvPVutf8_nolen ($arg);
void
parser_set_documentlanguage_override (value)
- char *value = (char *)SvPVbyte_nolen($arg);
+ char *value = (char *)SvPVutf8_nolen ($arg);
void
parser_set_debug (int i)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parser, parse_texi_piece) (parse_texi_text, parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_piece, parse_piece) (parse_string, parse_text, parser_add_expanded_format) (parser_set_input_file_name_encoding, parser_set_locale_encoding) (parser_set_documentlanguage_override): do not encode to UTF-8 in Perl code and get binary strings in XS, instead use SvPVutf8 to get string and convert to UTF-8 in XS.,
Patrice Dumas <=