texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp texi2any.pl Texinfo/Common.pm Texinf...


From: Patrice Dumas
Subject: texinfo/tp texi2any.pl Texinfo/Common.pm Texinf...
Date: Sat, 15 Sep 2012 12:19:43 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        12/09/15 12:19:42

Modified files:
        tp             : texi2any.pl 
        tp/Texinfo     : Common.pm Parser.pm 

Log message:
        Avoid duplicating information on parser configuration item names.
        Put some in Common.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.141&r2=1.142
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.155&r2=1.156
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.398&r2=1.399

Patches:
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -b -r1.141 -r1.142
--- texi2any.pl 14 Sep 2012 20:20:06 -0000      1.141
+++ texi2any.pl 15 Sep 2012 12:19:42 -0000      1.142
@@ -969,13 +969,10 @@
 
 # FIXME should this be set when the --set is set too?  The corresponding
 # code is ready above, but commented out.
-# FIXME should the list come from Texinfo::Common
+# using no warnings is wrong, but a way to avoid a spurious warning.
+no warnings 'once';
 foreach my $parser_settable_option (
-       'TOP_NODE_UP', 'MAX_MACRO_CALL_NESTING', 'INLINE_INSERTCOPYING', 
-       'SHOW_MENU', 'IGNORE_BEFORE_SETFILENAME', 'TEST', 
-       'GLOBAL_COMMANDS', 'CPP_LINE_DIRECTIVES', 
-       'INPUT_ENCODING_NAME', 'INPUT_PERL_ENCODING', 
-       'MACRO_BODY_IGNORES_LEADING_SPACE', 'USE_UP_NODE_FOR_ELEMENT_UP') {
+                keys(%Texinfo::Parser::default_customization_values)) {
   if (defined(get_conf($parser_settable_option))) {
     $parser_default_options->{$parser_settable_option} 
        = get_conf($parser_settable_option);
@@ -986,9 +983,12 @@
   }
 }
 
