Skip to content

Commit ea25adf

Browse files
committed
UCD.pm: Add check for parameter type
This needs to be a scalar reference; I got burned with it not doing the right thing when it wasn't such a reference. Thanks to Tony Cook for contributing a better solution than mine.
1 parent 434c9cd commit ea25adf

File tree

7 files changed

+22
-7
lines changed

7 files changed

+22
-7
lines changed

β€Žcharclass_invlists.incβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456662,7 +456662,7 @@ static const U8 WB_dfa_table[] = {
456662456662
#endif /* defined(PERL_IN_REGEXEC_C) */
456663456663

456664456664
/* Generated from:
456665-
* 6cbf3f0fc04bbb22420eb9689126b5030bd714ad06397d0904702714feabe28e lib/Unicode/UCD.pm
456665+
* 198105a1b3637a4bc7240628bae2f65f6d0c31df2cee4f0242c2561421ea2e75 lib/Unicode/UCD.pm
456666456666
* 764f420cedfc8b43d9fec251c957a5d55fc45d40f6573f162990ed1dce7e36e0 lib/unicore/ArabicShaping.txt
456667456667
* b8f32554c6f658821fb0ee742d21c5b1f2086b9bf13071fed04894b022f93d67 lib/unicore/BidiBrackets.txt
456668456668
* d7afdadd1bbd66f5a663ac0e8f7958f18fd9491fc0bc59ec5877cb82db71db7d lib/unicore/BidiMirroring.txt

β€Žlib/Unicode/UCD.pmβ€Ž

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use warnings;
55
no warnings 'surrogate'; # surrogates can be inputs to this
66
use charnames ();
77

8-
our $VERSION = '0.82';
8+
our $VERSION = '0.83';
99

1010
sub DEBUG () { 0 }
1111
$|=1 if DEBUG;
@@ -2534,10 +2534,15 @@ change these into digits, and then call C<num> on the result.
25342534
sub num ($;$) {
25352535
my ($string, $retlen_ref) = @_;
25362536

2537+
if (defined $retlen_ref) {
2538+
eval { $$retlen_ref = 0; 1 } # Initialize to assume failure
2539+
or croak __PACKAGE__,
2540+
"::num: second parameter must be a scalar reference";
2541+
}
2542+
25372543
use feature 'unicode_strings';
25382544

25392545
_numeric unless %NUMERIC;
2540-
$$retlen_ref = 0 if $retlen_ref; # Assume will fail
25412546

25422547
my $length = length $string;
25432548
return if $length == 0;

β€Žlib/Unicode/UCD.tβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,16 @@ is($ret_len, 5, "... and the returned length is 5");
834834
ok(! defined num("98765\N{FULLWIDTH DIGIT FOUR}", \$ret_len),
835835
'Verify num("98765\N{FULLWIDTH DIGIT FOUR}") isnt defined');
836836
is($ret_len, 5, "... but the returned length is 5");
837+
{
838+
local $@;
839+
my @dummy = 5;
840+
eval { num("98765", \@dummy); };
841+
like($@, qr/::num: second parameter must be a scalar reference/,
842+
"num: Incorrect type for second parameter; must be scalar ref");
843+
my $x=\1;
844+
eval { num("98765", \$x); };
845+
is($@, "", 'num: Views $x=\1 as a scalar ref');
846+
}
837847
my $tai_lue_2;
838848
if ($v_unicode_version ge v4.1.0) {
839849
my $tai_lue_1 = charnames::string_vianame("NEW TAI LUE DIGIT ONE");

β€Žlib/unicore/uni_keywords.plβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žregcharclass.hβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žregexp_constants.hβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#define MAX_FOLD_FROMS 3
3030

3131
/* Generated from:
32-
* 6cbf3f0fc04bbb22420eb9689126b5030bd714ad06397d0904702714feabe28e lib/Unicode/UCD.pm
32+
* 198105a1b3637a4bc7240628bae2f65f6d0c31df2cee4f0242c2561421ea2e75 lib/Unicode/UCD.pm
3333
* 764f420cedfc8b43d9fec251c957a5d55fc45d40f6573f162990ed1dce7e36e0 lib/unicore/ArabicShaping.txt
3434
* b8f32554c6f658821fb0ee742d21c5b1f2086b9bf13071fed04894b022f93d67 lib/unicore/BidiBrackets.txt
3535
* d7afdadd1bbd66f5a663ac0e8f7958f18fd9491fc0bc59ec5877cb82db71db7d lib/unicore/BidiMirroring.txt

β€Žuni_keywords.hβ€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
Β (0)