texlive[44447] Master/tlpkg/TeXLive/TLConfFile.pm: fix two TLConfFile

commits+preining at tug.org commits+preining at tug.org
Sun Jun 4 04:03:31 CEST 2017


Revision: 44447
          http://tug.org/svn/texlive?view=revision&revision=44447
Author:   preining
Date:     2017-06-04 04:03:31 +0200 (Sun, 04 Jun 2017)
Log Message:
-----------
fix two TLConfFile bugs (mail Takayuki YATO 2017-05-25)

Modified Paths:
--------------
    trunk/Master/tlpkg/TeXLive/TLConfFile.pm

Modified: trunk/Master/tlpkg/TeXLive/TLConfFile.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLConfFile.pm	2017-06-03 22:56:23 UTC (rev 44446)
+++ trunk/Master/tlpkg/TeXLive/TLConfFile.pm	2017-06-04 02:03:31 UTC (rev 44447)
@@ -214,6 +214,7 @@
       $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,8 +314,8 @@
   #
   # 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");
@@ -321,23 +322,27 @@
     } 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 @@
   }
   # 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 @@
   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";
     }



More information about the tex-live-commits mailing list