-# this is very wrong, but a way to avoid a spurious warning.
-no warnings 'once';
-foreach my $parser_option (@Texinfo::Common::parser_options) {
+## using no warnings is wrong, but a way to avoid a spurious warning.
+#no warnings 'once';
+# The configuration options are upper-cased when considered as 
+# customization variables, and lower-cased when passed to the Parser
+foreach my $parser_option (map {uc($_)} 
+                  (keys 
(%Texinfo::Common::default_parser_state_configuration))) {
   $parser_default_options->{lc($parser_option)} = get_conf($parser_option)
     if (defined(get_conf($parser_option)));
 }
@@ -1008,8 +1008,7 @@
 my %unclosed_files;
 my $error_count = 0;
 # main processing
-while(@input_files)
-{
+while(@input_files) {
   $file_number++;
   my $input_file_arg = shift(@input_files);
   my $input_file_name;

Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -b -r1.155 -r1.156
--- Texinfo/Common.pm   14 Sep 2012 20:20:07 -0000      1.155
+++ Texinfo/Common.pm   15 Sep 2012 12:19:42 -0000      1.156
@@ -86,6 +86,48 @@
   $null_device_file{'NUL'} = 1;
 }
 
+# these are the default values for the parser state that may be 
+# initialized to values given by the user.
+# They are defined here, because they are used below and we 
+# don't want Texinfo::Common to use Texinfo::Parser.
+our %default_parser_state_configuration = (
+  # this is the initial context.  It is put at the bottom of the 
+  # 'context_stack'.  It is not clear if this is really useful to be
+  # able to customize that value.
+  'context' => '_root',
+  'expanded_formats' => [],
+  'gettext' => sub {return $_[0];},
+  'include_directories' => [ '.' ],
+  # these are the user-added indices.  May be an array reference on names
+  # or an hash reference in the same format than %index_names below
+  'indices' => [],
+  # the following are dynamically modified during the document parsing.
+  'aliases' => {},            # key is a command name value is the alias
+  'clickstyle' => 'arrow',
+  'documentlanguage' => undef,
+                              # Current documentlanguage set by 
+                              # @documentlanguage
+  'explained_commands' => {}, # the key is a command name, either acronym
+                              # or abbr, the value is a hash.  The key hash 
+                              # is a normalized first argument of the 
+                              # corresponding command, the value is the 
+                              # contents array of the previous command with
+                              # this first arg and a second arg.
+  'kbdinputstyle' => 'distinct',
+  'labels'          => {},    # keys are normalized label names, as described
+                              # in the `HTML Xref' node.  Value should be
+                              # a node/anchor or float in the tree.
+  'macros' => {},             # the key is the user-defined macro name.  The 
+                              # value is the reference on a macro element 
+                              # as obtained by parsing the @macro
+  'merged_indices' => {},     # the key is merged in the value
+  'novalidate' => 0,          # same as setting @novalidate.
+  'sections_level' => 0,      # modified by raise/lowersections
+  'values' => {'txicommandconditionals' => 1},
+                              # the key is the name, the value the @set name 
+                              # argument.  A Texinfo tree may also be used.
+);
+
 # command-line options
 #my @command_line_settable_at_commands = ('footnotestyle', 'novalidate',
 #  'documentlanguage', 'paragraphindent');
@@ -114,7 +156,7 @@
         'oddfootingmarks','oddheadingmarks',
         'pagesizes', 'setchapternewpage',
         'setcontentsaftertitlepage',
-        'setfilename', # FIXME this does not work
+        'setfilename',
         'setshortcontentsaftertitlepage',
         );
 
@@ -131,10 +173,7 @@
 
 # documented in the Texinfo::Parser pod section
 # all are lower cased in texi2any.pl
-our @parser_options = ('EXPANDED_FORMATS', 'GETTEXT', 'INCLUDE_DIRECTORIES',
-  'ALIASES', 'CLICKSTYLE', 'DOCUMENTLANGUAGE', 'EXPLAINED_COMMANDS',
-  'INDICES', 'KBDINPUTSTYLE', 'LABELS',
-  'MACROS', 'NOVALIDATE', 'SECTIONS_LEVEL', 'VALUES');
+my @parser_options = map {uc($_)} (keys(%default_parser_state_configuration));
 
 my @obsolete_variables = ('TOP_HEADING_AT_BEGINNING', 'USE_SECTIONS',
   'IDX_SUMMARY', 'I18N_PERL_HASH', 'USE_UNICODE', 'USE_NLS',

Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.398
retrieving revision 1.399
diff -u -b -r1.398 -r1.399
--- Texinfo/Parser.pm   14 Sep 2012 20:20:07 -0000      1.398
+++ Texinfo/Parser.pm   15 Sep 2012 12:19:42 -0000      1.399
@@ -100,79 +100,36 @@
   return &{$self->{'gettext'}}(@_);
 }
 
-# these are the default values for the parser state that may be 
-# initialized to values given by the user.
-our %default_configuration = (
+# Customization variables obeyed by the Parser, and the default values.
+our %default_customization_values = (
   'TEST' => 0,
   'DEBUG' => 0,     # if >= 10, tree is printed in texi2any.pl after parsing.
                     # If >= 100 tree is printed every line.
   'SHOW_MENU' => 1,             # if false no menu error related.
-  'gettext' => sub {return $_[0];},
-  'expanded_formats' => [],
-  'include_directories' => [ '.' ],
   'INLINE_INSERTCOPYING' => 0,
   'IGNORE_BEFORE_SETFILENAME' => 1,
   'MACRO_BODY_IGNORES_LEADING_SPACE' => 0,
-  # this is the initial context.  It is put at the bottom of the 
-  # 'context_stack'
-  'context' => '_root',
-  # these are the user-added indices.  May be an array reference on names
-  # or an hash reference in the same format than %index_names below
-  'indices' => [],
-  # the following are dynamically modified during the document parsing.
-  'aliases' => {},            # key is a command name value is the alias
-  'values' => {'txicommandconditionals' => 1}, 
-                              # the key is the name, the value the @set name 
-                              # argument.  A Texinfo tree may also be used.
-  'macros' => {},             # the key is the user-defined macro name.  The 
-                              # value is the reference on a macro element 
-                              # as obtained by parsing the @macro
-  'explained_commands' => {}, # the key is a command name, either acronym
-                              # or abbr, the value is a hash.  The key hash 
-                              # is a normalized first argument of the 
-                              # corresponding command, the value is the 
-                              # contents array of the previous command with
-                              # this first arg and a second arg.
-  'clickstyle' => 'arrow',
-  'kbdinputstyle' => 'distinct',
-  'sections_level' => 0,      # modified by raise/lowersections
-  'merged_indices' => {},     # the key is merged in the value
-  'labels'          => {},    # keys are normalized label names, as described
-                              # in the `HTML Xref' node.  Value should be
-                              # a node/anchor or float in the tree.
-  'novalidate' => 0,          # same as setting @novalidate.
   'INPUT_PERL_ENCODING' => undef, # input perl encoding name, set from 
                               # @documentencoding in the default case
   'INPUT_ENCODING_NAME' => undef, # encoding name normalized as preferred
                               # IANA, set from @documentencoding in the default
                               # case
-  'documentlanguage' => undef, 
-                              # Current documentlanguage set by 
-                              # @documentlanguage
+  'CPP_LINE_DIRECTIVES' => 1, # handle cpp like synchronization lines
+  'MAX_MACRO_CALL_NESTING' => 100000, # max number of nested macro calls
+  'GLOBAL_COMMANDS' => [],    # list of commands registered 
   # This is not used directly, but passed to Convert::Text through 
   # Texinfo::Common::_convert_text_options
   'ENABLE_ENCODING' => 1,     # output accented and special characters
                               # based on @documentencoding
-  'CPP_LINE_DIRECTIVES' => 1, # handle cpp like synchronization lines
-  'MAX_MACRO_CALL_NESTING' => 100000, # max number of nested macro calls
+  # following are used in Texinfo::Structuring
   'TOP_NODE_UP' => '(dir)',   # up node of Top node
-  'SIMPLE_MENU' => 0,         # currently not used in the parser for now, 
-                              # but relevant for structuring
-  'GLOBAL_COMMANDS' => [],    # list of commands registered 
+  'SIMPLE_MENU' => 0,         # not used in the parser but in structuring
+  'USE_UP_NODE_FOR_ELEMENT_UP' => 0, # Use node up for Up if there is no 
+                                     # section up.
 );
 
-# content is not copied but reference is copied when duplicating a parser.
-my %tree_informations;
-foreach my $tree_information ('values', 'macros', 'explained_commands', 
'labels') {
-  $tree_informations{$tree_information} = 1;
-}
-
-# The commands in initialization_overrides are not set in the document if
-# set at the parser initialization.
-my %initialization_overrides = (
-  'INPUT_ENCODING_NAME' => 1,
-  'documentlanguage' => 1,
-);
+my %parser_default_configuration = 
(%Texinfo::Common::default_parser_state_configuration,
+                                    %default_customization_values);
 
 # the other possible keys for the parser state are:
 #
@@ -230,7 +187,7 @@
 #
 # A text fragment information is a 2 element array reference, the first is the
 # text fragment, the second is the line information.
-#
+
 # The input structure is an array, the first is the most recently included
 # file.  The last element may be a file if the parsing is done on a file, 
 # with parse_texi_file, or simply pending text, if called as parse_texi_text.
@@ -241,6 +198,18 @@
 # line_nr    current line number in the file
 # fh         filehandle for the file
 
+# content is not copied but reference is copied when duplicating a parser.
+my %tree_informations;
+foreach my $tree_information ('values', 'macros', 'explained_commands', 
'labels') {
+  $tree_informations{$tree_information} = 1;
+}
+
+# The commands in initialization_overrides are not set in the document if
+# set at the parser initialization.
+my %initialization_overrides = (
+  'INPUT_ENCODING_NAME' => 1,
+  'documentlanguage' => 1,
+);
 
 my %no_brace_commands         = %Texinfo::Common::no_brace_commands;
 my %misc_commands             = %Texinfo::Common::misc_commands;
@@ -564,7 +533,7 @@
 
 # initialization entry point.  Set up a parser.
 # The last argument, optional, is a hash provided by the user to change
-# the default values for what is present in %default_configuration.
+# the default values for what is present in %parser_default_configuration.
 # The exact arguments of the function depend on how it was called,
 # in a object oriented way or not.
 sub parser(;$$)
@@ -572,9 +541,9 @@
   my $class = shift;
   my $conf;
 
-  my $parser = _deep_copy(\%default_configuration);
+  my $parser = _deep_copy(\%parser_default_configuration);
   # _deep_copy doesn't handle subs
-  $parser->{'gettext'} = $default_configuration{'gettext'};
+  $parser->{'gettext'} = $parser_default_configuration{'gettext'};
 
   # called not object-oriented
   if (ref($class) eq 'HASH') {
@@ -586,7 +555,7 @@
     # called on an existing parser, interpreted as a duplication
     my $old_parser = $class;
     $class = ref($class);
-    foreach my $key (keys(%default_configuration)) {
+    foreach my $key (keys(%parser_default_configuration)) {
       if ($tree_informations{$key}) {
         if (defined($old_parser->{$key})) {
           foreach my $info_key (keys(%{$old_parser->{$key}})) {
@@ -613,7 +582,7 @@
 
   if (defined($conf)) {
     foreach my $key (keys(%$conf)) {
-      if (exists($default_configuration{$key})) {
+      if (exists($parser_default_configuration{$key})) {
         if (ref($conf->{$key}) ne 'CODE' and $key ne 'values') {
           $parser->{$key} = _deep_copy($conf->{$key});
         } else {
@@ -663,6 +632,8 @@
   $parser->{'context_stack'} = [ $parser->{'context'} ];
   $parser->{'regions_stack'} = [];
   $parser->{'macro_stack'} = [];
+  $parser->{'conditionals_stack'} = [];
+
   # turn the array to a hash for speed.  Not sure it really matters for such
   # a small array.
   foreach my $expanded_format(@{$parser->{'expanded_formats'}}) {
@@ -3097,18 +3068,21 @@
                  $self->__("Encoding `%s' is not a canonical texinfo 
encoding"),
                                $text)
             if (!$texinfo_encoding or $texinfo_encoding ne lc($text));
+          if ($input_encoding) {
+            $current->{'extra'}->{'input_encoding_name'} = $input_encoding;
+          }
           if (!$perl_encoding) {
             $self->_command_warn($current, $line_nr,
                  $self->__("unrecognized encoding name `%s'"), $text);
           } else {
+            $current->{'extra'}->{'input_perl_encoding'} = $perl_encoding;
+
             if ($input_encoding) {
-              $current->{'extra'}->{'input_encoding_name'} = $input_encoding;
               if (!$self->{'set'}->{'INPUT_ENCODING_NAME'}) {
                 $self->{'INPUT_ENCODING_NAME'} = $input_encoding;
                 $self->{'info'}->{'input_encoding_name'} = $input_encoding;
               }
             }
-            $current->{'extra'}->{'input_perl_encoding'} = $perl_encoding;
 
             if (!$self->{'set'}->{'INPUT_PERL_ENCODING'}) {
               $self->{'INPUT_PERL_ENCODING'} = $perl_encoding;
@@ -3565,8 +3539,6 @@
   $root = { 'contents' => [], 'type' => 'text_root' } if (!defined($root));
   my $current = $root;
 
-  $self->{'conditionals_stack'} = [];
-
   my $line_nr;
   
  NEXT_LINE:
@@ -5871,6 +5843,11 @@
    'extra' => {'arg_line' => " mymacro{arg}\n",
                'macrobody' => "coucou \arg\ after arg\n"}}
 
+= item merged_indices
+
+The associated hash reference holds merged indices information, each key 
+is merged in the value.  Same as setting C<@synindex> of C<syncodeindex>.
+
 =item novalidate
 
 If set, it is as if C<@novalidate> was set in the document.



reply via email to

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