commit: d855d71c4d12fb7ed6e458c3be91ec9c8aa33fe7
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Sep 12 04:13:28 2025 +0000
Commit: Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Fri Sep 12 16:42:13 2025 +0000
URL: https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=d855d71c
Introduce the basename() helper subroutine
Add a new subroutine that serves as a simple wrapper for
File::Spec->splitpath().
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
locale-gen | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/locale-gen b/locale-gen
index 16bcc00..0d180f3 100755
--- a/locale-gen
+++ b/locale-gen
@@ -17,10 +17,7 @@ use Getopt::Long ();
# Formally stable as of v5.40; sufficiently functional in both v5.36 and v5.38.
use experimental qw(try);
-# Determine the basename of the presently compiling script.
-my $PROGRAM;
-BEGIN { $PROGRAM = (splitpath(__FILE__))[-1]; }
-
+my $PROGRAM = basename(__FILE__);
my $VERSION = '3.4';
my $DEFERRED_SIGNAL = '';
@@ -309,7 +306,7 @@ sub get_valid_locales ($prefix) {
die "$PROGRAM: Can't chdir to '$pwd': $!\n";
} else {
chomp @paths;
- return map +( (splitpath($_))[-1] ), @paths;
+ return map +basename($_), @paths;
}
}
@@ -632,6 +629,10 @@ sub round ($number) {
return eval(sprintf '%.2f', $number);
}
+sub basename ($path) {
+ return (splitpath($path))[2];
+}
+
END {
if ($$ == $PID) {
if (length $TEMPDIR) {