texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/ParserNonXS.pm (parse_texi_line): al


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (parse_texi_line): always add a line such as to always get error messages. * tp/Texinfo/Report.pm (gdt): show errors in parsing Texinfo generated for translations.
Date: Fri, 27 Aug 2021 11:30:49 -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 6abd15a  * tp/Texinfo/ParserNonXS.pm (parse_texi_line): always add a 
line such as to always get error messages. * tp/Texinfo/Report.pm (gdt): show 
errors in parsing Texinfo generated for translations.
6abd15a is described below

commit 6abd15ac05820a3c07612391e16b8782fdc7df11
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Aug 27 17:30:38 2021 +0200

    * tp/Texinfo/ParserNonXS.pm (parse_texi_line): always add a line
    such as to always get error messages.
    * tp/Texinfo/Report.pm (gdt): show errors in parsing Texinfo generated
    for translations.
    
    * tp/Texinfo/ParserNonXS.pm (_setup_conf): use same error message
    as XS parser for unknown configuration option.
    
    * tp/t/test_utils.pl: add parser_options->{'init_files'} to support
    tests loading init files.
---
 ChangeLog                                          |  13 +
 tp/Texinfo/Convert/HTML.pm                         |   4 +-
 tp/Texinfo/ParserNonXS.pm                          |  25 +-
 tp/Texinfo/Report.pm                               |  18 +-
 tp/t/README                                        |   6 +
 tp/t/init/command_translation_modified.init        |   5 +
 tp/t/init/translate_txiinternalvalue_macro.init    |  27 ++
 tp/t/init_files.t                                  |  43 +++
 ...acro_defined_txiinternalvalue_in_translation.pl | 173 ++++++++++++
 .../init_files_tests/modified_translation.pl       | 311 +++++++++++++++++++++
 tp/t/results/init_files_tests/redefined_need.pl    | 125 +++++++++
 tp/t/test_utils.pl                                 |  28 ++
 12 files changed, 759 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 622e16a..5666b69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2021-08-27  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (parse_texi_line): always add a line
+       such as to always get error messages.
+       * tp/Texinfo/Report.pm (gdt): show errors in parsing Texinfo generated
+       for translations.
+
+       * tp/Texinfo/ParserNonXS.pm (_setup_conf): use same error message
+       as XS parser for unknown configuration option.
+
+       * tp/t/test_utils.pl: add parser_options->{'init_files'} to support
+       tests loading init files.
+
 2021-08-26  Patrice Dumas  <pertusus@free.fr>
 
        replace in_gdt by accept_internalvalue
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 0714e8c..d01e5a5 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -1319,8 +1319,8 @@ $default_commands_formatting{'normal'}->{"\t"} = '&nbsp;';
 $default_commands_formatting{'normal'}->{"\n"} = '&nbsp;';
 
 my %default_commands_translation;
-# possible example of use, right now not used, as the generic
-# translated command with gdt tree is used.
+# possible example of use, right now not used, as 'translated_commands'
+# in the generic Converter customization is directly used.
 #$default_commands_translation{'normal'}->{'error'} = 'error--&gt;';
 ## This is used to have gettext pick up the chain to be translated
 #if (0) {
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 27118e4..a000830 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -143,8 +143,8 @@ my %parser_state_configuration = (
                                # currently set if called by gdt.
   'clickstyle' => 'arrow',
   'kbdinputstyle' => 'distinct',
-  # this is not really used, but this allows to have an
-  # output more similar to the XS parser output.
+  # this is not really needed, as it would be autogenerated,
+  # but this allows to have an output more similar to the XS parser output.
   'floats' => {},
 );
 
@@ -613,9 +613,9 @@ sub _deep_copy($)
   return $struct;
 }
 
-sub _setup_conf($$$)
+sub _setup_conf($$)
 {
-  my ($parser, $conf, $module_name) = @_;
+  my ($parser, $conf) = @_;
 
   if (defined($conf)) {
     foreach my $key (keys(%$conf)) {
@@ -632,7 +632,7 @@ sub _setup_conf($$$)
           $parser->{'set'}->{$key} = $parser->{$key};
         }
       } else {
-        warn "$key not a possible customization in $module_name\n";
+        warn "ignoring parser configuration value \"$key\"\n";
       }
     }
   }
