texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp/Texinfo Parser.pm Report.pm Convert/...


From: Patrice Dumas
Subject: texinfo/tp/Texinfo Parser.pm Report.pm Convert/...
Date: Mon, 19 Sep 2011 17:53:45 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/09/19 17:53:45

Modified files:
        tp/Texinfo     : Parser.pm Report.pm 
        tp/Texinfo/Convert: DocBook.pm HTML.pm Plaintext.pm 

Log message:
        Put gdt() in Texinfo::Report instead of Texinfo::Parser.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.295&r2=1.296
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Report.pm?cvsroot=texinfo&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/DocBook.pm?cvsroot=texinfo&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.151&r2=1.152
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.159&r2=1.160

Patches:
Index: Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.295
retrieving revision 1.296
diff -u -b -r1.295 -r1.296
--- Parser.pm   18 Sep 2011 23:22:26 -0000      1.295
+++ Parser.pm   19 Sep 2011 17:53:44 -0000      1.296
@@ -45,6 +45,7 @@
 
 # commands definitions
 use Texinfo::Common;
+# Error reporting and counting, and translation of strings.
 use Texinfo::Report;
 
 # to expand file names in @include
@@ -77,7 +78,6 @@
   labels_information
   global_commands_information
   global_informations
-  gdt
 ) ] );
 
 @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
@@ -87,152 +87,6 @@
 
 $VERSION = '0.01';
 
