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 F15D115827B for ; Wed, 20 Aug 2025 02:39:36 +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 D93B1342461 for ; Wed, 20 Aug 2025 02:39:36 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id E7A6811055F; Wed, 20 Aug 2025 02:39:32 +0000 (UTC) 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) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id D4EEA11055F for ; Wed, 20 Aug 2025 02:39:32 +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 74AED34245F for ; Wed, 20 Aug 2025 02:39:32 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 837E6322F for ; Wed, 20 Aug 2025 02:39:30 +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: <1755618173.a11addf203d3ee4d043f5dc1aca9451ec98166a9.kfm@gentoo> Subject: [gentoo-commits] proj/locale-gen:master commit in: / X-VCS-Repository: proj/locale-gen X-VCS-Files: mkconfig X-VCS-Directories: / X-VCS-Committer: kfm X-VCS-Committer-Name: Kerin Millar X-VCS-Revision: a11addf203d3ee4d043f5dc1aca9451ec98166a9 X-VCS-Branch: master Date: Wed, 20 Aug 2025 02:39:30 +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: 846b6151-bd2a-43e0-885f-635fe6470ba5 X-Archives-Hash: cde2f5dc8495cf33382028450b692f4d commit: a11addf203d3ee4d043f5dc1aca9451ec98166a9 Author: Kerin Millar plushkava net> AuthorDate: Tue Aug 19 15:42:53 2025 +0000 Commit: Kerin Millar plushkava net> CommitDate: Tue Aug 19 15:42:53 2025 +0000 URL: https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=a11addf2 mkconfig: use read_lines() to read the SUPPORTED file Use the read_lines() method of File::Slurper to consume the SUPPORTED file. Doing so might use a little more memory than does reading line by line. However, it confers the advantage of decoding the input as UTF-8 and throwing an exception if malformed. See-also: 945525e71206428f87f94b839fe4ce36b9d85e1e Signed-off-by: Kerin Millar plushkava.net> mkconfig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mkconfig b/mkconfig index c455a54..b52beb5 100755 --- a/mkconfig +++ b/mkconfig @@ -13,15 +13,15 @@ use v5.36; use File::Spec::Functions qw(catdir catfile); use Unicode::Normalize qw(NFKD); -use File::Slurper qw(read_text); +use File::Slurper qw(read_lines read_text); { # The first argument shall be treated as a prefix, if any. my $prefix = @ARGV ? $ARGV[0] : ''; - # Open the file containing the supported locale/charmap combinations. + # Read the file containing the supported locale/charmap combinations. my $path = catfile($prefix, '/usr/share/i18n', 'SUPPORTED'); - open my $fh, '<', $path or die "Can't open '$path': $!"; + my @lines = read_lines($path); # Gather the language and territory attributes of the locale templates. my $attr_by = map_locale_attributes($prefix); @@ -29,7 +29,7 @@ use File::Slurper qw(read_text); # Use column(1) to write out a nicely columnated list. my $pipe = open_column("\037"); - while (my $line = readline $fh) { + for my $line (@lines) { my ($read_locale, $charmap) = split ' ', $line; # The names of the templates don't incorporate a codeset part. @@ -51,7 +51,6 @@ use File::Slurper qw(read_text); printf {$pipe} "# %s\037%s\037# %s\n", $read_locale, $charmap, $comment; } } - close $fh; close $pipe or exit 1; }