summaryrefslogtreecommitdiff
path: root/locale.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2022-11-25 14:49:05 -0700
committerKarl Williamson <khw@cpan.org>2022-11-30 17:42:46 -0700
commit04de0222db2c455e25ec09919a16dd3550a2c9f2 (patch)
tree554c68209a69eaf16ec65d3a7c545180077cfc84 /locale.c
parentf42fb42da6158a7aa9310d4aa8a8db32e526d6b4 (diff)
downloadperl-04de0222db2c455e25ec09919a16dd3550a2c9f2.tar.gz
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.
Diffstat (limited to 'locale.c')
-rw-r--r--locale.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/locale.c b/locale.c
index 5a6ad85f4b..1da054470e 100644
--- a/locale.c
+++ b/locale.c
@@ -3496,7 +3496,7 @@ S_populate_localeconv(pTHX_ const struct lconv *lcbuf,
while (strings->name) {
const char *value = *((const char **)(ptr + strings->offset));
- if (value && *value) {
+ if (value) {
bool is_utf8 = /* Only make UTF-8 if required to */
(UTF8NESS_YES == (get_locale_string_utf8ness_i(locale,
cat_index,
@@ -3516,8 +3516,7 @@ S_populate_localeconv(pTHX_ const struct lconv *lcbuf,
while (integers->name) {
const char value = *((const char *)(ptr + integers->offset));
- if (value != CHAR_MAX)
- (void) hv_store(retval, integers->name,
+ (void) hv_store(retval, integers->name,
strlen(integers->name), newSViv(value), 0);
integers++;
}