From 85e1e753b0a0bccb6039411d7fdee240ced54dac Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 19 Jul 2011 19:16:54 +0000 Subject: [PATCH] Commit FS#12188 - Fix perl scripts that used Switch by Sean Bartell. Perl 5.14 removed Switch which means that Rockbox will no longer build with the current release of Perl. The patch replaces Switch with given/when which was introduced in Perl 5.10.0. Debian stable has 5.10.1, cygwin 1.7 has 5.10.1 and Mac OSX 10.6 comes with 5.10.0. I'm not sure what version older versions of OSX come with, but newer versions are apparently available from Macports. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30169 a1c6a512-1295-4272-9138-f99709370657 --- tools/multigcc.pl | 10 +++++----- tools/voice.pl | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/multigcc.pl b/tools/multigcc.pl index 9be9978bd..e263638d9 100755 --- a/tools/multigcc.pl +++ b/tools/multigcc.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -use Switch; +use feature "switch"; use List::Util 'shuffle'; # standard from Perl 5.8 and later my $tempfile = "multigcc.out"; @@ -26,16 +26,16 @@ my $command = join " ", @params; # count number of cores my $cores; -switch($^O) { - case "darwin" { +given ($^O) { + when ("darwin") { chomp($cores = `sysctl -n hw.ncpu`); $cores = 1 if ($?); } - case "solaris" { + when ("solaris") { $cores = scalar grep /on-line/i, `psrinfo`; $cores = 1 if ($?); } - else { + default { if (open CPUINFO, "; close CPUINFO; diff --git a/tools/voice.pl b/tools/voice.pl index ee68c30eb..9c528299b 100755 --- a/tools/voice.pl +++ b/tools/voice.pl @@ -17,9 +17,9 @@ use strict; use warnings; +use feature 'switch'; use File::Basename; use File::Copy; -use Switch; use vars qw($V $C $t $l $e $E $s $S $i $v); use IPC::Open2; use IPC::Open3; @@ -74,8 +74,8 @@ sub init_tts { our $verbose; my ($tts_engine, $tts_engine_opts, $language) = @_; my %ret = ("name" => $tts_engine); - switch($tts_engine) { - case "festival" { + given ($tts_engine) { + when ("festival") { print("> festival $tts_engine_opts --server\n") if $verbose; my $pid = open(FESTIVAL_SERVER, "| festival $tts_engine_opts --server > /dev/null 2>&1"); my $dummy = *FESTIVAL_SERVER; #suppress warning @@ -83,7 +83,7 @@ sub init_tts { $SIG{KILL} = sub { kill TERM => $pid; print("boo"); panic_cleanup(); }; $ret{"pid"} = $pid; } - case "sapi" { + when ("sapi") { my $toolsdir = dirname($0); my $path = `cygpath $toolsdir -a -w`; chomp($path); @@ -111,12 +111,12 @@ sub init_tts { # Shutdown TTS engine if necessary. sub shutdown_tts { my ($tts_object) = @_; - switch($$tts_object{"name"}) { - case "festival" { + given ($$tts_object{"name"}) { + when ("festival") { # Send SIGTERM to festival server kill TERM => $$tts_object{"pid"}; } - case "sapi" { + when ("sapi") { print({$$tts_object{"stdin"}} "QUIT\r\n"); close($$tts_object{"stdin"}); } @@ -147,8 +147,8 @@ sub voicestring { my ($string, $output, $tts_engine_opts, $tts_object) = @_; my $cmd; printf("Generate \"%s\" with %s in file %s\n", $string, $$tts_object{"name"}, $output) if $verbose; - switch($$tts_object{"name"}) { - case "festival" { + given ($$tts_object{"name"}) { + when ("festival") { # festival_client lies to us, so we have to do awful soul-eating # work with IPC::open3() $cmd = "festival_client --server localhost --otype riff --ttw --output \"$output\""; @@ -168,22 +168,22 @@ sub voicestring { close(CMD_OUT); close(CMD_ERR); } - case "flite" { + when ("flite") { $cmd = "flite $tts_engine_opts -t \"$string\" \"$output\""; print("> $cmd\n") if $verbose; `$cmd`; } - case "espeak" { + when ("espeak") { $cmd = "espeak $tts_engine_opts -w \"$output\""; print("> $cmd\n") if $verbose; open(ESPEAK, "| $cmd"); print ESPEAK $string . "\n"; close(ESPEAK); } - case "sapi" { + when ("sapi") { print({$$tts_object{"stdin"}} "SPEAK\t$output\t$string\r\n"); } - case "swift" { + when ("swift") { $cmd = "swift $tts_engine_opts -o \"$output\" \"$string\""; print("> $cmd\n") if $verbose; system($cmd); -- 2.11.4.GIT