From 04de0222db2c455e25ec09919a16dd3550a2c9f2 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Fri, 25 Nov 2022 14:49:05 -0700 Subject: POSIX::localeconv: Return empty/special values This function returns a hash allowing Perl access to the localeconv() data structure, with the keys being the structure's field names, and the values being their corresponding value in the current locale. Prior to this commit, it did not populate the hash with: 1) any string-valued keys whose value is the empty string 2) any numeric-valued keys whose value is the special value CHAR_MAX This is wrong. localeconv() should return a complete list of fields on the platform, regardless of their values. Someone may well wish to iterate over all the keys in the hash. CHAR_MAX just indicates special handling is required for that numeric field. And all string fields legally can be empty, except for the decimal point. For example, the symbol indicating a number is positive is empty in many locales. I couldn't find a reason in the history why these have been omitted. --- ext/POSIX/t/posix.t | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'ext') diff --git a/ext/POSIX/t/posix.t b/ext/POSIX/t/posix.t index f200a895bd..117fa5e138 100644 --- a/ext/POSIX/t/posix.t +++ b/ext/POSIX/t/posix.t @@ -373,10 +373,9 @@ SKIP: { currency_symbol mon_decimal_point mon_thousands_sep mon_grouping positive_sign negative_sign)) { SKIP: { - skip("localeconv has no result for $_", 1) - unless exists $conv->{$_}; - unlike(delete $conv->{$_}, qr/\A\z/, - "localeconv returned a non-empty string for $_"); + my $value = delete $conv->{$_}; + skip("localeconv '$_' may be empty", 1) if $_ ne 'decimal_point'; + isnt($value, "", "localeconv returned a non-empty string for $_"); } } @@ -399,8 +398,6 @@ SKIP: { foreach (@lconv) { SKIP: { - skip("localeconv has no result for $_", 1) - unless exists $conv->{$_}; like(delete $conv->{$_}, qr/\A-?\d+\z/, "localeconv returned an integer for $_"); } -- cgit v1.2.1