6 ################################################################
12 sub convert_0_0_52_to_0_0_53
15 s
/include
\"/$
1\\include
\"/g
;
19 sub convert_0_0_54_to_0_0_55
25 sub convert_0_0_53_to_0_0_54
27 print STDERR
"Not smart enough to convert \\transpose\n" if (/\\transpose
/) ;
30 # we-re not at 58 yet, but this is at least one of the rules
31 sub convert_0_0_55_to_0_0_56
36 sub convert_0_0_56_to_0_0_57
38 s
/\
(([ \
]\
[|
\t-\
.>]|
\\[<!>a
-z
]+)*\
)/\~ $
1/g
;
41 sub convert_0_0_57_to_0_0_58
43 s
/\
[ *([^\
[\
]]*)\
] *([1-9]*) *\
/ *([1-9]*)/[$
2\
/$
3 $
1]1\
/1/g
;
46 sub convert_0_0_58_to_0_0_59
48 die
"Not smart enough to convert 0.0.58 to 0.0.59\n";
51 sub convert_0_0_59_to_0_0_60
53 s
/(\\unitspace
[0-9.mcptin
\\ ]+|
\\geometric
[0-9.]+|
\\width
[0-9.mcp
\\tin
]+)/$
1;/g
;
54 s
/(\\output
\"[^
\"]+\")/$
1;/;
55 s
/(\\tempo
[0-9: ]+)/$
1;/;
58 sub convert_0_0_60_to_0_0_61
60 s
/(\\unitspace|
\\geometric|
\\width
)/$
1=/g
;
64 sub convert_0_1_0_to_0_1_1
66 s
/\\tempo (.*):(.*);/\\tempo $
1 = $
2;/g
69 sub convert_0_1_2_to_0_1_3
71 s
/\\stem
*(\\up|
1) *;/\\stemup
/g
;
72 s
/\\stem
*(\\down|
-1) *;/\\stemdown
/g
;
73 s
/\\stem
*0 *;/\\stemboth
/g
;
74 s
/\\hshift ([^
;]+) *;/\\property Voice
.hshift
= $
1/g
;
79 sub generic_conversion_scan
85 if ($header_b
&& /^
*\
}/)
90 sub convert_0_1_4_to_0_1_5
92 s
/([<{]) *\\id "Piano" (.+);/\\type Grandstaff
= $
3 $
1/;
93 s
/([<{]) *\\id (.+) (.+);/\\type $
2 = $
3 $
1/;
97 sub convert_0_1_5_to_0_1_6
99 s
/< *\\multi (.*);/\\multi $
1 </;
102 sub convert_0_1_6_to_0_1_7
106 s
/^
([a
-zA
-z
]+)[ \t]+(.*)$
/$
1 =\t \"$
2\";/;
107 s
/^
([ \t])+(.*)$
/$
1 \"$
2\";/;
111 sub convert_0_1_7_to_0_1_8
113 s
/\\plet
*1 *\
/ *1 *;/\\]/;
114 s
/\\plet
*([1-9][0-9]*) *\
/ *([2-9][0-9]*) *;/\\[$
1\
/$
2/;
117 sub convert_0_1_8_to_0_1_9
119 # sticky plet shorthand...
120 # print "introduced plet and finger shorthands...\n";
123 ###############################################################
133 print STDERR
"This is convert-mudela " . $convert_mudela_version
.
134 " (up to mudela version ", last_conversion
, ")\n";
140 print STDERR
"Usage: convert-mudela [options] [mudela-file]...\n"
141 . "Convert old mudela source from mudela-file or stdin\n\n"
143 . " -e, --edit perform in-place conversion\n"
144 . " -f, --from=PATHLEVEL use source version 0.0.PATCHLEVEL\n"
145 . " -h, --help print this help\n"
146 . " -o, --output=FILE name output file\n"
147 . " -s, --show-rules print all known conversion rules\n"
148 . " -t, --to=VERSION convert to version VERSION\n"
152 my
%minor_conversions
= ("0.0.50" => \
&no_conv
,
153 "0.0.52" => \
&convert_0_0_50_to_0_0_52
,
154 "0.0.53" => \
&convert_0_0_52_to_0_0_53
,
155 "0.0.54" => \
&convert_0_0_53_to_0_0_54
,
156 "0.0.55" => \
&convert_0_0_54_to_0_0_55
,
157 "0.0.56" => \
&convert_0_0_55_to_0_0_56
,
158 "0.0.57" => \
&convert_0_0_56_to_0_0_57
,
159 "0.0.58" => \
&convert_0_0_57_to_0_0_58
,
160 "0.0.59" => \
&convert_0_0_58_to_0_0_59
,
161 "0.0.60" => \
&convert_0_0_59_to_0_0_60
,
162 "0.0.61" => \
&convert_0_0_60_to_0_0_61
,
163 "0.1.1" => \
&convert_0_1_0_to_0_1_1
,
164 "0.1.2" => \
&no_conv
,
165 "0.1.3" => \
&convert_0_1_2_to_0_1_3
,
166 "0.1.4" => \
&no_conv
,
167 "0.1.5" => \
&convert_0_1_4_to_0_1_5
,
168 "0.1.6" => \
&convert_0_1_5_to_0_1_6
169 ,"0.1.7" => \
&convert_0_1_6_to_0_1_7
170 ,"0.1.8" => \
&convert_0_1_7_to_0_1_8
171 ,"0.1.9" => \
&convert_0_1_8_to_0_1_9
178 return (sort
{ cmpver
; } (keys
%minor_conversions
));
186 print "Rules: ", join(", ", @v), "\n";
194 my
@applicable_conversion;
199 if (version_compare($ver
, $
from) > 0 && version_compare($ver
,$to
) <= 0 ){
200 push
@applicable_conversion, $minor_conversions
{$ver
};
201 push
@mudela_levels, $ver
;
205 print STDERR
"Applying following rules: ", join(", ", @mudela_levels) , "\n";
208 generic_conversion_scan
;
209 foreach $
subroutine (@applicable_conversion) {
214 version_string_conv $
from, $to
;
223 open INLY
, $fn || die
"Can't open";
226 s
/^
.*\\version
\"([^
\"]*)\".*$
//;
228 print STDERR
"Guessing version: ", $
1, ".. ";
234 print STDERR
"can't determine mudela version in $fn.\n";
246 $outfile
= $opt_output
if (defined($opt_output
));
251 if (!(-f $infile
) && !($infile
=~
/\
.ly$
/s
)) {
254 if ($opt_edit
&& $infile ne
"-") {
256 $outfile
= "$infile.NEW";
259 print STDERR
"Input ", (($infile eq
"-") ?
"STDIN" : $infile
), " .. ";
267 local ($from_version
, $to_version
);
268 $from_version
= $opt_from
;
269 $to_version
= $opt_to
;
271 ($from_version
= get_auto_from $infile
) unless
defined($opt_from
);
272 return if (!defined($from_version
));
274 ($to_version
= last_conversion
) unless (defined($opt_to
));
276 die
"can't open \`$infile\'" unless
open INLY
,$infile
;
277 die
"can't open \`$outfile\'" unless
open OUTLY
, ">$outfile";
279 do_conversion $from_version
, $to_version
;
284 rename $infile
, "$infile~";
285 rename $outfile
, "$infile";
294 GetOptions ("help", "output=s", "from=i", "to=i", "minor=i", "edit", "show-rules");
298 $opt_help
= 0; # to extinguish typo check.
302 if ($opt_show_rules
) {
304 $opt_show_rules
= 0; # to extinguish typo check.
308 local ( $infile
,$outfile
);
311 while (defined($ARGV
[0])) {
316 do_one_arg
unless ($processed_one
);