Skip to content

Commit ffd8e51

Browse files
committed
charnames.pm: Make a variable ReadOnly
This is in preparation for exporting it in the next commit.
1 parent 5f27078 commit ffd8e51

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/_charnames.pm

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ sub carp
140140
require Carp; goto &Carp::carp;
141141
} # carp
142142

143+
sub populate_txt()
144+
{
145+
return if $txt;
146+
147+
$txt = do "unicore/Name.pl";
148+
Internals::SvREADONLY($txt, 1);
149+
}
150+
143151
sub alias (@) # Set up a single alias
144152
{
145153
my @errors;
@@ -408,7 +416,7 @@ sub lookup_name ($$$;$) {
408416
## "00052\nLATIN CAPITAL LETTER R\n\n"
409417
# or
410418
# "0052 0303\nLATIN CAPITAL LETTER R WITH TILDE\n\n"
411-
$txt = do "unicore/Name.pl" unless $txt;
419+
populate_txt() unless $txt;
412420

413421
## @off will hold the index into the code/name string of the start and
414422
## end of the name as we find it.
@@ -695,7 +703,7 @@ sub import
695703
## see if at least we can find one letter from each script.
696704
##
697705
if (warnings::enabled('utf8') && @scripts) {
698-
$txt = do "unicore/Name.pl" unless $txt;
706+
populate_txt() unless $txt;
699707

700708
for my $script (@scripts) {
701709
if (not $txt =~ m/^$script (?:CAPITAL |SMALL )?LETTER /m) {
@@ -773,7 +781,7 @@ sub viacode {
773781
# If the code point is above the max in the table, there's no point
774782
# looking through it. Checking the length first is slightly faster
775783
if (length($hex) <= 5 || CORE::hex($hex) <= 0x10FFFF) {
776-
$txt = do "unicore/Name.pl" unless $txt;
784+
populate_txt() unless $txt;
777785

778786
# See if the name is algorithmically determinable.
779787
my $algorithmic = charnames::code_point_to_name_special(CORE::hex $hex);

0 commit comments

Comments
 (0)