-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
locale: monetary: international currency formatting (POSIX.1-2008) #13975
Comments
From afresh1@openbsd.orgCreated by afresh1@openbsd.orgThis is a bug report for perl from afresh1@openbsd.org, ----------------------------------------------------------------- cc'd patch@cpan as his YAPC::NA talk made me think he might be Perl Info
|
From afresh1@openbsd.org0001-locale-monetary-international-currency-formatting-PO.patchFrom 30202bd55db05716dc9b23bdf616a85548a85a75 Mon Sep 17 00:00:00 2001
From: Martin Pelikan <pelikan@openbsd.org>
Date: Wed, 9 Jul 2014 03:30:00 -0700
Subject: [PATCH] locale: monetary: international currency formatting (POSIX.1-2008)
---
ext/POSIX/POSIX.xs | 22 ++++++++++++++--------
ext/POSIX/lib/POSIX.pod | 6 ++++++
ext/POSIX/t/posix.t | 4 +++-
3 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 371db1d..7deb5d8 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -331,14 +331,20 @@ const struct lconv_offset lconv_strings[] = {
const struct lconv_offset lconv_integers[] = {
#ifdef USE_LOCALE_MONETARY
- {"int_frac_digits", STRUCT_OFFSET(struct lconv, int_frac_digits)},
- {"frac_digits", STRUCT_OFFSET(struct lconv, frac_digits)},
- {"p_cs_precedes", STRUCT_OFFSET(struct lconv, p_cs_precedes)},
- {"p_sep_by_space", STRUCT_OFFSET(struct lconv, p_sep_by_space)},
- {"n_cs_precedes", STRUCT_OFFSET(struct lconv, n_cs_precedes)},
- {"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)},
+ {"int_frac_digits", STRUCT_OFFSET(struct lconv, int_frac_digits)},
+ {"frac_digits", STRUCT_OFFSET(struct lconv, frac_digits)},
+ {"p_cs_precedes", STRUCT_OFFSET(struct lconv, p_cs_precedes)},
+ {"p_sep_by_space", STRUCT_OFFSET(struct lconv, p_sep_by_space)},
+ {"n_cs_precedes", STRUCT_OFFSET(struct lconv, n_cs_precedes)},
+ {"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)},
+ {"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
{NULL, 0}
};
diff --git a/ext/POSIX/lib/POSIX.pod b/ext/POSIX/lib/POSIX.pod
index 61b0f71..39d3222 100644
--- a/ext/POSIX/lib/POSIX.pod
+++ b/ext/POSIX/lib/POSIX.pod
@@ -848,6 +848,12 @@ 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),
diff --git a/ext/POSIX/t/posix.t b/ext/POSIX/t/posix.t
index c2e4abe..d60dd70 100644
--- a/ext/POSIX/t/posix.t
+++ b/ext/POSIX/t/posix.t
@@ -344,7 +344,9 @@ 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)) {
+ n_cs_precedes 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)) {
SKIP: {
skip("localeconv has no result for $_", 1)
unless exists $conv->{$_};
--
1.9.3
|
From @khwilliamsonOn 07/09/2014 04:47 AM, (via RT) wrote:
I think we need a Configure probe to see if the platform supports these |
The RT System itself - Status changed from 'new' to 'open' |
From andrew@afresh1.comOn Wed, Jul 09, 2014 at 06:27:14AM -0700, karl williamson via RT wrote:
How does this look? |
From andrew@afresh1.com0001-locale-monetary-international-currency-formatting-PO.patchFrom bcae077cb912e777be66e348a59661e67fba376e Mon Sep 17 00:00:00 2001
From: Andrew Fresh <afresh1@openbsd.org>
Date: Wed, 9 Jul 2014 03:30:00 -0700
Subject: [PATCH] locale: monetary: international currency formatting
(POSIX.1-2008)
---
Configure | 23 +++++++++++++++++++++++
Cross/config.sh-arm-linux | 1 +
NetWare/config.wc | 1 +
Porting/config.sh | 1 +
config_h.SH | 6 ++++++
configure.com | 2 ++
ext/POSIX/POSIX.xs | 8 ++++++++
ext/POSIX/lib/POSIX.pod | 9 +++++++++
ext/POSIX/t/posix.t | 22 +++++++++++++++++++---
plan9/config_sh.sample | 1 +
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 +
17 files changed, 85 insertions(+), 5 deletions(-)
diff --git a/Configure b/Configure
index 620b7b5..1e31d4a 100755
--- a/Configure
+++ b/Configure
@@ -591,6 +591,7 @@ d_localtime_r=''
d_localtime_r_needs_tzset=''
localtime_r_proto=''
d_locconv=''
+d_lc_monetary_2008=''
d_lockf=''
d_longdbl=''
longdblsize=''
@@ -15578,6 +15579,27 @@ $rm_try
set localeconv d_locconv
eval $inlibc
+: see if localtime_r calls tzset
+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
@@ -23226,6 +23248,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 a5f612e..6409c01 100644
--- a/Cross/config.sh-arm-linux
+++ b/Cross/config.sh-arm-linux
@@ -298,6 +298,7 @@ d_isinf='define'
d_isnan='define'
d_isnanl='define'
d_killpg='define'
+d_lc_monetary_2008='undef'
d_lchown='define'
d_ldbl_dig='define'
d_libm_lib_version='define'
diff --git a/NetWare/config.wc b/NetWare/config.wc
index 9dcb1e4..eb124ab 100644
--- a/NetWare/config.wc
+++ b/NetWare/config.wc
@@ -287,6 +287,7 @@ d_isinf='undef'
d_isnan='undef'
d_isnanl='undef'
d_killpg='undef'
+d_lc_monetary_2008='undef'
d_lchown='undef'
d_ldbl_dig='define'
d_libm_lib_version='undef'
diff --git a/Porting/config.sh b/Porting/config.sh
index e66cab1..ce0a7d8 100644
--- a/Porting/config.sh
+++ b/Porting/config.sh
@@ -307,6 +307,7 @@ d_isinf='define'
d_isnan='define'
d_isnanl='define'
d_killpg='define'
+d_lc_monetary_2008='undef'
d_lchown='define'
d_ldbl_dig='define'
d_libm_lib_version='define'
diff --git a/config_h.SH b/config_h.SH
index db150a6..d649ebd 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 abea303..3a6d3bf 100644
--- a/configure.com
+++ b/configure.com
@@ -5386,6 +5386,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"
@@ -6066,6 +6067,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 371db1d..1071311 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -339,6 +339,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.pod b/ext/POSIX/lib/POSIX.pod
index 61b0f71..9780206 100644
--- a/ext/POSIX/lib/POSIX.pod
+++ b/ext/POSIX/lib/POSIX.pod
@@ -848,12 +848,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 c2e4abe..abd5a61 100644
--- a/ext/POSIX/t/posix.t
+++ b/ext/POSIX/t/posix.t
@@ -8,7 +8,7 @@ BEGIN {
}
}
-use Test::More tests => 109;
+use Test::More tests => 115;
use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write
errno localeconv dup dup2 lseek access);
@@ -343,8 +343,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 9608ceb..8fbf61c 100644
--- a/plan9/config_sh.sample
+++ b/plan9/config_sh.sample
@@ -298,6 +298,7 @@ d_isinf='undef'
d_isnan='undef'
d_isnanl='undef'
d_killpg='undef'
+d_lc_monetary_2008='undef'
d_lchown='undef'
d_ldbl_dig='define'
d_libm_lib_version='0'
diff --git a/symbian/config.sh b/symbian/config.sh
index d86c71e..23b965e 100644
--- a/symbian/config.sh
+++ b/symbian/config.sh
@@ -244,6 +244,7 @@ d_isinf='undef'
d_isnan='undef'
d_isnanl='undef'
d_killpg='undef'
+d_lc_monetary_2008='undef'
d_lchown='undef'
d_ldbl_dig='undef'
d_libm_lib_version='undef'
diff --git a/uconfig.h b/uconfig.h
index eb1839a..c7d66fa 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.
@@ -4742,6 +4748,6 @@
#endif
/* Generated from:
- * a37f46da5285428077feb313bcbe68661740bac16d76fa658d723d9fcc91c2c4 config_h.SH
- * 4b709c0b049c660c04c0932eaa8481f9ca6fdc697ec4ffaa86b7bef21ee886a8 uconfig.sh
+ * e29569c7c69ff9327a6b7476c0fbaf7ac89c787b90da92f46aada24f4855b2ac config_h.SH
+ * 1bf67494263a7ee3b689780d9c29dfd69cdfe4f51444da1347de27087150f380 uconfig.sh
* ex: set ro: */
diff --git a/uconfig.sh b/uconfig.sh
index e8df3c2..beadd3e 100644
--- a/uconfig.sh
+++ b/uconfig.sh
@@ -237,6 +237,7 @@ d_isinf='undef'
d_isnan='undef'
d_isnanl='undef'
d_killpg='undef'
+d_lc_monetary_2008='undef'
d_lchown='undef'
d_ldbl_dig='undef'
d_libm_lib_version='undef'
diff --git a/uconfig64.sh b/uconfig64.sh
index a4adccb..f6f066c 100644
--- a/uconfig64.sh
+++ b/uconfig64.sh
@@ -238,6 +238,7 @@ d_isinf='undef'
d_isnan='undef'
d_isnanl='undef'
d_killpg='undef'
+d_lc_monetary_2008='undef'
d_lchown='undef'
d_ldbl_dig='undef'
d_libm_lib_version='undef'
diff --git a/win32/config.ce b/win32/config.ce
index 0601162..754561a 100644
--- a/win32/config.ce
+++ b/win32/config.ce
@@ -285,6 +285,7 @@ d_isinf='undef'
d_isnan='define'
d_isnanl='undef'
d_killpg='undef'
+d_lc_monetary_2008='undef'
d_lchown='undef'
d_ldbl_dig='define'
d_libm_lib_version='undef'
diff --git a/win32/config.gc b/win32/config.gc
index 11b490e..d7f197f 100644
--- a/win32/config.gc
+++ b/win32/config.gc
@@ -285,6 +285,7 @@ d_isinf='undef'
d_isnan='define'
d_isnanl='undef'
d_killpg='define'
+d_lc_monetary_2008='undef'
d_lchown='undef'
d_ldbl_dig='define'
d_libm_lib_version='undef'
diff --git a/win32/config.vc b/win32/config.vc
index d4b0b83..a48c0ec 100644
--- a/win32/config.vc
+++ b/win32/config.vc
@@ -285,6 +285,7 @@ d_isinf='undef'
d_isnan='define'
d_isnanl='undef'
d_killpg='define'
+d_lc_monetary_2008='undef'
d_lchown='undef'
d_ldbl_dig='define'
d_libm_lib_version='undef'
--
1.9.3
|
From @khwilliamsonOn 07/10/2014 03:48 AM, Andrew Fresh wrote:
It looks pretty good to me. However, the person who does most of the |
From @TuxKarl Williamson schreef op 2014-07-14 06:06:
The initial comment looks bad: That is not what this is testing for And it is also missing a Glossary entry
|
From andrew@afresh1.comOn Mon, Jul 14, 2014 at 01:11:00AM -0700, H. Merijn Brand via RT wrote:
Will fix, copy/pasto. Doh!
How do I create that? The glossary claimed to be generated by l8rZ, I wish life had an UNDO function. |
From @TuxOn Tue, 29 Jul 2014 11:15:36 -0700, Andrew Fresh <andrew@afresh1.com>
Suggest a patch as you did before, but now also suggest the patch for I'll rework the into the files that generate Configure and the Glossary -- |
From @khwilliamsonOn 09/10/2014 09:47 PM, Andrew Fresh wrote:
p5p will deal with metaconfig. Sorry you wasted time on that. I haven't the time right now to look at your patch in detail. But I did |
From @khwilliamsonOn 09/11/2014 11:14 AM, Karl Williamson wrote:
This looks good to me. Tux, please see if the config part is ok with you? |
From @TuxOn Mon, 15 Sep 2014 13:34:29 -0600, Karl Williamson
It still needs some amendments It looks complete, which can be interpreted as a compliment! * the indentation in Glossary is wrong * minor nit case "$d_locconv:$d_lc_monetary_2008" in should be case "$d_locconv:$d_lc_monetary_2008" in Feel free to pick, I'll backport later (and make the fixes) -- |
From @khwilliamsonThanks, now in blead as -- |
@khwilliamson - Status changed from 'open' to 'pending release' |
From @khwilliamsonThanks for submitting this ticket The issue should be resolved with the release today of Perl v5.22. If you find that the problem persists, feel free to reopen this ticket -- |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#122252 (status was 'resolved')
Searchable as RT122252$
The text was updated successfully, but these errors were encountered: