perl magic: Use if/elsif/else instead of given/when (FS #12188)
Unbreaks the maemo build. Patch by Nick Peskett with a small comment added as suggested by Dominik Riebeling. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30323 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2e154df92f
commit
121b26e62f
2 changed files with 90 additions and 97 deletions
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/perl
|
||||
use feature "switch";
|
||||
use List::Util 'shuffle'; # standard from Perl 5.8 and later
|
||||
|
||||
my $tempfile = "multigcc.out";
|
||||
|
@ -26,16 +25,16 @@ my $command = join " ", @params;
|
|||
|
||||
# count number of cores
|
||||
my $cores;
|
||||
given ($^O) {
|
||||
when ("darwin") {
|
||||
# Don't use given/when here - it's not compatible with old perl versions
|
||||
if ($^O eq 'darwin') {
|
||||
chomp($cores = `sysctl -n hw.ncpu`);
|
||||
$cores = 1 if ($?);
|
||||
}
|
||||
when ("solaris") {
|
||||
elsif ($^O eq 'solaris') {
|
||||
$cores = scalar grep /on-line/i, `psrinfo`;
|
||||
$cores = 1 if ($?);
|
||||
}
|
||||
default {
|
||||
else {
|
||||
if (open CPUINFO, "</proc/cpuinfo") {
|
||||
$cores = scalar grep /^processor/i, <CPUINFO>;
|
||||
close CPUINFO;
|
||||
|
@ -44,7 +43,6 @@ given ($^O) {
|
|||
$cores = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# fork children
|
||||
my @pids;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use feature 'switch';
|
||||
use File::Basename;
|
||||
use File::Copy;
|
||||
use vars qw($V $C $t $l $e $E $s $S $i $v);
|
||||
|
@ -74,8 +73,8 @@ sub init_tts {
|
|||
our $verbose;
|
||||
my ($tts_engine, $tts_engine_opts, $language) = @_;
|
||||
my %ret = ("name" => $tts_engine);
|
||||
given ($tts_engine) {
|
||||
when ("festival") {
|
||||
# Don't use given/when here - it's not compatible with old perl versions
|
||||
if ($tts_engine eq '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 +82,7 @@ sub init_tts {
|
|||
$SIG{KILL} = sub { kill TERM => $pid; print("boo"); panic_cleanup(); };
|
||||
$ret{"pid"} = $pid;
|
||||
}
|
||||
when ("sapi") {
|
||||
elsif ($tts_engine eq 'sapi') {
|
||||
my $toolsdir = dirname($0);
|
||||
my $path = `cygpath $toolsdir -a -w`;
|
||||
chomp($path);
|
||||
|
@ -104,24 +103,21 @@ sub init_tts {
|
|||
"stdout" => *CMD_OUT,
|
||||
"vendor" => $vendor);
|
||||
}
|
||||
}
|
||||
return \%ret;
|
||||
}
|
||||
|
||||
# Shutdown TTS engine if necessary.
|
||||
sub shutdown_tts {
|
||||
my ($tts_object) = @_;
|
||||
given ($$tts_object{"name"}) {
|
||||
when ("festival") {
|
||||
if ($$tts_object{'name'} eq 'festival') {
|
||||
# Send SIGTERM to festival server
|
||||
kill TERM => $$tts_object{"pid"};
|
||||
}
|
||||
when ("sapi") {
|
||||
elsif ($$tts_object{'name'} eq 'sapi') {
|
||||
print({$$tts_object{"stdin"}} "QUIT\r\n");
|
||||
close($$tts_object{"stdin"});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Apply corrections to a voice-string to make it sound better
|
||||
sub correct_string {
|
||||
|
@ -146,9 +142,9 @@ sub voicestring {
|
|||
our $verbose;
|
||||
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;
|
||||
given ($$tts_object{"name"}) {
|
||||
when ("festival") {
|
||||
my $name = $$tts_object{'name'};
|
||||
printf("Generate \"%s\" with %s in file %s\n", $string, $name, $output) if $verbose;
|
||||
if ($name eq '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,28 +164,27 @@ sub voicestring {
|
|||
close(CMD_OUT);
|
||||
close(CMD_ERR);
|
||||
}
|
||||
when ("flite") {
|
||||
elsif ($name eq 'flite') {
|
||||
$cmd = "flite $tts_engine_opts -t \"$string\" \"$output\"";
|
||||
print("> $cmd\n") if $verbose;
|
||||
`$cmd`;
|
||||
}
|
||||
when ("espeak") {
|
||||
elsif ($name eq 'espeak') {
|
||||
$cmd = "espeak $tts_engine_opts -w \"$output\"";
|
||||
print("> $cmd\n") if $verbose;
|
||||
open(ESPEAK, "| $cmd");
|
||||
print ESPEAK $string . "\n";
|
||||
close(ESPEAK);
|
||||
}
|
||||
when ("sapi") {
|
||||
elsif ($name eq 'sapi') {
|
||||
print({$$tts_object{"stdin"}} "SPEAK\t$output\t$string\r\n");
|
||||
}
|
||||
when ("swift") {
|
||||
elsif ($name eq 'swift') {
|
||||
$cmd = "swift $tts_engine_opts -o \"$output\" \"$string\"";
|
||||
print("> $cmd\n") if $verbose;
|
||||
system($cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# trim leading / trailing silence from the clip
|
||||
sub wavtrim {
|
||||
|
|
Loading…
Reference in a new issue