-# i18n
-
-my $DEFAULT_LANGUAGE = 'en';
-
-# we want a reliable way to switch locale, so we don't use the system
-# gettext.
-Locale::Messages->select_package ('gettext_pp');
-
-#my $strings_textdomain = 'texinfo_document';
-# FIXME use texinfo_document
-my $strings_textdomain = 'texi2html_document';
-my $messages_textdomain = 'texinfo';
-
-# libintl converts between encodings but doesn't decode them into the
-# perl internal format.  This is only caled if the encoding is a proper
-# perl encoding.
-sub encode_i18n_string($$)
-{
-  my $string = shift;
-  my $encoding = shift;
-  return Encode::decode($encoding, $string);
-}
-
-# handle translations of in-document strings.
-sub gdt($$;$$)
-{
-  my $self = shift;
-  my $message = shift;
-  my $context = shift;
-  my $conf = shift;
-
-  my $encoding = $self->{'encoding_name'};
-
-  my $re = join '|', map { quotemeta $_ } keys %$context
-      if (defined($context) and ref($context));
-
-  my $saved_env_LC_ALL = $ENV{'LC_ALL'};
-  my $saved_LANGUAGE = $ENV{'LANGUAGE'};
-#  my $saved_LANG = $ENV{'LANG'};
-#  my $saved_LC_ALL = POSIX::setlocale (LC_ALL);
-#  my $saved_LC_CTYPE = POSIX::setlocale (LC_CTYPE);
-#  my $saved_LC_MESSAGES = POSIX::setlocale (LC_MESSAGES);
-
-  Locale::Messages::textdomain($strings_textdomain);
-  Locale::Messages::bind_textdomain_codeset($strings_textdomain, $encoding)
-    if ($encoding and $encoding ne 'us-ascii');
-  if (!($encoding and $encoding eq 'us-ascii') and $self->{'perl_encoding'}) {
-    Locale::Messages::bind_textdomain_filter($strings_textdomain,
-      \&encode_i18n_string, $self->{'perl_encoding'});
-  }
-
-  # FIXME do that in the converters when @documentlanguage is found.
-  my $lang = $self->get_conf('documentlanguage');
-  $lang = $DEFAULT_LANGUAGE if (!defined($lang));
-  my @langs = ($lang);
-  if ($lang =~ /^([a-z]+)_([A-Z]+)/) {
-    my $main_lang = $1;
-    my $region_code = $2;
-    push @langs, $main_lang;
-  }
-
-  my $locales = '';
-
-  foreach my $language (@langs) {
-    if ($encoding) {
-      $locales .= "$language.$encoding:";
-    } else {
-      $locales .= "$language:";
-    }
-    # always try us-ascii, the charset should always be a subset of
-    # all charset, and should resort to @-commands if needed for non
-    # ascii characters
-    if (!$encoding or ($encoding and $encoding ne 'us-ascii')) {
-      $locales .= "$language.us-ascii:";
-    }
-  }
-  $locales =~ s/:$//;
-  #print STDERR "$locales $message\n";
-  # END FIXME
-
-  Locale::Messages::nl_putenv("LANGUAGE=$locales");
-
-  my $result;
-  if (!defined($context) or ref($context)) {
-    $result = Locale::Messages::gettext($message);
-  } else {
-    $result = Locale::Messages::pgettext($context, $message);
-  }
-
-  Locale::Messages::textdomain($messages_textdomain);
-  # old perl complains 'Use of uninitialized value in scalar assignment'
-  if (!defined($saved_LANGUAGE)) {
-    delete ($ENV{'LANGUAGE'});
-  } else {
-    $ENV{'LANGUAGE'} = $saved_LANGUAGE;
-  }
-  if (!defined($saved_env_LC_ALL)) {
-    delete ($ENV{'LC_ALL'});
-  } else {
-    $ENV{'LC_ALL'} = $saved_env_LC_ALL;
-  }
-#  my $new_LC_ALL = POSIX::setlocale (LC_ALL);
-#  my $new_LC_CTYPE = POSIX::setlocale (LC_CTYPE);
-#  my $new_LC_MESSAGES = POSIX::setlocale (LC_MESSAGES);
-#  my $new_env_LC_ALL = 'UNDEF';
-#  $new_env_LC_ALL = $ENV{'LC_ALL'} if defined($ENV{'LC_ALL'});
-#  my $saved_str_env_LC_ALL = $saved_env_LC_ALL;
-#  $saved_str_env_LC_ALL = 'UNDEF' if (!defined($saved_str_env_LC_ALL));
-
-#  print STDERR "  LC_ALL $saved_LC_ALL $new_LC_ALL ENV: $saved_str_env_LC_ALL 
$new_env_LC_ALL\n";
-#  print STDERR "  LC_CTYPE $saved_LC_CTYPE $new_LC_CTYPE\n";
-#  print STDERR "  LC_MESSAGES $saved_LC_MESSAGES $new_LC_MESSAGES\n";
-#  my $new_LANG = 'UNDEF';
-#  $new_LANG = $ENV{'LANG'} if defined($ENV{'LANG'});
-#  my $saved_str_LANG = $saved_LANG;
-#  $saved_str_LANG = 'UNDEF' if (!defined($saved_str_LANG));
-#  print STDERR "  LANG $saved_str_LANG $new_LANG\n";
-
-  my $parser_conf;
-  # we change the substituted brace-enclosed strings to values, that
-  # way they are substituted, including when they are Texinfo trees.
-  if (defined($re)) {
-    # next line taken from libintl perl, copyright Guido. sub __expand
-    $result =~ s/\{($re)\}/address@hidden/g;
-    foreach my $substitution(keys %$context) {
-      #print STDERR "$result $substitution $context->{$substitution}\n";
-      $parser_conf->{'values'}->{$substitution} = $context->{$substitution};
-    }
-  }
-  # FIXME reuse a parser?
-  if ($self->get_conf('DEBUG')) {
-    $parser_conf->{'DEBUG'} = 1;
-    print STDERR "GDT $result\n";
-  }
-  my $parser = parser($parser_conf);
-
-  # FIXME it doesn't seems to be used anywhere.
-  if ($conf->{'paragraph'}) {
-    $result = $parser->parse_texi_text($result);
-  } else {
-    $result = $parser->parse_texi_line($result);
-  }
-  return $result;
-}
-
-
 sub N__($)
 {
   return $_[0];

Index: Report.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Report.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- Report.pm   20 Aug 2011 14:38:46 -0000      1.10
+++ Report.pm   19 Sep 2011 17:53:45 -0000      1.11
@@ -1,4 +1,4 @@
-# Report.pm: prepare error messages.
+# Report.pm: prepare error messages and translate strings.
 #
 # Copyright 2010, 2011 Free Software Foundation, Inc.
 # 
@@ -30,6 +30,7 @@
 # will save memory.
 %EXPORT_TAGS = ( 'all' => [ qw(
   errors
+  gdt
 ) ] );
 
 @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
@@ -45,6 +46,9 @@
 use 5.00405;
 use strict;
 
+# to be able to load a parser if none was given to gdt.
+use Texinfo::Parser;
+
 # return the errors and warnings
 sub errors ($)
 {
@@ -163,5 +167,150 @@
     { 'type' => 'warning', 'text' => $warn_line, 'error_line' => $warn_line};
 }
 
+# i18n
+
+my $DEFAULT_LANGUAGE = 'en';
+
+# we want a reliable way to switch locale, so we don't use the system
+# gettext.
+Locale::Messages->select_package ('gettext_pp');
+
+#my $strings_textdomain = 'texinfo_document';
+# FIXME use texinfo_document
+my $strings_textdomain = 'texi2html_document';
+my $messages_textdomain = 'texinfo';
+
+# libintl converts between encodings but doesn't decode them into the
+# perl internal format.  This is only caled if the encoding is a proper
+# perl encoding.
+sub encode_i18n_string($$)
+{
+  my $string = shift;
+  my $encoding = shift;
+  return Encode::decode($encoding, $string);
+}
+
+# handle translations of in-document strings.
+sub gdt($$;$$)
+{
+  my $self = shift;
+  my $message = shift;
+  my $context = shift;
+  my $conf = shift;
+
+  my $encoding = $self->{'encoding_name'};
+
+  my $re = join '|', map { quotemeta $_ } keys %$context
+      if (defined($context) and ref($context));
+
+  my $saved_env_LC_ALL = $ENV{'LC_ALL'};
+  my $saved_LANGUAGE = $ENV{'LANGUAGE'};
+#  my $saved_LANG = $ENV{'LANG'};
+#  my $saved_LC_ALL = POSIX::setlocale (LC_ALL);
+#  my $saved_LC_CTYPE = POSIX::setlocale (LC_CTYPE);
+#  my $saved_LC_MESSAGES = POSIX::setlocale (LC_MESSAGES);
+
+  Locale::Messages::textdomain($strings_textdomain);
+  Locale::Messages::bind_textdomain_codeset($strings_textdomain, $encoding)
+    if ($encoding and $encoding ne 'us-ascii');
+  if (!($encoding and $encoding eq 'us-ascii') and $self->{'perl_encoding'}) {
+    Locale::Messages::bind_textdomain_filter($strings_textdomain,
+      \&encode_i18n_string, $self->{'perl_encoding'});
+  }
+
+  # FIXME do that in the converters when @documentlanguage is found.
+  my $lang = $self->get_conf('documentlanguage');
+  $lang = $DEFAULT_LANGUAGE if (!defined($lang));
+  my @langs = ($lang);
+  if ($lang =~ /^([a-z]+)_([A-Z]+)/) {
+    my $main_lang = $1;
+    my $region_code = $2;
+    push @langs, $main_lang;
+  }
+
+  my $locales = '';
+
+  foreach my $language (@langs) {
+    if ($encoding) {
+      $locales .= "$language.$encoding:";
+    } else {
+      $locales .= "$language:";
+    }
+    # always try us-ascii, the charset should always be a subset of
+    # all charset, and should resort to @-commands if needed for non
+    # ascii characters
+    if (!$encoding or ($encoding and $encoding ne 'us-ascii')) {
+      $locales .= "$language.us-ascii:";
+    }
+  }
+  $locales =~ s/:$//;
+  #print STDERR "$locales $message\n";
+  # END FIXME
+
+  Locale::Messages::nl_putenv("LANGUAGE=$locales");
+
+  my $result;
+  if (!defined($context) or ref($context)) {
+    $result = Locale::Messages::gettext($message);
+  } else {
+    $result = Locale::Messages::pgettext($context, $message);
+  }
+
+  Locale::Messages::textdomain($messages_textdomain);
+  # old perl complains 'Use of uninitialized value in scalar assignment'
+  if (!defined($saved_LANGUAGE)) {
+    delete ($ENV{'LANGUAGE'});
+  } else {
+    $ENV{'LANGUAGE'} = $saved_LANGUAGE;
+  }
+  if (!defined($saved_env_LC_ALL)) {
+    delete ($ENV{'LC_ALL'});
+  } else {
+    $ENV{'LC_ALL'} = $saved_env_LC_ALL;
+  }
+#  my $new_LC_ALL = POSIX::setlocale (LC_ALL);
+#  my $new_LC_CTYPE = POSIX::setlocale (LC_CTYPE);
+#  my $new_LC_MESSAGES = POSIX::setlocale (LC_MESSAGES);
+#  my $new_env_LC_ALL = 'UNDEF';
+#  $new_env_LC_ALL = $ENV{'LC_ALL'} if defined($ENV{'LC_ALL'});
+#  my $saved_str_env_LC_ALL = $saved_env_LC_ALL;
+#  $saved_str_env_LC_ALL = 'UNDEF' if (!defined($saved_str_env_LC_ALL));
+
+#  print STDERR "  LC_ALL $saved_LC_ALL $new_LC_ALL ENV: $saved_str_env_LC_ALL 
$new_env_LC_ALL\n";
+#  print STDERR "  LC_CTYPE $saved_LC_CTYPE $new_LC_CTYPE\n";
+#  print STDERR "  LC_MESSAGES $saved_LC_MESSAGES $new_LC_MESSAGES\n";
+#  my $new_LANG = 'UNDEF';
+#  $new_LANG = $ENV{'LANG'} if defined($ENV{'LANG'});
+#  my $saved_str_LANG = $saved_LANG;
+#  $saved_str_LANG = 'UNDEF' if (!defined($saved_str_LANG));
+#  print STDERR "  LANG $saved_str_LANG $new_LANG\n";
+
+  my $parser_conf;
+  # we change the substituted brace-enclosed strings to values, that
+  # way they are substituted, including when they are Texinfo trees.
+  if (defined($re)) {
+    # next line taken from libintl perl, copyright Guido. sub __expand
+    $result =~ s/\{($re)\}/address@hidden/g;
+    foreach my $substitution(keys %$context) {
+      #print STDERR "$result $substitution $context->{$substitution}\n";
+      $parser_conf->{'values'}->{$substitution} = $context->{$substitution};
+    }
+  }
+  # FIXME reuse a parser?
+  if ($self->get_conf('DEBUG')) {
+    $parser_conf->{'DEBUG'} = 1;
+    print STDERR "GDT $result\n";
+  }
+  my $parser = Texinfo::Parser::parser($parser_conf);
+
+  # FIXME it doesn't seems to be used anywhere.
+  if ($conf->{'paragraph'}) {
+    $result = $parser->parse_texi_text($result);
+  } else {
+    $result = $parser->parse_texi_line($result);
+  }
+  return $result;
+}
+
 
 1;

Index: Convert/DocBook.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/DocBook.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- Convert/DocBook.pm  18 Sep 2011 23:22:26 -0000      1.11
+++ Convert/DocBook.pm  19 Sep 2011 17:53:45 -0000      1.12
@@ -29,7 +29,6 @@
 use Texinfo::Convert::Texinfo;
 use Data::Dumper;
 use Carp qw(cluck);
-use Texinfo::Parser qw(gdt);
 
 require Exporter;
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

Index: Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -b -r1.151 -r1.152
--- Convert/HTML.pm     17 Sep 2011 21:23:59 -0000      1.151
+++ Convert/HTML.pm     19 Sep 2011 17:53:45 -0000      1.152
@@ -24,11 +24,9 @@
 
 use Texinfo::Convert::Converter;
 use Texinfo::Common;
-use Texinfo::Report;
 use Texinfo::Convert::Texinfo;
 use Texinfo::Convert::Text;
 use Texinfo::Convert::Unicode;
-use Texinfo::Parser qw(gdt);
 
 use Carp qw(cluck);
 

Index: Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -b -r1.159 -r1.160
--- Convert/Plaintext.pm        18 Sep 2011 23:22:27 -0000      1.159
+++ Convert/Plaintext.pm        19 Sep 2011 17:53:45 -0000      1.160
@@ -29,7 +29,6 @@
 use Texinfo::Convert::Paragraph;
 use Texinfo::Convert::Line;
 use Texinfo::Convert::UnFilled;
-use Texinfo::Parser qw(gdt);
 
 use Carp qw(cluck);
 



reply via email to

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