[Top][All Lists]
[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: |
Tue, 10 Jul 2012 22:32:32 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 12/07/10 22:32:32
Modified files:
tp : texi2any.pl
tp/Texinfo : Common.pm Parser.pm
tp/t : 55conditionals.t
Added files:
tp/t/results/conditionals: command_conditionals.pl
Log message:
Define txicommandconditionals value.
Handle @ifcommanddefined and @ifcommandnotdefined.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.129&r2=1.130
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.142&r2=1.143
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.380&r2=1.381
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/55conditionals.t?cvsroot=texinfo&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/conditionals/command_conditionals.pl?cvsroot=texinfo&rev=1.1
Patches:
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -b -r1.129 -r1.130
--- texi2any.pl 26 Apr 2012 17:36:25 -0000 1.129
+++ texi2any.pl 10 Jul 2012 22:32:31 -0000 1.130
@@ -435,7 +435,8 @@
my @prepend_dirs = ();
# options for all the files
-my $parser_default_options = {'expanded_formats' => [], 'values' => {},
+my $parser_default_options = {'expanded_formats' => [],
+ 'values' => {'txicommandconditionals' => 1},
'gettext' => \&__};
Texinfo::Config::_load_config($converter_default_options, $cmdline_options);
Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -b -r1.142 -r1.143
--- Texinfo/Common.pm 26 May 2012 09:47:36 -0000 1.142
+++ Texinfo/Common.pm 10 Jul 2012 22:32:31 -0000 1.143
@@ -671,6 +671,9 @@
$block_commands{'ifset'} = 'conditional';
$block_commands{'ifclear'} = 'conditional';
+$block_commands{'ifcommanddefined'} = 'conditional';
+$block_commands{'ifcommandnotdefined'} = 'conditional';
+
# 'macro' ?
foreach my $block_command_one_arg('table', 'ftable', 'vtable',
'itemize', 'enumerate', 'quotation', 'smallquotation') {
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.380
retrieving revision 1.381
diff -u -b -r1.380 -r1.381
--- Texinfo/Parser.pm 8 Jul 2012 22:38:14 -0000 1.380
+++ Texinfo/Parser.pm 10 Jul 2012 22:32:31 -0000 1.381
@@ -117,7 +117,8 @@
'indices' => [],
# the following are dynamically modified during the document parsing.
'aliases' => {}, # key is a command name value is the alias
- 'values' => {}, # the key is the name, the value the @set name
+ '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
@@ -3560,7 +3561,9 @@
last;
# ifclear/ifset may be nested
} elsif (($current->{'cmdname'} eq 'ifclear'
- or $current->{'cmdname'} eq 'ifset')
+ or $current->{'cmdname'} eq 'ifset'
+ or $current->{'cmdname'} eq 'ifcommanddefined'
+ or $current->{'cmdname'} eq 'ifcommandnotdefined')
and $line =~ /address@hidden>{'cmdname'}/) {
$line =~ s/\s*\@($current->{'cmdname'})//;
push @{$current->{'contents'}}, { 'cmdname' => $1,
@@ -4382,6 +4385,22 @@
$self->line_error (sprintf($self->__("%c%s requires a name"),
ord('@'), $command), $line_nr);
}
+ } elsif ($command eq 'ifcommanddefined'
+ or $command eq 'ifcommandnotdefined') {
+ # REMACRO
+ if ($line =~ /^\s+([[:alnum:]][[:alnum:]\-]*)/) {
+ my $name = $1;
+ if ((exists($Texinfo::Common::all_commands{$name})
+ and $command eq 'ifcommanddefined')
+ or (!exists($Texinfo::Common::all_commands{$name})
+ and $command eq 'ifcommandnotdefined')) {
+ $ifvalue_true = 1;
+ }
+ print STDERR "CONDITIONAL address@hidden $name:
$ifvalue_true\n" if ($self->{'DEBUG'});
+ } else {
+ $self->line_error (sprintf($self->__("%c%s requires a name"),
+ ord('@'), $command), $line_nr);
+ }
} elsif ($command =~ /^ifnot(.*)/) {
$ifvalue_true = 1 if !($self->{'expanded_formats_hash'}->{$1}
# exception as explained in the texinfo manual
Index: t/55conditionals.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/55conditionals.t,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- t/55conditionals.t 30 Dec 2011 18:49:43 -0000 1.14
+++ t/55conditionals.t 10 Jul 2012 22:32:31 -0000 1.15
@@ -347,7 +347,33 @@
'@ifhtml
inhtml
@end ifhtml
-']
+'],
+['command_conditionals',
+'@ifset txicommandconditionals
+Good, the txicommandconditionals variable was set.
address@hidden ifset
+
address@hidden nodexyz
+Bad, @@nodexyz is defined.
address@hidden ifcommanddefined
address@hidden nodexyz
+Good, @@nodexyz is not defined.
address@hidden ifcommandnotdefined
+
address@hidden node
+Good, @@node is defined.
address@hidden ifcommanddefined
address@hidden node
+Bad, @@node is not defined.
address@hidden ifcommandnotdefined
+
address@hidden mathcode
+Unfortunately, @@mathcode is defined.
address@hidden ifcommanddefined
address@hidden mathcode
+Happily, @@mathcode is not defined.
address@hidden ifcommandnotdefined
+'],
);
our ($arg_test_case, $arg_generate, $arg_debug);
Index: t/results/conditionals/command_conditionals.pl
===================================================================
RCS file: t/results/conditionals/command_conditionals.pl
diff -N t/results/conditionals/command_conditionals.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/results/conditionals/command_conditionals.pl 10 Jul 2012 22:32:32
-0000 1.1
@@ -0,0 +1,139 @@
+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{'command_conditionals'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => 'Good, the txicommandconditionals variable was set.
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => 'Good, '
+ },
+ {
+ 'cmdname' => '@',
+ 'parent' => {}
+ },
+ {
+ 'parent' => {},
+ 'text' => 'nodexyz is not defined.
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => 'Good, '
+ },
+ {
+ 'cmdname' => '@',
+ 'parent' => {}
+ },
+ {
+ 'parent' => {},
+ 'text' => 'node is defined.
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => 'Happily, '
+ },
+ {
+ 'cmdname' => '@',
+ 'parent' => {}
+ },
+ {
+ 'parent' => {},
+ 'text' => 'mathcode is not defined.
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ }
+ ],
+ 'type' => 'text_root'
+};
+$result_trees{'command_conditionals'}{'contents'}[0]{'contents'}[0]{'parent'}
= $result_trees{'command_conditionals'}{'contents'}[0];
+$result_trees{'command_conditionals'}{'contents'}[0]{'parent'} =
$result_trees{'command_conditionals'};
+$result_trees{'command_conditionals'}{'contents'}[1]{'parent'} =
$result_trees{'command_conditionals'};
+$result_trees{'command_conditionals'}{'contents'}[2]{'contents'}[0]{'parent'}
= $result_trees{'command_conditionals'}{'contents'}[2];
+$result_trees{'command_conditionals'}{'contents'}[2]{'contents'}[1]{'parent'}
= $result_trees{'command_conditionals'}{'contents'}[2];
+$result_trees{'command_conditionals'}{'contents'}[2]{'contents'}[2]{'parent'}
= $result_trees{'command_conditionals'}{'contents'}[2];
+$result_trees{'command_conditionals'}{'contents'}[2]{'parent'} =
$result_trees{'command_conditionals'};
+$result_trees{'command_conditionals'}{'contents'}[3]{'parent'} =
$result_trees{'command_conditionals'};
+$result_trees{'command_conditionals'}{'contents'}[4]{'contents'}[0]{'parent'}
= $result_trees{'command_conditionals'}{'contents'}[4];
+$result_trees{'command_conditionals'}{'contents'}[4]{'contents'}[1]{'parent'}
= $result_trees{'command_conditionals'}{'contents'}[4];
+$result_trees{'command_conditionals'}{'contents'}[4]{'contents'}[2]{'parent'}
= $result_trees{'command_conditionals'}{'contents'}[4];
+$result_trees{'command_conditionals'}{'contents'}[4]{'parent'} =
$result_trees{'command_conditionals'};
+$result_trees{'command_conditionals'}{'contents'}[5]{'parent'} =
$result_trees{'command_conditionals'};
+$result_trees{'command_conditionals'}{'contents'}[6]{'contents'}[0]{'parent'}
= $result_trees{'command_conditionals'}{'contents'}[6];
+$result_trees{'command_conditionals'}{'contents'}[6]{'contents'}[1]{'parent'}
= $result_trees{'command_conditionals'}{'contents'}[6];
+$result_trees{'command_conditionals'}{'contents'}[6]{'contents'}[2]{'parent'}
= $result_trees{'command_conditionals'}{'contents'}[6];
+$result_trees{'command_conditionals'}{'contents'}[6]{'parent'} =
$result_trees{'command_conditionals'};
+
+$result_texis{'command_conditionals'} = 'Good, the txicommandconditionals
variable was set.
+
+Good, @@nodexyz is not defined.
+
+Good, @@node is defined.
+
+Happily, @@mathcode is not defined.
+';
+
+
+$result_texts{'command_conditionals'} = 'Good, the txicommandconditionals
variable was set.
+
+Good, @nodexyz is not defined.
+
+Good, @node is defined.
+
+Happily, @mathcode is not defined.
+';
+
+$result_errors{'command_conditionals'} = [];
+
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf...,
Patrice Dumas <=