In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/b15c1b561a4d9a6ec5ecdf68b69fda7ef7d09cb7?hp=c774046ba1377cc500a8a8fd88aa3cf810aad808>
- Log ----------------------------------------------------------------- commit b15c1b561a4d9a6ec5ecdf68b69fda7ef7d09cb7 Author: Andrew Fresh <[email protected]> Date: Wed Jul 9 03:30:00 2014 -0700 PATCH: [perl #122252] international currency formatting (POSIX.1-2008) Add the new portions of locale currency formatting that are specified in POSIX.1-2008 The commiter (Karl Williamson) made the trivial indentation changes asked for by H. Merijn Brand, and added a perldelta entry ----------------------------------------------------------------------- Summary of changes: Configure | 23 +++++++++++++++++++++++ Cross/config.sh-arm-linux | 1 + NetWare/config.wc | 1 + Porting/Glossary | 5 +++++ Porting/config.sh | 1 + config_h.SH | 6 ++++++ configure.com | 2 ++ ext/POSIX/POSIX.xs | 8 ++++++++ ext/POSIX/lib/POSIX.pm | 2 +- ext/POSIX/lib/POSIX.pod | 9 +++++++++ ext/POSIX/t/posix.t | 22 +++++++++++++++++++--- plan9/config_sh.sample | 1 + pod/perldelta.pod | 15 +++++++++++++++ symbian/config.sh | 1 + uconfig.h | 10 ++++++++-- uconfig.sh | 1 + uconfig64.sh | 1 + win32/config.ce | 1 + win32/config.gc | 1 + win32/config.vc | 1 + 20 files changed, 106 insertions(+), 6 deletions(-) diff --git a/Configure b/Configure index 343e062..95909f2 100755 --- a/Configure +++ b/Configure @@ -600,6 +600,7 @@ d_localtime_r='' d_localtime_r_needs_tzset='' localtime_r_proto='' d_locconv='' +d_lc_monetary_2008='' d_lockf='' d_ldexpl='' d_longdbl='' @@ -15928,6 +15929,27 @@ $rm_try set localeconv d_locconv eval $inlibc +: see if libc has the POSIX.1-2008 currency locale rules +case "$d_locconv:$d_lc_monetary_2008" in + $define:) + $cat >try.c <<EOCP +#include <locale.h> +int main() { + struct lconv *lc = localeconv(); + char int_p_cs_precedes = lc->int_p_cs_precedes; + return 0; +} +EOCP + set try + if eval $compile; then + d_lc_monetary_2008="$define" + else + d_lc_monetary_2008="$undef" + fi; + $rm_try + ;; +esac + : see if lockf exists set lockf d_lockf eval $inlibc @@ -23656,6 +23678,7 @@ d_localtime64='$d_localtime64' d_localtime_r='$d_localtime_r' d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset' d_locconv='$d_locconv' +d_lc_monetary_2008='$d_lc_monetary_2008' d_lockf='$d_lockf' d_longdbl='$d_longdbl' d_longlong='$d_longlong' diff --git a/Cross/config.sh-arm-linux b/Cross/config.sh-arm-linux index 48b1d87..69220aa 100644 --- a/Cross/config.sh-arm-linux +++ b/Cross/config.sh-arm-linux @@ -307,6 +307,7 @@ d_isnanl='define' d_j0='define' d_j0l='define' d_killpg='define' +d_lc_monetary_2008='undef' d_lchown='define' d_ldbl_dig='define' d_ldexpl='define' diff --git a/NetWare/config.wc b/NetWare/config.wc index 1407c44..6e19e53 100644 --- a/NetWare/config.wc +++ b/NetWare/config.wc @@ -296,6 +296,7 @@ d_isnanl='undef' d_j0='undef' d_j0l='undef' d_killpg='undef' +d_lc_monetary_2008='undef' d_lchown='undef' d_ldbl_dig='define' d_ldexpl='undef' diff --git a/Porting/Glossary b/Porting/Glossary index e28bb56..32b29e2 100644 --- a/Porting/Glossary +++ b/Porting/Glossary @@ -1362,6 +1362,11 @@ d_killpg (d_killpg.U): indicates to the C program that the killpg() routine is available to kill process groups. +d_lc_monetary_2008 (d_lc_monetary_2008.U): + This variable conditionally defines HAS_LC_MONETARY_2008 if libc + has the international currency locale rules from POSIX + 1003.1-2008. + d_lchown (d_lchown.U): This variable conditionally defines the HAS_LCHOWN symbol, which indicates to the C program that the lchown() routine is available diff --git a/Porting/config.sh b/Porting/config.sh index cb85168..18ac740 100644 --- a/Porting/config.sh +++ b/Porting/config.sh @@ -316,6 +316,7 @@ d_isnanl='define' d_j0='undef' d_j0l='undef' d_killpg='define' +d_lc_monetary_2008='undef' d_lchown='define' d_ldbl_dig='define' d_ldexpl='define' diff --git a/config_h.SH b/config_h.SH index 7aae94f..5b26b94 100755 --- a/config_h.SH +++ b/config_h.SH @@ -261,6 +261,12 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un */ #$d_locconv HAS_LOCALECONV /**/ +/* HAS_LC_MONETARY_2008: + * This symbol, if defined, indicates that the localeconv routine is + * available and has the additional members added in POSIX 1003.1-2008. + */ +#$d_lc_monetary_2008 HAS_LC_MONETARY_2008 /**/ + /* HAS_LOCKF: * This symbol, if defined, indicates that the lockf routine is * available to do file locking. diff --git a/configure.com b/configure.com index 0bb1a75..2128bdd 100644 --- a/configure.com +++ b/configure.com @@ -5398,6 +5398,7 @@ $ vms_cc_type="decc" $ ENDIF $ d_faststdio="define" $ d_locconv="define" +$ d_lc_monetary_2008="define" $ d_mblen="define" $ d_mbstowcs="define" $ d_mbtowc="define" @@ -6095,6 +6096,7 @@ $ WC "d_link='" + d_link + "'" $ WC "d_llseek='undef'" $ WC "d_localtime64='undef'" $ WC "d_locconv='" + d_locconv + "'" +$ WC "d_lc_monetary_2008='" + d_lc_monetary_2008 + "'" $ WC "d_lockf='undef'" $ WC "d_longdbl='" + d_longdbl + "'" $ WC "d_longlong='" + d_longlong + "'" diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index dcda631..d84db98 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -1218,6 +1218,14 @@ const struct lconv_offset lconv_integers[] = { {"n_sep_by_space", STRUCT_OFFSET(struct lconv, n_sep_by_space)}, {"p_sign_posn", STRUCT_OFFSET(struct lconv, p_sign_posn)}, {"n_sign_posn", STRUCT_OFFSET(struct lconv, n_sign_posn)}, +#ifdef HAS_LC_MONETARY_2008 + {"int_p_cs_precedes", STRUCT_OFFSET(struct lconv, int_p_cs_precedes)}, + {"int_p_sep_by_space", STRUCT_OFFSET(struct lconv, int_p_sep_by_space)}, + {"int_n_cs_precedes", STRUCT_OFFSET(struct lconv, int_n_cs_precedes)}, + {"int_n_sep_by_space", STRUCT_OFFSET(struct lconv, int_n_sep_by_space)}, + {"int_p_sign_posn", STRUCT_OFFSET(struct lconv, int_p_sign_posn)}, + {"int_n_sign_posn", STRUCT_OFFSET(struct lconv, int_n_sign_posn)}, +#endif #endif {NULL, 0} }; diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm index 0b236d2..be1f097 100644 --- a/ext/POSIX/lib/POSIX.pm +++ b/ext/POSIX/lib/POSIX.pm @@ -4,7 +4,7 @@ use warnings; our ($AUTOLOAD, %SIGRT); -our $VERSION = '1.43'; +our $VERSION = '1.44'; require XSLoader; diff --git a/ext/POSIX/lib/POSIX.pod b/ext/POSIX/lib/POSIX.pod index 82bc213..1030540 100644 --- a/ext/POSIX/lib/POSIX.pod +++ b/ext/POSIX/lib/POSIX.pod @@ -1036,12 +1036,21 @@ Here is how to query the database for the B<de> (Deutsch or German) locale. n_sep_by_space p_sign_posn n_sign_posn + int_p_cs_precedes + int_p_sep_by_space + int_n_cs_precedes + int_n_sep_by_space + int_p_sign_posn + int_n_sign_posn )) { printf qq(%s: "%s",\n), $property, $lconv->{$property}; } +int_p_* and int_n_* members added by POSIX.1-2008 are only available on +systems that support them. + =item C<localtime> This is identical to Perl's builtin C<localtime()> function for diff --git a/ext/POSIX/t/posix.t b/ext/POSIX/t/posix.t index da4aba8..398928c 100644 --- a/ext/POSIX/t/posix.t +++ b/ext/POSIX/t/posix.t @@ -8,7 +8,7 @@ BEGIN { } } -use Test::More tests => 111; +use Test::More tests => 117; use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write errno localeconv dup dup2 lseek access); @@ -359,8 +359,24 @@ SKIP: { } } - foreach (qw(int_frac_digits frac_digits p_cs_precedes p_sep_by_space - n_cs_precedes n_sep_by_space p_sign_posn n_sign_posn)) { + my @lconv = qw( + int_frac_digits frac_digits + p_cs_precedes p_sep_by_space + n_cs_precedes n_sep_by_space + p_sign_posn n_sign_posn + ); + + SKIP: { + skip('No HAS_LC_MONETARY_2008', 6) unless $Config{d_lc_monetary_2008}; + + push @lconv, qw( + int_p_cs_precedes int_p_sep_by_space + int_n_cs_precedes int_n_sep_by_space + int_p_sign_posn int_n_sign_posn + ); + } + + foreach (@lconv) { SKIP: { skip("localeconv has no result for $_", 1) unless exists $conv->{$_}; diff --git a/plan9/config_sh.sample b/plan9/config_sh.sample index 8b32a82..30012ce 100644 --- a/plan9/config_sh.sample +++ b/plan9/config_sh.sample @@ -307,6 +307,7 @@ d_isnanl='undef' d_j0='undef' d_j0l='undef' d_killpg='undef' +d_lc_monetary_2008='undef' d_lchown='undef' d_ldbl_dig='define' d_ldexpl='undef' diff --git a/pod/perldelta.pod b/pod/perldelta.pod index b9a97c2..608c1df 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -27,6 +27,21 @@ here, but most should go in the L</Performance Enhancements> section. [ List each enhancement as a =head2 entry ] +=head2 Perl now supports POSIX 2008 locale currency additions. + +On platforms that are able to handle POSIX.1-2008, the +hash returned by +L<C<POSIX::localeconv()>|perllocale/The localeconv function> +includes the international currency fields added by that version of the +POSIX standard. These are +C<int_n_cs_precedes>, +C<int_n_sep_by_space>, +C<int_n_sign_posn>, +C<int_p_cs_precedes>, +C<int_p_sep_by_space>, +and +C<int_p_sign_posn>. + =head1 Security XXX Any security-related notices go here. In particular, any security diff --git a/symbian/config.sh b/symbian/config.sh index 193b8db..7496ae9 100644 --- a/symbian/config.sh +++ b/symbian/config.sh @@ -253,6 +253,7 @@ d_isnanl='undef' d_j0='undef' d_j0l='undef' d_killpg='undef' +d_lc_monetary_2008='undef' d_lchown='undef' d_ldbl_dig='undef' d_ldexpl='undef' diff --git a/uconfig.h b/uconfig.h index 81d5e06..dc6690e 100644 --- a/uconfig.h +++ b/uconfig.h @@ -226,6 +226,12 @@ */ /*#define HAS_LOCALECONV / **/ +/* HAS_LC_MONETARY_2008: + * This symbol, if defined, indicates that the localeconv routine is + * available and has the additional members added in POSIX 1003.1-2008. + */ +/*#define HAS_LC_MONETARY_2008 / **/ + /* HAS_LOCKF: * This symbol, if defined, indicates that the lockf routine is * available to do file locking. @@ -4865,6 +4871,6 @@ #endif /* Generated from: - * d7da79ac72d2191d6814ec98688e342f20eba70c64292c2e0b6b5622cdf3b6e6 config_h.SH - * a3cd0b705a952f6915cc1424cc116d4183481f54ba9605415baf93bc57e12122 uconfig.sh + * 74bb96b6e7b18b5b5f121da4f2849cd5521bb55ff62d63970fedb9a7ebd80f63 config_h.SH + * 35023b2d9244ad2dc3abea4bb5174a7f66398b60266231cb9a2c3bfc8df867cf uconfig.sh * ex: set ro: */ diff --git a/uconfig.sh b/uconfig.sh index 0341bda..d4199cd 100644 --- a/uconfig.sh +++ b/uconfig.sh @@ -246,6 +246,7 @@ d_isnanl='undef' d_j0='undef' d_j0l='undef' d_killpg='undef' +d_lc_monetary_2008='undef' d_lchown='undef' d_ldbl_dig='undef' d_ldexpl='undef' diff --git a/uconfig64.sh b/uconfig64.sh index 00fa9d0..c575a4e 100644 --- a/uconfig64.sh +++ b/uconfig64.sh @@ -247,6 +247,7 @@ d_isnanl='undef' d_j0='undef' d_j0l='undef' d_killpg='undef' +d_lc_monetary_2008='undef' d_lchown='undef' d_ldbl_dig='undef' d_ldexpl='undef' diff --git a/win32/config.ce b/win32/config.ce index e1083af..37be642 100644 --- a/win32/config.ce +++ b/win32/config.ce @@ -294,6 +294,7 @@ d_isnanl='undef' d_j0='undef' d_j0l='undef' d_killpg='undef' +d_lc_monetary_2008='undef' d_lchown='undef' d_ldbl_dig='define' d_ldexpl='undef' diff --git a/win32/config.gc b/win32/config.gc index d83ab2a..3451f11 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -294,6 +294,7 @@ d_isnanl='undef' d_j0='undef' d_j0l='undef' d_killpg='define' +d_lc_monetary_2008='undef' d_lchown='undef' d_ldbl_dig='define' d_ldexpl='undef' diff --git a/win32/config.vc b/win32/config.vc index 454ff88..7819916 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -294,6 +294,7 @@ d_isnanl='undef' d_j0='undef' d_j0l='undef' d_killpg='define' +d_lc_monetary_2008='undef' d_lchown='undef' d_ldbl_dig='define' d_ldexpl='undef' -- Perl5 Master Repository
