From 83190675a8a72b94a0c34db8a26fa9628d6c04dc Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 27 May 2010 18:29:08 +0000 Subject: allow post comments and continuation lines (who would want to have that?) git-svn-id: svn://tug.org/texlive/trunk@18534 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLConfFile.pm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'Master/tlpkg') diff --git a/Master/tlpkg/TeXLive/TLConfFile.pm b/Master/tlpkg/TeXLive/TLConfFile.pm index 13e6904595e..17233ca201f 100644 --- a/Master/tlpkg/TeXLive/TLConfFile.pm +++ b/Master/tlpkg/TeXLive/TLConfFile.pm @@ -40,19 +40,29 @@ sub reparse $self{'keyvalue'} = (); $self{'confdata'} = \%config; $self{'changed'} = 0; + my $in_postcomment = 0; for my $i (0..$config{'lines'}) { if ($config{$i}{'type'} eq 'comment') { $lastkey = undef; + $is_postcomment = 0; } elsif ($config{$i}{'type'} eq 'data') { $lastkey = $config{$i}{'key'}; $self{'keyvalue'}{$lastkey}{'value'} = $config{$i}{'value'}; $self{'keyvalue'}{$lastkey}{'line'} = $i; $self{'keyvalue'}{$lastkey}{'status'} = 'unchanged'; + if (defined($config{$i}{'postcomment'})) { + $in_postcomment = 1; + } else { + $in_postcomment = 0; + } } elsif ($config{$i}{'type'} eq 'empty') { $lastkey = undef; + $is_postcomment = 0; } elsif ($config{$i}{'type'} eq 'continuation') { if (defined($lastkey)) { - $self{'keyvalue'}{$lastkey}{'value'} .= $config{$i}{'value'}; + if (!$in_postcomment) { + $self{'keyvalue'}{$lastkey}{'value'} .= $config{$i}{'value'}; + } } # otherwise we are in a continuation of a comment!!! so nothing to do } else { @@ -179,7 +189,7 @@ sub save if (defined($config{$i}{'postcomment'})) { print $fhout $config{$i}{'postcomment'}; } - print $fhout "\n"; + print $fhout ($config{$i}{'multiline'} ? "\\\n" : "\n"); } else { print $fhout "$config{$i}{'original'}"; print $fhout ($config{$i}{'multiline'} ? "\\\n" : "\n"); @@ -289,7 +299,13 @@ sub parse_config_file { $config{$l}{'key'} = $1; $config{$l}{'value'} = $2; if (defined($3)) { - $config{$l}{'postcomment'} = $3; + my $postcomment = $3; + # check that there is actually a comment in the second part of the + # line. Otherwise we might add the continuation lines of that + # line to the value + if ($postcomment =~ m/$cc/) { + $config{$l}{'postcomment'} = $postcomment; + } } next; } -- cgit v1.2.3