8 my ($from_version, $to_version) = @_;
9 s/\version \"0.0.$from_version\"/\version \"0.0.$to_version\"/g;
12 ################################################################
15 conv_pl0_0_50_pl0_0_52
22 s/include \"/$1\\include \"/g;
26 ###############################################################
35 print STDERR "Usage: convert-mudela\n";
36 print STDERR "other options: --edit --output=FILE --show-rules\n";
40 my %minor_conversions = (50 => \&no_conv,
41 52 => \&conv_pl0_0_50_pl0_0_52,
42 53 => \&conv_pl52_pl53
46 return (sort keys %minor_conversions);
53 print "Rules: ", join(", ", sort keys %minor_conversions), "\n";
62 my @applicable_conversion;
65 die "This is too old to convert " if $from < 50;
68 if ($a > $from && $a <= $to ){
69 push @applicable_conversion, $minor_conversions{$a};
70 push @mudela_levels, $a;
74 print STDERR "Applying following rules: ", join(", ", @mudela_levels) , "\n";
77 foreach $subroutine (@applicable_conversion) {
82 version_string_conv $from, $to;
90 open INLY, $fn || die "Can't open";
93 s/^.*\\version \"([^\"]*)\".*$//;
95 print STDERR "Guessing version: ", $1, ".. ";
100 die "can't determine mudela version." unless (defined($ver));
110 $outfile = $opt_output if (defined($opt_output));
115 if (( ! -f $infile) && (! $infile =~ /\\.ly$/s ) ){
117 print STDERR "trying $infile";
120 if ($opt_edit && $infile ne "-") {
122 $outfile = "$infile.NEW";
127 GetOptions ("output=s", "from=i", "to=i", "minor=i", "edit", "show-rules");
129 if ($opt_show_rules) {
131 $opt_show_rules = 0; # to extinguish typo check.
135 local ( $infile,$outfile);
139 ($opt_from = set_auto_from $infile) unless defined($opt_from);
142 ($opt_to = pop @v) unless (defined($opt_to));
145 die "can't open \`$infile\'" unless open INLY,$infile ;
146 die "can't open \`$outfile\'" unless open OUTLY, ">$outfile";
148 do_conversion $opt_from, $opt_to;
153 rename $infile, "$infile~";
154 rename $outfile, "$infile";