[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Mon, 27 Nov 2023 12:16:50 -0500 (EST) |
branch: master
commit 4c2b16f8fd2f75bb03ed4d1da29ce6d2df7de8ac
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Nov 27 16:23:47 2023 +0000
* tp/Texinfo/ParserNonXS.pm (_new_macro),
(_parse_line_command_args) <@alias, @definfoenclose>
<@defindex, @defcodeindex>: Do nothing if 'restricted' flag set.
* tp/t/init_files_tests.t
(macro_defined_txiinternalvalue_in_translation): Remove test,
as @macro no longer works inside a translated string.
---
ChangeLog | 10 ++
tp/Makefile.tres | 1 -
tp/Texinfo/ParserNonXS.pm | 14 +-
tp/t/init/translate_txiinternalvalue_macro.init | 30 ----
tp/t/init_files_tests.t | 7 -
...acro_defined_txiinternalvalue_in_translation.pl | 155 ---------------------
6 files changed, 21 insertions(+), 196 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 48c4d98b7a..f9b7939785 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-11-27 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/ParserNonXS.pm (_new_macro),
+ (_parse_line_command_args) <@alias, @definfoenclose>
+ <@defindex, @defcodeindex>: Do nothing if 'restricted' flag set.
+
+ * tp/t/init_files_tests.t
+ (macro_defined_txiinternalvalue_in_translation): Remove test,
+ as @macro no longer works inside a translated string.
+
2023-11-27 Gavin Smith <gavinsmith0123@gmail.com>
Parser 'restricted' flag
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index d46f256d9c..6fb559e2e1 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -988,7 +988,6 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/init_files_tests/customize_translations/res_html \
t/results/init_files_tests/documentation_examples.pl \
t/results/init_files_tests/documentation_examples/res_html \
- t/results/init_files_tests/macro_defined_txiinternalvalue_in_translation.pl \
t/results/init_files_tests/modified_translation.pl \
t/results/init_files_tests/redefined_need.pl \
t/results/init_files_tests/sc_formatting_with_css.pl \
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 1c5bac1320..feaee9620c 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -6556,6 +6556,8 @@ sub _new_macro($$$)
my $name = shift;
my $current = shift;
+ return if $self->{'restricted'};
+
my $macrobody;
if (defined($current->{'contents'})) {
$macrobody =
@@ -7601,7 +7603,9 @@ sub _parse_line_command_args($$$)
if ($command eq 'alias') {
# REMACRO
- if ($line =~
s/^([[:alnum:]][[:alnum:]-]*)(\s*=\s*)([[:alnum:]][[:alnum:]-]*)$//) {
+ if ($self->{'restricted'}) {
+ # do nothing
+ } elsif ($line =~
s/^([[:alnum:]][[:alnum:]-]*)(\s*=\s*)([[:alnum:]][[:alnum:]-]*)$//) {
my $new_command = $1;
my $existing_command = $3;
$args = [$1, $3];
@@ -7631,7 +7635,9 @@ sub _parse_line_command_args($$$)
} elsif ($command eq 'definfoenclose') {
# REMACRO
# FIXME how to handle non ascii space? As space or in argument?
- if ($line =~
s/^([[:alnum:]][[:alnum:]\-]*)\s*,\s*([^\s,]*)\s*,\s*([^\s,]*)$//) {
+ if ($self->{'restricted'}) {
+ # do nothing
+ } elsif ($line =~
s/^([[:alnum:]][[:alnum:]\-]*)\s*,\s*([^\s,]*)\s*,\s*([^\s,]*)$//) {
$args = [$1, $2, $3 ];
my ($cmd_name, $begin, $end) = ($1, $2, $3);
$self->{'definfoenclose'}->{$cmd_name} = [ $begin, $end ];
@@ -7681,7 +7687,9 @@ sub _parse_line_command_args($$$)
}
} elsif ($command eq 'defindex' || $command eq 'defcodeindex') {
# REMACRO
- if ($line =~ /^([[:alnum:]][[:alnum:]\-]*)$/) {
+ if ($self->{'restricted'}) {
+ # do nothing
+ } elsif ($line =~ /^([[:alnum:]][[:alnum:]\-]*)$/) {
my $name = $1;
if ($forbidden_index_name{$name}) {
$self->_line_error(sprintf(
diff --git a/tp/t/init/translate_txiinternalvalue_macro.init
b/tp/t/init/translate_txiinternalvalue_macro.init
deleted file mode 100644
index 8269fd1a7f..0000000000
--- a/tp/t/init/translate_txiinternalvalue_macro.init
+++ /dev/null
@@ -1,30 +0,0 @@
-
-texinfo_register_command_formatting('sp', \&my_sp_formatting);
-
-sub my_sp_formatting($$$$$)
-{
- my $self = shift;
- my $cmdname = shift;
- my $command = shift;
- my $args = shift;
- my $content = shift;
-
- if (defined($command->{'extra'})
- and defined($command->{'extra'}->{'misc_args'})
- and defined($command->{'extra'}->{'misc_args'}->[0])) {
- my $sp_nr = $command->{'extra'}->{'misc_args'}->[0];
- my $translated_tree = $self->gdt('@macro txiinternalvalue
-user internalvalue
-@end macro
-{myarg} @TeX{}', {'myarg' => {'contents' => [{'text' => $sp_nr}]}});
- #print STDERR "T
".Texinfo::Common::debug_print_tree($translated_tree)."\n";
- $result = $self->convert_tree($translated_tree);
- return $result;
- }
-
- return &{$self->default_command_conversion($cmdname)}($self,
- $cmdname, $command, $args, $content);
-}
-
-
-1;
diff --git a/tp/t/init_files_tests.t b/tp/t/init_files_tests.t
index 3e4276abd5..0b1ae6e7e2 100644
--- a/tp/t/init_files_tests.t
+++ b/tp/t/init_files_tests.t
@@ -21,13 +21,6 @@ fr @error{}.
pt @error{}.
', {'init_files' => ['command_translation_modified.init']}],
-['macro_defined_txiinternalvalue_in_translation',
-'@sp 1
-
-@sp 2
-
-',{'init_files' => ['translate_txiinternalvalue_macro.init'],
-}],
);
my @file_tests = (
diff --git
a/tp/t/results/init_files_tests/macro_defined_txiinternalvalue_in_translation.pl
b/tp/t/results/init_files_tests/macro_defined_txiinternalvalue_in_translation.pl
deleted file mode 100644
index 6fb7c6f37b..0000000000
---
a/tp/t/results/init_files_tests/macro_defined_txiinternalvalue_in_translation.pl
+++ /dev/null
@@ -1,155 +0,0 @@
-use vars qw(%result_texis %result_texts %result_trees %result_errors
- %result_indices %result_sectioning %result_nodes %result_menus
- %result_floats %result_converted %result_converted_errors
- %result_elements %result_directions_text %result_indices_sort_strings);
-
-use utf8;
-
-$result_trees{'macro_defined_txiinternalvalue_in_translation'} = {
- 'contents' => [
- {
- 'contents' => [
- {
- 'args' => [
- {
- 'contents' => [
- {
- 'text' => '1'
- }
- ],
- 'info' => {
- 'spaces_after_argument' => {
- 'text' => '
-'
- }
- },
- 'type' => 'line_arg'
- }
- ],
- 'cmdname' => 'sp',
- 'extra' => {
- 'misc_args' => [
- '1'
- ]
- },
- 'info' => {
- 'spaces_before_argument' => {
- 'text' => ' '
- }
- },
- 'source_info' => {
- 'file_name' => '',
- 'line_nr' => 1,
- 'macro' => ''
- }
- },
- {
- 'text' => '
-',
- 'type' => 'empty_line'
- },
- {
- 'args' => [
- {
- 'contents' => [
- {
- 'text' => '2'
- }
- ],
- 'info' => {
- 'spaces_after_argument' => {
- 'text' => '
-'
- }
- },
- 'type' => 'line_arg'
- }
- ],
- 'cmdname' => 'sp',
- 'extra' => {
- 'misc_args' => [
- '2'
- ]
- },
- 'info' => {
- 'spaces_before_argument' => {
- 'text' => ' '
- }
- },
- 'source_info' => {
- 'file_name' => '',
- 'line_nr' => 3,
- 'macro' => ''
- }
- },
- {
- 'text' => '
-',
- 'type' => 'empty_line'
- }
- ],
- 'type' => 'before_node_section'
- }
- ],
- 'type' => 'document_root'
-};
-
-$result_texis{'macro_defined_txiinternalvalue_in_translation'} = '@sp 1
-
-@sp 2
-
-';
-
-
-$result_texts{'macro_defined_txiinternalvalue_in_translation'} = '
-
-
-
-
-';
-
-$result_errors{'macro_defined_txiinternalvalue_in_translation'} = [];
-
-
-$result_floats{'macro_defined_txiinternalvalue_in_translation'} = {};
-
-
-
-$result_converted{'html'}->{'macro_defined_txiinternalvalue_in_translation'} =
'<!DOCTYPE html>
-<html>
-<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<title>Untitled Document</title>
-
-<meta name="description" content="Untitled Document">
-<meta name="keywords" content="Untitled Document">
-<meta name="resource-type" content="document">
-<meta name="distribution" content="global">
-<meta name="viewport" content="width=device-width,initial-scale=1">
-
-
-
-</head>
-
-<body lang="en">
-user internalvalue TeX
-user internalvalue TeX
-
-
-
-</body>
-</html>
-';
-
-$result_converted_errors{'html'}->{'macro_defined_txiinternalvalue_in_translation'}
= [
- {
- 'error_line' => 'warning: must specify a title with a title command or @top
-',
- 'text' => 'must specify a title with a title command or @top',
- 'type' => 'warning'
- }
-];
-
-
-1;