}
sub split_list {
- my $listtxt = shift || '';
+ my $listtxt = shift // '';
return split (/\0/, $listtxt) if $listtxt =~ m/\0/;
return $tmpl if !$tmpl;
my $res = '';
- while ($tmpl =~ m/([^{]+)?({([^}]+)})?/g) {
+ while ($tmpl =~ m/([^{]+)?(\{([^}]+)\})?/g) {
$res .= $1 if $1;
$res .= ($data->{$3} || '-') if $2;
}
'pl' => ['Polish', 'pl', 'qwerty/pl.kmap.gz', 'pl', undef],
'pt' => ['Portuguese', 'pt', 'qwerty/pt-latin1.kmap.gz', 'pt', 'nodeadkeys'],
'pt-br' => ['Brazil-Portuguese', 'pt-br', 'qwerty/br-latin1.kmap.gz', 'br', 'nodeadkeys'],
- #'ru' => ['Russian', 'ru', 'qwerty/ru.kmap.gz', 'ru', undef], # dont know?
+ #'ru' => ['Russian', 'ru', 'qwerty/ru.kmap.gz', 'ru', undef], # don't know?
'si' => ['Slovenian', 'sl', 'qwertz/slovene.kmap.gz', 'si', undef],
'se' => ['Swedish', 'sv', 'qwerty/se-latin1.kmap.gz', 'se', 'nodeadkeys'],
#'th' => [],
# avoid leaving a zombie if the parent gets interrupted
my $sig_received;
- local $SIG{INT} = sub { $sig_received++; };
my $child = fork();
if (!defined($child)) {
POSIX::_exit(0);
}
+ local $SIG{INT} = sub { $sig_received++; };
+ local $SIG{TERM} = sub {
+ $error //= "interrupted by unexpected signal\n";
+ kill('TERM', $child);
+ };
+
$pipe_out->reader();
my $readvalues = sub {
local $/ = undef;
- my $child_res = decode_json(scalar<$pipe_out>);
+ my $child_res = decode_json(readline_nointr($pipe_out));
$res = $child_res->{result};
$error = $child_res->{error};
};
return int($value);
}
+# uninterruptible readline
+# retries on EINTR
+sub readline_nointr {
+ my ($fh) = @_;
+ my $line;
+ while (1) {
+ $line = <$fh>;
+ last if defined($line) || ($! != EINTR);
+ }
+ return $line;
+}
+
+sub get_host_arch {
+
+ my @uname = POSIX::uname();
+ my $machine = $uname[4];
+
+ if ($machine eq 'x86_64') {
+ return 'amd64';
+ } elsif ($machine eq 'aarch64') {
+ return 'arm64';
+ } else {
+ die "unsupported host architecture '$machine'\n";
+ }
+}
+
1;