Bug#821096: (no subject)

victory <[email protected]>
Newsgroups gmane.linux.debian.devel.www
Message-ID <20160417162933.348b25c7e1d7d986dce78308__1694.56143999032$1460892878$gmane$org@gmail.com>
to make it prompt you to select "keep current|merge|override"
 when the target wml file exists

first some lines of "make_wml" subroutine
sub make_wml{
  $moreinfo = read_old_wml($wml, $moreinfo) if (-f $wml);
  return if($moreinfo eq "KEEP");
  open WML, ">", "$wml";

new subroutine:
sub read_old_wml{
  my $w = shift;
  my $n = shift;
  return unless (-f $w);
  open (WML, "<", $w) or return;
  my ($flag, $o);
  while (my $c=<WML>){
    last if((substr($c,0,20) eq '<p>For the oldstable')
		||(substr($c,0,17) eq '<p>For the stable')
		||(substr($c,0,18) eq '<p>For the testing')
		||(substr($c,0,19) eq '<p>For the unstable'));
    $o .= $c if($flag);
    $flag=1 if(substr($c,0,21) eq '<define-tag moreinfo>');
  }
  close WML;
  print "$w already exists!\n";
  print "current wml file has no contents. will be overridden.\n" if(!$o);
  print "current wml file has following contents:\n\t" if($o);
  print $o =~ s/\n/\n\t/rg if($o);
  print "\n\tchoices are: keep current[K], merge[M], override[O].\n" if($o);
  print "\t(defaults to 'keep current', do nothing.)\n" if($o);
  my $s;
  my $e=<STDIN>;
  chomp $e;
  $s = 1 if ($e eq "O");
  $s = 2 if ($e eq "M");
  return "KEEP" if(!$s);
  return $n if ($s == 1);
  # merge old description and new package versions below
  my $p = index($n, "\n\n<p>For the");
  my $n2 = substr($n,$p);
  $n = substr($n,0,$p);
  print "\nn:$n\n";
  $p = index($o, "\n\n<p>For the");
  $o = substr($o,0,$p);
  return "$n\n\n<p>For reference, the original advisory text follows.</p>\n\n$o$n2";
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.