diff options
author | Karl Williamson <khw@cpan.org> | 2022-11-25 14:49:05 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-11-30 17:42:46 -0700 |
commit | 04de0222db2c455e25ec09919a16dd3550a2c9f2 (patch) | |
tree | 554c68209a69eaf16ec65d3a7c545180077cfc84 /locale.c | |
parent | f42fb42da6158a7aa9310d4aa8a8db32e526d6b4 (diff) | |
download | perl-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.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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++; } |