[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: |
Sat, 29 Oct 2011 11:31:56 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/10/29 11:31:56
Modified files:
tp : texi2any.pl
tp/Texinfo : Common.pm Parser.pm
tp/Texinfo/Convert: Plaintext.pm
Log message:
Handle cpp synchronization lines.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/texi2any.pl?cvsroot=texinfo&r1=1.77&r2=1.78
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.83&r2=1.84
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.321&r2=1.322
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Plaintext.pm?cvsroot=texinfo&r1=1.176&r2=1.177
Patches:
Index: texi2any.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/texi2any.pl,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- texi2any.pl 26 Oct 2011 22:53:08 -0000 1.77
+++ texi2any.pl 29 Oct 2011 11:31:55 -0000 1.78
@@ -855,7 +855,7 @@
foreach my $parser_settable_option ('TOP_NODE_UP', 'MAX_MACRO_CALL_NESTING',
'INLINE_INSERTCOPYING', 'SHOW_MENU',
'IGNORE_BEFORE_SETFILENAME', 'TEST',
- 'GLOBAL_COMMANDS') {
+ 'GLOBAL_COMMANDS', 'CPP_LINE_DIRECTIVES') {
$parser_default_options->{$parser_settable_option} =
get_conf($parser_settable_option)
if (defined(get_conf($parser_settable_option)));
}
Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -b -r1.83 -r1.84
--- Texinfo/Common.pm 28 Oct 2011 23:04:16 -0000 1.83
+++ Texinfo/Common.pm 29 Oct 2011 11:31:56 -0000 1.84
@@ -144,8 +144,9 @@
'PROGRAM_NAME_IN_FOOTER', 'NODE_FILENAMES', 'DEFAULT_ENCODING',
'OUT_ENCODING', 'ENCODING_NAME', 'EXTERNAL_CROSSREF_SPLIT', 'BODYTEXT',
'CSS_LINES', 'RENAMED_NODES_REDIRECTIONS', 'RENAMED_NODES_FILE',
- 'TEXI2DVI', 'DUMP_TREE', 'MAX_MACRO_CALL_NESTING',
# TODO new, document?
+ 'TEXI2DVI', 'DUMP_TREE', 'MAX_MACRO_CALL_NESTING',
+ 'CPP_LINE_DIRECTIVES',
'PROGRAM_AND_VERSION', 'PROGRAM_HOMEPAGE', 'PROGRAM',
'PRE_BODY_CLOSE', 'AFTER_BODY_OPEN', 'PRE_ABOUT', 'AFTER_ABOUT',
'EXTRA_HEAD', 'LINKS_BUTTONS', 'DO_ABOUT',
@@ -1246,6 +1247,20 @@
return %options;
}
+sub count_bytes($$)
+{
+ my $self = shift;
+ my $string = shift;
+
+ if ($self and $self->{'perl_encoding'}
+ and $self->{'perl_encoding'} ne 'ascii') {
+ return length(Encode::encode($self->{'perl_encoding'}, $string));
+ } else {
+ return length($string);
+ }
+}
+
+
1;
__END__
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.321
retrieving revision 1.322
diff -u -b -r1.321 -r1.322
--- Texinfo/Parser.pm 28 Oct 2011 23:04:16 -0000 1.321
+++ Texinfo/Parser.pm 29 Oct 2011 11:31:56 -0000 1.322
@@ -143,6 +143,9 @@
'documentlanguage' => undef,
# Current documentlanguage set by
# @documentlanguage
+ '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
'TOP_NODE_UP' => '(dir)', # up node of Top node
'SIMPLE_MENU' => 0, # currently not used in the parser for now,
@@ -674,11 +677,13 @@
my $line;
my @first_lines;
while ($line = <$filehandle>) {
- $line_nr++;
- $line =~ s/\x{7F}.*\s*//;
if ($line =~ /^ *\\input/ or $line =~ /^\s*$/) {
+ $line =~ s/\x{7F}.*\s*//;
push @first_lines, $line;
+ $line_nr++;
} else {
+ # put the line back in the filehandle
+ seek($filehandle, -Texinfo::Common::count_bytes($self, $line), 1);
last;
}
}
@@ -694,8 +699,7 @@
$self = parser() if (!defined($self));
$self->{'input'} = [{
- 'pending' => [ [$line, { 'line_nr' => $line_nr,
- 'file_name' => $file_name, 'macro' => '' }] ],
+ 'pending' => [],
'name' => $file_name,
'line_nr' => $line_nr,
'fh' => $filehandle
@@ -1677,14 +1681,23 @@
} elsif ($current->{'fh'}) {
my $fh = $current->{'fh'};
my $line = <$fh>;
- if (defined($line)) {
+ while (defined($line)) {
$line =~ s/\x{7F}.*\s*//;
+ if ($self->{'CPP_LINE_DIRECTIVES'}
+ and $line =~ /^\s*#\s*(line)? (\d+)( "([^"]+)")?(\s+\d+)*/) {
+ $current->{'line_nr'} = $2;
+ if (defined($4)) {
+ $current->{'name'} = $4;
+ }
+ $line = <$fh>;
+ } else {
$current->{'line_nr'}++;
return ($line, {'line_nr' => $current->{'line_nr'},
'file_name' => $current->{'name'},
'macro' => ''});
}
}
+ }
shift(@{$self->{'input'}});
}
Index: Texinfo/Convert/Plaintext.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Plaintext.pm,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -b -r1.176 -r1.177
--- Texinfo/Convert/Plaintext.pm 22 Oct 2011 19:56:26 -0000 1.176
+++ Texinfo/Convert/Plaintext.pm 29 Oct 2011 11:31:56 -0000 1.177
@@ -568,11 +568,7 @@
my $self = shift;
my $string = shift;
- if ($self->{'perl_encoding'} and $self->{'perl_encoding'} ne 'ascii') {
- return length(Encode::encode($self->{'perl_encoding'}, $string));
- } else {
- return length($string);
- }
+ return Texinfo::Common::count_bytes($self, $string);
}
sub _add_text_count($$)
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/02
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/08
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/10
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/11
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/21
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf...,
Patrice Dumas <=
- texinfo/tp texi2any.pl Texinfo/Common.pm Texinf..., Patrice Dumas, 2011/10/30