@@ -654,7 +654,7 @@ sub parser(;$$)
 sub _setup_parser {
   my ($parser, $conf) = @_;
 
-  _setup_conf($parser, $conf, "Texinfo::Parser::parser");
+  _setup_conf($parser, $conf);
 
   # Now initialize command hash that are dynamically modified, notably
   # those for index commands, and lists, based on defaults and user provided.
@@ -738,7 +738,7 @@ sub simple_parser(;$)
   my $parser = dclone(\%parser_default_configuration);
   bless $parser;
 
-  _setup_conf($parser, $conf, "Texinfo::Parser::simple_parser");
+  _setup_conf($parser, $conf);
 
   $parser->{'line_commands'} = $simple_parser_line_commands;
   $parser->{'valid_nestings'} = $simple_parser_valid_nestings;
@@ -790,8 +790,9 @@ sub _text_to_lines($)
 
 # construct a text fragments array matching a lines array, based on information
 # supplied.
-# If $fixed_line_number is set the line number is not increased, otherwise
-# it is increased, beginning at $first_line.
+# If $FIRST_LINE is undef, no line numbers are set.
+# Otherwise, if $FIXED_LINE_NUMBER is set the line number is not
+# increased, else it is increased, beginning at $FIRST_LINE.
 sub _complete_line_nr($$;$$$)
 {
   my ($lines, $first_line, $file, $macro, $fixed_line_number) = @_;
@@ -831,9 +832,11 @@ sub parse_texi_text($$;$$$$)
   }
   $lines_nr = [] if (!defined($lines_nr));
   if (!ref($lines_nr)) {
+    # $lines_nr is the first line number
     $lines_array = _complete_line_nr($text, $lines_nr, $file, 
                                      $macro, $fixed_line_number);
   } else {
+    # $lines_nr is an array of line numbers
     while (@$text) {
       my $line_nr = shift @$lines_nr;
       my $line = shift @$text;
@@ -979,6 +982,10 @@ sub parse_texi_line($$;$$$$)
   if (!ref($text)) {
     $text = _text_to_lines($text);
   }
+  if (not defined($lines_nr)) {
+    $lines_nr = 0;
+  }
+
   my $lines_array = _complete_line_nr($text, $lines_nr, $file, 
                                      $macro, $fixed_line_number);
 
diff --git a/tp/Texinfo/Report.pm b/tp/Texinfo/Report.pm
index 0697490..3fdc8a1 100644
--- a/tp/Texinfo/Report.pm
+++ b/tp/Texinfo/Report.pm
@@ -327,7 +327,7 @@ sub gdt($$;$$)
 
   Locale::Messages::nl_putenv("LANGUAGE=$locales");
 
-  my $translation_result = Locale::Messages::gettext($message);
+  my $translated_message = Locale::Messages::gettext($message);
 
   Locale::Messages::textdomain($messages_textdomain);
   if (!defined($saved_LANGUAGE)) {
@@ -341,6 +341,8 @@ sub gdt($$;$$)
     POSIX::setlocale(LC_ALL, '');
   }
 
+  my $translation_result = $translated_message;
+
   if ($type and $type eq 'translated_text') {
     if (defined($re)) {
       # next line taken from libintl perl, copyright Guido. sub __expand
@@ -385,13 +387,13 @@ sub gdt($$;$$)
   }
 
   my $tree = $parser->parse_texi_line($translation_result);
-  if ($parser->{'DEBUG'}) {
-    my ($errors, $errors_count) = $parser->errors();
-    if ($errors_count) {
-      print STDERR "GDT $errors_count errors\n";
-      foreach my $error_message (@$errors) {
-        warn $error_message->{'error_line'};
-      }
+  my ($errors, $errors_count) = $parser->errors();
+  if ($errors_count) {
+    warn "translation $errors_count error(s)\n";
+    warn "translated message: $translated_message\n";
+    warn "Error messages: \n";
+    foreach my $error_message (@$errors) {
+      warn $error_message->{'error_line'};
     }
   }
   $tree = _substitute ($tree, $context);
diff --git a/tp/t/README b/tp/t/README
index da4fc9c..129877b 100644
--- a/tp/t/README
+++ b/tp/t/README
@@ -51,6 +51,12 @@ When making changes that you expect will change the parse 
tree but not
 change any of the output, one way to check this would be to run "make
 check" and then "grep FAIL test-suite.log | grep -v 'tree$'".
 
+The tests output on STDERR are not checked, it is possible to look
+for surious output on STDERR in addition to the header and a few
+informations after "make check" with:
+
+ grep -v -e '^ok [0-9]\+' -e '^PASS:' -e '^SKIP:' -e '1\.\.[0-9]\+$' t/*.log
+
 Another way to check test results is to regenerate the reference test
 results (see below), and then run "git diff t".
 
diff --git a/tp/t/init/command_translation_modified.init 
b/tp/t/init/command_translation_modified.init
new file mode 100644
index 0000000..7e23dd8
--- /dev/null
+++ b/tp/t/init/command_translation_modified.init
@@ -0,0 +1,5 @@
+
+# modified with an existing translated string for interesting results
+# depending on the @documentlanguage
+$commands_translation{'normal'}->{'error'} = "Special Form";
+1;
diff --git a/tp/t/init/translate_txiinternalvalue_macro.init 
b/tp/t/init/translate_txiinternalvalue_macro.init
new file mode 100644
index 0000000..a0febed
--- /dev/null
+++ b/tp/t/init/translate_txiinternalvalue_macro.init
@@ -0,0 +1,27 @@
+
+texinfo_register_command_formatting('sp', \&my_sp_formatting);
+
+sub my_sp_formatting($$$$)
+{
+  my $self = shift;
+  my $cmdname = shift;
+  my $command = shift;
+  my $args = shift;
+
+  if (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::print_tree($translated_tree)."\n";
+    $result = $self->convert_tree($translated_tree);
+    return $result;
+  }
+
+  return &{$self->default_commands_conversion($cmdname)}($self,
+        $cmdname, $command, $args);
+}
+
+
+1;
diff --git a/tp/t/init_files.t b/tp/t/init_files.t
new file mode 100644
index 0000000..eb3b419
--- /dev/null
+++ b/tp/t/init_files.t
@@ -0,0 +1,43 @@
+use strict;
+
+use lib '.';
+use Texinfo::ModulePath (undef, undef, 'updirs' => 2);
+
+require 't/test_utils.pl';
+
+my @test_cases = (
+['redefined_need',
+'@need 0.1
+', {'init_files' => ['redefine_need.init']}],
+['modified_translation',
+'@error{}.
+
+@documentlanguage fr
+
+fr @error{}.
+
+@documentlanguage pt
+
+pt @error{}.
+
+', {'init_files' => ['command_translation_modified.init']}],
+['macro_defined_txiinternalvalue_in_translation',
+'@sp 1
+
+@sp 2
+
+',{'init_files' => ['translate_txiinternalvalue_macro.init'],
+}],
+);
+
+our ($arg_test_case, $arg_generate, $arg_debug);
+
+foreach my $test (@test_cases) {
+  push @{$test->[2]->{'test_formats'}}, 'html';
+}
+
+run_all ('init_files_tests', [@test_cases], $arg_test_case,
+   $arg_generate, $arg_debug);
+
+1;
+
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
new file mode 100644
index 0000000..59702a2
--- /dev/null
+++ 
b/tp/t/results/init_files_tests/macro_defined_txiinternalvalue_in_translation.pl
@@ -0,0 +1,173 @@
+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);
+
+use utf8;
+
+$result_trees{'macro_defined_txiinternalvalue_in_translation'} = {
+  'contents' => [
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => '1'
+            }
+          ],
+          'extra' => {
+            'spaces_after_argument' => '
+'
+          },
+          'parent' => {},
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'sp',
+      'extra' => {
+        'misc_args' => [
+          '1'
+        ],
+        'spaces_before_argument' => ' '
+      },
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 1,
+        'macro' => ''
+      },
+      'parent' => {}
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => '2'
+            }
+          ],
+          'extra' => {
+            'spaces_after_argument' => '
+'
+          },
+          'parent' => {},
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'sp',
+      'extra' => {
+        'misc_args' => [
+          '2'
+        ],
+        'spaces_before_argument' => ' '
+      },
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 3,
+        'macro' => ''
+      },
+      'parent' => {}
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[0]{'args'}[0];
+$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[0]{'args'}[0]{'parent'}
 = 
$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[0];
+$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[0]{'parent'}
 = $result_trees{'macro_defined_txiinternalvalue_in_translation'};
+$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[1]{'parent'}
 = $result_trees{'macro_defined_txiinternalvalue_in_translation'};
+$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[2]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[2]{'args'}[0];
+$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[2]{'args'}[0]{'parent'}
 = 
$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[2];
+$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[2]{'parent'}
 = $result_trees{'macro_defined_txiinternalvalue_in_translation'};
+$result_trees{'macro_defined_txiinternalvalue_in_translation'}{'contents'}[3]{'parent'}
 = $result_trees{'macro_defined_txiinternalvalue_in_translation'};
+
+$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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>
+<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">
+
+<style type="text/css">
+<!--
+a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
+a.summary-letter {text-decoration: none}
+blockquote.indentedblock {margin-right: 0em}
+div.display {margin-left: 3.2em}
+div.example {margin-left: 3.2em}
+kbd {font-style: oblique}
+pre.display {font-family: inherit}
+pre.format {font-family: inherit}
+pre.menu-comment {font-family: serif}
+pre.menu-preformatted {font-family: serif}
+span.nolinebreak {white-space: nowrap}
+span.roman {font-family: initial; font-weight: normal}
+span.sansserif {font-family: sans-serif; font-weight: normal}
+span:hover a.copiable-anchor {visibility: visible}
+ul.no-bullet {list-style: none}
+-->
+</style>
+
+
+</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;
diff --git a/tp/t/results/init_files_tests/modified_translation.pl 
b/tp/t/results/init_files_tests/modified_translation.pl
new file mode 100644
index 0000000..9fd9145
--- /dev/null
+++ b/tp/t/results/init_files_tests/modified_translation.pl
@@ -0,0 +1,311 @@
+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);
+
+use utf8;
+
+$result_trees{'modified_translation'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'args' => [
+            {
+              'contents' => [],
+              'parent' => {},
+              'type' => 'brace_command_arg'
+            }
+          ],
+          'cmdname' => 'error',
+          'contents' => [],
+          'line_nr' => {
+            'file_name' => '',
+            'line_nr' => 1,
+            'macro' => ''
+          },
+          'parent' => {}
+        },
+        {
+          'parent' => {},
+          'text' => '.
+'
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => 'fr'
+            }
+          ],
+          'extra' => {
+            'spaces_after_argument' => '
+'
+          },
+          'parent' => {},
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'documentlanguage',
+      'extra' => {
+        'spaces_before_argument' => ' ',
+        'text_arg' => 'fr'
+      },
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 3,
+        'macro' => ''
+      },
+      'parent' => {}
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => 'fr '
+        },
+        {
+          'args' => [
+            {
+              'contents' => [],
+              'parent' => {},
+              'type' => 'brace_command_arg'
+            }
+          ],
+          'cmdname' => 'error',
+          'contents' => [],
+          'line_nr' => {
+            'file_name' => '',
+            'line_nr' => 5,
+            'macro' => ''
+          },
+          'parent' => {}
+        },
+        {
+          'parent' => {},
+          'text' => '.
+'
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => 'pt'
+            }
+          ],
+          'extra' => {
+            'spaces_after_argument' => '
+'
+          },
+          'parent' => {},
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'documentlanguage',
+      'extra' => {
+        'spaces_before_argument' => ' ',
+        'text_arg' => 'pt'
+      },
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 7,
+        'macro' => ''
+      },
+      'parent' => {}
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'contents' => [
+        {
+          'parent' => {},
+          'text' => 'pt '
+        },
+        {
+          'args' => [
+            {
+              'contents' => [],
+              'parent' => {},
+              'type' => 'brace_command_arg'
+            }
+          ],
+          'cmdname' => 'error',
+          'contents' => [],
+          'line_nr' => {
+            'file_name' => '',
+            'line_nr' => 9,
+            'macro' => ''
+          },
+          'parent' => {}
+        },
+        {
+          'parent' => {},
+          'text' => '.
+'
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'modified_translation'}{'contents'}[0]{'contents'}[0]{'args'}[0]{'parent'}
 = $result_trees{'modified_translation'}{'contents'}[0]{'contents'}[0];
+$result_trees{'modified_translation'}{'contents'}[0]{'contents'}[0]{'parent'} 
= $result_trees{'modified_translation'}{'contents'}[0];
+$result_trees{'modified_translation'}{'contents'}[0]{'contents'}[1]{'parent'} 
= $result_trees{'modified_translation'}{'contents'}[0];
+$result_trees{'modified_translation'}{'contents'}[0]{'parent'} = 
$result_trees{'modified_translation'};
+$result_trees{'modified_translation'}{'contents'}[1]{'parent'} = 
$result_trees{'modified_translation'};
+$result_trees{'modified_translation'}{'contents'}[2]{'args'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'modified_translation'}{'contents'}[2]{'args'}[0];
+$result_trees{'modified_translation'}{'contents'}[2]{'args'}[0]{'parent'} = 
$result_trees{'modified_translation'}{'contents'}[2];
+$result_trees{'modified_translation'}{'contents'}[2]{'parent'} = 
$result_trees{'modified_translation'};
+$result_trees{'modified_translation'}{'contents'}[3]{'parent'} = 
$result_trees{'modified_translation'};
+$result_trees{'modified_translation'}{'contents'}[4]{'contents'}[0]{'parent'} 
= $result_trees{'modified_translation'}{'contents'}[4];
+$result_trees{'modified_translation'}{'contents'}[4]{'contents'}[1]{'args'}[0]{'parent'}
 = $result_trees{'modified_translation'}{'contents'}[4]{'contents'}[1];
+$result_trees{'modified_translation'}{'contents'}[4]{'contents'}[1]{'parent'} 
= $result_trees{'modified_translation'}{'contents'}[4];
+$result_trees{'modified_translation'}{'contents'}[4]{'contents'}[2]{'parent'} 
= $result_trees{'modified_translation'}{'contents'}[4];
+$result_trees{'modified_translation'}{'contents'}[4]{'parent'} = 
$result_trees{'modified_translation'};
+$result_trees{'modified_translation'}{'contents'}[5]{'parent'} = 
$result_trees{'modified_translation'};
+$result_trees{'modified_translation'}{'contents'}[6]{'args'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'modified_translation'}{'contents'}[6]{'args'}[0];
+$result_trees{'modified_translation'}{'contents'}[6]{'args'}[0]{'parent'} = 
$result_trees{'modified_translation'}{'contents'}[6];
+$result_trees{'modified_translation'}{'contents'}[6]{'parent'} = 
$result_trees{'modified_translation'};
+$result_trees{'modified_translation'}{'contents'}[7]{'parent'} = 
$result_trees{'modified_translation'};
+$result_trees{'modified_translation'}{'contents'}[8]{'contents'}[0]{'parent'} 
= $result_trees{'modified_translation'}{'contents'}[8];
+$result_trees{'modified_translation'}{'contents'}[8]{'contents'}[1]{'args'}[0]{'parent'}
 = $result_trees{'modified_translation'}{'contents'}[8]{'contents'}[1];
+$result_trees{'modified_translation'}{'contents'}[8]{'contents'}[1]{'parent'} 
= $result_trees{'modified_translation'}{'contents'}[8];
+$result_trees{'modified_translation'}{'contents'}[8]{'contents'}[2]{'parent'} 
= $result_trees{'modified_translation'}{'contents'}[8];
+$result_trees{'modified_translation'}{'contents'}[8]{'parent'} = 
$result_trees{'modified_translation'};
+$result_trees{'modified_translation'}{'contents'}[9]{'parent'} = 
$result_trees{'modified_translation'};
+
+$result_texis{'modified_translation'} = '@error{}.
+
+@documentlanguage fr
+
+fr @error{}.
+
+@documentlanguage pt
+
+pt @error{}.
+
+';
+
+
+$result_texts{'modified_translation'} = 'error-->.
+
+
+fr error-->.
+
+
+pt error-->.
+
+';
+
+$result_errors{'modified_translation'} = [];
+
+
+$result_floats{'modified_translation'} = {};
+
+
+
+$result_converted{'html'}->{'modified_translation'} = '<!DOCTYPE html PUBLIC 
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd";>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Documento Sem Nome</title>
+
+<meta name="description" content="Documento Sem Nome">
+<meta name="keywords" content="Documento Sem Nome">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<style type="text/css">
+<!--
+a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
+a.summary-letter {text-decoration: none}
+blockquote.indentedblock {margin-right: 0em}
+div.display {margin-left: 3.2em}
+div.example {margin-left: 3.2em}
+kbd {font-style: oblique}
+pre.display {font-family: inherit}
+pre.format {font-family: inherit}
+pre.menu-comment {font-family: serif}
+pre.menu-preformatted {font-family: serif}
+span.nolinebreak {white-space: nowrap}
+span.roman {font-family: initial; font-weight: normal}
+span.sansserif {font-family: sans-serif; font-weight: normal}
+span:hover a.copiable-anchor {visibility: visible}
+ul.no-bullet {list-style: none}
+-->
+</style>
+
+
+</head>
+
+<body lang="pt">
+<p>Formulário especial.
+</p>
+
+<p>fr Forme Sp@\'eciale.
+</p>
+
+<p>pt Formulário especial.
+</p>
+
+
+
+</body>
+</html>
+';
+
+$result_converted_errors{'html'}->{'modified_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;
diff --git a/tp/t/results/init_files_tests/redefined_need.pl 
b/tp/t/results/init_files_tests/redefined_need.pl
new file mode 100644
index 0000000..5ff192b
--- /dev/null
+++ b/tp/t/results/init_files_tests/redefined_need.pl
@@ -0,0 +1,125 @@
+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);
+
+use utf8;
+
+$result_trees{'redefined_need'} = {
+  'contents' => [
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => '0.1'
+            }
+          ],
+          'extra' => {
+            'spaces_after_argument' => '
+'
+          },
+          'parent' => {},
+          'type' => 'line_arg'
+        }
+      ],
+      'cmdname' => 'need',
+      'extra' => {
+        'misc_args' => [
+          '0.1'
+        ],
+        'spaces_before_argument' => ' '
+      },
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 1,
+        'macro' => ''
+      },
+      'parent' => {}
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'redefined_need'}{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'redefined_need'}{'contents'}[0]{'args'}[0];
+$result_trees{'redefined_need'}{'contents'}[0]{'args'}[0]{'parent'} = 
$result_trees{'redefined_need'}{'contents'}[0];
+$result_trees{'redefined_need'}{'contents'}[0]{'parent'} = 
$result_trees{'redefined_need'};
+
+$result_texis{'redefined_need'} = '@need 0.1
+';
+
+
+$result_texts{'redefined_need'} = '';
+
+$result_errors{'redefined_need'} = [];
+
+
+$result_floats{'redefined_need'} = {};
+
+
+
+$result_converted{'html'}->{'redefined_need'} = '<!DOCTYPE html PUBLIC 
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd";>
+<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">
+
+<style type="text/css">
+<!--
+a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
+a.summary-letter {text-decoration: none}
+blockquote.indentedblock {margin-right: 0em}
+div.display {margin-left: 3.2em}
+div.example {margin-left: 3.2em}
+kbd {font-style: oblique}
+pre.display {font-family: inherit}
+pre.format {font-family: inherit}
+pre.menu-comment {font-family: serif}
+pre.menu-preformatted {font-family: serif}
+span.nolinebreak {white-space: nowrap}
+span.roman {font-family: initial; font-weight: normal}
+span.sansserif {font-family: sans-serif; font-weight: normal}
+span:hover a.copiable-anchor {visibility: visible}
+ul.no-bullet {list-style: none}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+<!-- need: 0.1 -->
+
+
+
+</body>
+</html>
+';
+
+$result_converted_errors{'html'}->{'redefined_need'} = [
+  {
+    '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'
+  },
+  {
+    'error_line' => ':1: warning: need has the right arg: 0.1
+',
+    'file_name' => '',
+    'line_nr' => 1,
+    'macro' => '',
+    'text' => 'need has the right arg: 0.1',
+    'type' => 'warning'
+  }
+];
+
+
+1;
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index a1ed7a0..a79d013 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -732,6 +732,21 @@ sub convert_to_latex($$$$$$;$)
   return ($errors, $result);
 }
 
+{
+# eval init file in the Texinfo::Config namespace.  Needed functions are in
+# the Texinfo::Convert::HTML Texinfo::Config package namespace code.
+package Texinfo::Config;
+sub _load_init_file($) {
+  my $file = shift;
+  require Texinfo::Convert::HTML;
+  eval { require($file) ;};
+  my $e = $@;
+  if ($e ne '') {
+    warn (sprintf("error loading %s: %s\n", $file, $e));
+  }
+}
+}
+
 # Run a single test case.  Each test case is an array
 # [TEST_NAME, TEST_TEXT, PARSER_OPTIONS, CONVERTER_OPTIONS]
 sub test($$) 
@@ -803,6 +818,19 @@ sub test($$)
     delete $parser_options->{'test_formats'};
   }
 
+  my $init_file_directories = [$srcdir.'init/', $srcdir.'t/init/'];
+  if ($parser_options and $parser_options->{'init_files'}) {
+    foreach my $filename (@{$parser_options->{'init_files'}}) {
+      my $file = Texinfo::Common::locate_init_file($filename, 
$init_file_directories, 0);
+      if (defined($file)) {
+        Texinfo::Config::_load_init_file($file);
+      } else {
+        warn (sprintf("could not read init file %s", $filename));
+      }
+    }
+    delete $parser_options->{'init_files'};
+  }
+
   my $parser = Texinfo::Parser::parser({'include_directories' => [
                                           $srcdir.'t/include/'],
                                         'DEBUG' => $self->{'DEBUG'},



reply via email to

[Prev in Thread] Current Thread [Next in Thread]