From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1548815827B for ; Sun, 10 Aug 2025 17:05:32 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id F06C9341ECB for ; Sun, 10 Aug 2025 17:05:31 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id D6264110280; Sun, 10 Aug 2025 17:05:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id CA02A110280 for ; Sun, 10 Aug 2025 17:05:30 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 63821340C98 for ; Sun, 10 Aug 2025 17:05:30 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id CA78A32D5 for ; Sun, 10 Aug 2025 17:05:28 +0000 (UTC) From: "Kerin Millar" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Kerin Millar" Message-ID: <1754845482.2d2ee989b05556a6ba109458f2fdb605eeb596e1.kfm@gentoo> Subject: [gentoo-commits] proj/locale-gen:master commit in: / X-VCS-Repository: proj/locale-gen X-VCS-Files: locale-gen X-VCS-Directories: / X-VCS-Committer: kfm X-VCS-Committer-Name: Kerin Millar X-VCS-Revision: 2d2ee989b05556a6ba109458f2fdb605eeb596e1 X-VCS-Branch: master Date: Sun, 10 Aug 2025 17:05:28 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 495828f9-e204-482e-ae67-3aadea2c2663 X-Archives-Hash: 3962fce4fbd1063d7444f1ec5127f59f commit: 2d2ee989b05556a6ba109458f2fdb605eeb596e1 Author: Kerin Millar plushkava net> AuthorDate: Sun Aug 10 16:57:23 2025 +0000 Commit: Kerin Millar plushkava net> CommitDate: Sun Aug 10 17:04:42 2025 +0000 URL: https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=2d2ee989 Delegate config file selection wholly to a new subroutine This commit introduces the select_config_file() subroutine, which relieves both the main block and the parse_opts() subroutine of their joint responsibility in determining which config files are to be passed to the read_config() subroutine. Signed-off-by: Kerin Millar plushkava.net> locale-gen | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/locale-gen b/locale-gen index d1d66d7..948ee59 100755 --- a/locale-gen +++ b/locale-gen @@ -74,15 +74,7 @@ umask 0022; my @locales = ([ 'C', 'UTF-8', 'C.UTF-8' ]); # Compose a list of up to two configuration files to be read. - my @config_files; - if (exists $opt{'config'}) { - push @config_files, $opt{'config'}; - } else { - push @config_files, ( - catfile($prefix, '/etc', 'locale.gen'), - catfile($prefix, '/usr/share/i18n', 'SUPPORTED') - ); - } + my @config_files = select_config_files($prefix, %opt); # Collect the locales that are being requested for installation. push @locales, read_config($prefix, @config_files); @@ -196,15 +188,29 @@ sub parse_opts ($known_prefix, @args) { if (! exists $opt{'jobs'} || $opt{'jobs'} < 1) { $opt{'jobs'} = get_nprocs() || 1; } - if ($opt{'all'}) { - $opt{'config'} = catfile($opt{'prefix'} // $known_prefix, '/usr/share/i18n', 'SUPPORTED'); - } elsif (exists $opt{'config'} && $opt{'config'} eq '-') { + + # Replace the special operand with "/dev/stdin". + if (exists $opt{'config'} && $opt{'config'} eq '-') { $opt{'config'} = '/dev/stdin'; } return %opt; } +sub select_config_files ($prefix, %opt) { + my $path1 = catfile($prefix, '/etc', 'locale.gen'); + my $path2 = catfile($prefix, '/usr/share/i18n', 'SUPPORTED'); + return do { + if (exists $opt{'config'}) { + $opt{'config'}; + } elsif (! $opt{'all'}) { + $path1, $path2; + } else { + $path2; + } + }; +} + sub show_usage (@options) { print "Usage: locale-gen [OPTION]...\n\n"; my $pipe;