From 1d58094ee8e1dca456fd71f151e6a46855774647 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 4 Jun 2017 02:03:31 +0000 Subject: fix two TLConfFile bugs (mail Takayuki YATO 2017-05-25) git-svn-id: svn://tug.org/texlive/trunk@44447 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLConfFile.pm | 44 ++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'Master/tlpkg/TeXLive/TLConfFile.pm') diff --git a/Master/tlpkg/TeXLive/TLConfFile.pm b/Master/tlpkg/TeXLive/TLConfFile.pm index 40ab9e9bd7d..9f9df17aea7 100644 --- a/Master/tlpkg/TeXLive/TLConfFile.pm +++ b/Master/tlpkg/TeXLive/TLConfFile.pm @@ -214,6 +214,7 @@ sub value $self{'changed'} = 1; } } + # $self->dump_myself(); if (defined($self{'keyvalue'}{$key})) { my @key_lines = sort by_lnr CORE::keys %{$self{'keyvalue'}{$key}}; if ($t eq 'first-win') { @@ -313,31 +314,35 @@ sub save # # first we write the config file as close as possible to orginal layout, # and after that we add new key/value pairs + my $current_key_value_is_changed = 0; for my $i (0..$config{'lines'}) { - my $is_changed = 0; if ($config{$i}{'type'} eq 'comment') { print $fhout "$config{$i}{'value'}"; print $fhout ($config{$i}{'multiline'} ? "\\\n" : "\n"); } elsif ($config{$i}{'type'} eq 'empty') { print $fhout ($config{$i}{'multiline'} ? "\\\n" : "\n"); } elsif ($config{$i}{'type'} eq 'data') { + $current_key_value_is_changed = 0; # we have to check whether the original data has been changed!! if ($self{'keyvalue'}{$config{$i}{'key'}}{$i}{'status'} eq 'changed') { - $is_changed = 1; + $current_key_value_is_changed = 1; print $fhout "$config{$i}{'key'} $config{'sep'} $self{'keyvalue'}{$config{$i}{'key'}}{$i}{'value'}"; if (defined($config{$i}{'postcomment'})) { print $fhout $config{$i}{'postcomment'}; } - print $fhout ($config{$i}{'multiline'} ? "\\\n" : "\n"); + # if a value is changed, we do not print out multiline stuff + # as keys are not split + print $fhout "\n"; } elsif ($self{'keyvalue'}{$config{$i}{'key'}}{$i}{'status'} eq 'deleted') { - $is_changed = 1; + $current_key_value_is_changed = 1; } else { - print $fhout "$config{$i}{'original'}"; - print $fhout ($config{$i}{'multiline'} ? "\\\n" : "\n"); + $current_key_value_is_changed = 0; + # the original already contains the final \, so only print new line + print $fhout "$config{$i}{'original'}\n"; } } elsif ($config{$i}{'type'} eq 'continuation') { - if ($is_changed) { - # ignore continuation lines + if ($current_key_value_is_changed) { + # ignore continuation lines if values are changed } else { print $fhout "$config{$i}{'value'}"; print $fhout ($config{$i}{'multiline'} ? "\\\n" : "\n"); @@ -475,9 +480,28 @@ sub parse_config_file { } # save the number of lines in the config hash $config{'lines'} = $lines; + #print "====DEBUG dumping config ====\n"; + #dump_config_data(\%config); + #print "====DEBUG writing config ====\n"; + #write_config_file(\%config); + #print "=============================\n"; return %config; } +sub dump_myself { + my $self = shift; + print "======== DUMPING SELF =============\n"; + dump_config_data($self{'confdata'}); + print "DUMPING KEY VALUES\n"; + for my $k (CORE::keys %{$self{'keyvalue'}}) { + print "key = $k\n"; + for my $l (sort CORE::keys %{$self{'keyvalue'}{$k}}) { + print " line =$l= value =", $self{'keyvalue'}{$k}{$l}{'value'}, "= status =", $self{'keyvalue'}{$k}{$l}{'status'}, "=\n"; + } + } + print "=========== END DUMP ==============\n"; +} + sub dump_config_data { my $foo = shift; my %config = %{$foo}; @@ -488,14 +512,16 @@ sub dump_config_data { for my $i (0..$config{'lines'}) { print "line ", $i+1, ": $config{$i}{'type'}"; if ($config{$i}{'type'} eq 'comment') { - print "\nCOMMNENT = $config{$i}{'value'}\n"; + print "\nCOMMENT = $config{$i}{'value'}\n"; } elsif ($config{$i}{'type'} eq 'data') { print "\nKEY = $config{$i}{'key'}\nVALUE = $config{$i}{'value'}\n"; + print "MULTLINE = ", ($config{$i}{'multiline'} ? "1" : "0"), "\n"; } elsif ($config{$i}{'type'} eq 'empty') { print "\n"; # do nothing } elsif ($config{$i}{'type'} eq 'continuation') { print "\nVALUE = $config{$i}{'value'}\n"; + print "MULTLINE = ", ($config{$i}{'multiline'} ? "1" : "0"), "\n"; } else { print "-- UNKNOWN TYPE\n"; } -- cgit v1.2.3