4 # version of "supporting" engine, not mudela conversions.
7 $convert_mudela_version = "0.1";
13 sub version_string_conv
15 my ($from_version, $to_version) = @_;
16 s/\version \"0.0.$from_version\"/\version \"0.0.$to_version\"/g;
19 ################################################################
25 sub convert_0_0_52_to_0_0_53
28 s/include \"/$1\\include \"/g;
32 sub convert_0_0_53_to_0_0_54
34 print STDERR "Not smart enough to convert \\transpose\n" if (/\\transpose/) ;
37 ###############################################################
47 print STDERR "This is convert-mudela " . $convert_mudela_version .
48 " (up to mudela version 0.0.", last_conversion, ")\n";
54 print STDERR "Usage: convert-mudela [options] [mudela-file]...\n"
55 . "Convert old mudela source from mudela-file or stdin\n\n"
57 . " -e, --edit perform in-place conversion\n"
58 . " -f, --from=PATHLEVEL use source version 0.0.PATCHLEVEL\n"
59 . " -h, --help print this help\n"
60 . " -o, --output=FILE name output file\n"
61 . " -s, --show-rules print all known conversion rules\n"
62 . " -t, --to=PATCHLEVEL convert to version 0.0.PATCHLEVEL\n"
65 # beware of the year 2000
66 my %minor_conversions = (50 => \&no_conv,
67 52 => \&convert_0_0_50_to_0_0_52,
68 53 => \&convert_0_0_52_to_0_0_53,
69 54 => \&convert_0_0_53_to_0_0_54
75 return (sort keys %minor_conversions);
81 print "Rules: ", join(", ", sort keys %minor_conversions), "\n";
89 my @applicable_conversion;
92 die "This is too old to convert " if $from < 50;
95 if ($a > $from && $a <= $to ){
96 push @applicable_conversion, $minor_conversions{$a};
97 push @mudela_levels, $a;
101 print STDERR "Applying following rules: ", join(", ", @mudela_levels) , "\n";
104 foreach $subroutine (@applicable_conversion) {
109 version_string_conv $from, $to;
118 open INLY, $fn || die "Can't open";
121 s/^.*\\version \"([^\"]*)\".*$//;
123 print STDERR "Guessing version: ", $1, ".. ";
129 print STDERR "can't determine mudela version in $fn.\n";
142 $outfile = $opt_output if (defined($opt_output));
147 if (( ! -f $infile) && (! $infile =~ /\\.ly$/s ) ){
152 if ($opt_edit && $infile ne "-") {
154 $outfile = "$infile.NEW";
157 print STDERR "Input ", (($infile eq "-") ?"STDIN" : $infile), " .. ";
165 local ($from_version, $to_version);
166 $from_version = $opt_from;
167 $to_version = $opt_to;
169 ($from_version = get_auto_from $infile) unless defined($opt_from);
170 return if (!defined($from_version));
172 ($to_version = last_conversion) unless (defined($opt_to));
175 die "can't open \`$infile\'" unless open INLY,$infile ;
176 die "can't open \`$outfile\'" unless open OUTLY, ">$outfile";
178 do_conversion $from_version, $to_version;
183 rename $infile, "$infile~";
184 rename $outfile, "$infile";
192 GetOptions ("help", "output=s", "from=i", "to=i", "minor=i", "edit", "show-rules");
196 $opt_help = 0; # to extinguish typo check.
200 if ($opt_show_rules) {
202 $opt_show_rules = 0; # to extinguish typo check.
206 local ( $infile,$outfile);
209 while (defined($ARGV[0])) {
214 do_one_arg unless ($processed_one);