From 4f42d1192c252e8a5d5d0a5fee4cb4f7d61a0e2b Mon Sep 17 00:00:00 2001 From: pelikan Date: Mon, 14 Jul 2014 07:22:06 +0000 Subject: [PATCH] international currency locale rules as per POSIX.1-2008 required for libc++ ok guenther afresh1 --- gnu/usr.bin/perl/ext/POSIX/POSIX.xs | 6 +++++ gnu/usr.bin/perl/ext/POSIX/lib/POSIX.pod | 6 +++++ gnu/usr.bin/perl/ext/POSIX/t/posix.t | 4 ++- include/locale.h | 8 +++++- lib/libc/locale/_def_monetary.c | 12 +++++++-- lib/libc/locale/localeconv.c | 8 +++++- lib/libc/locale/setlocale.3 | 34 ++++++++++++++++++++++-- sys/sys/localedef.h | 8 +++++- 8 files changed, 78 insertions(+), 8 deletions(-) diff --git a/gnu/usr.bin/perl/ext/POSIX/POSIX.xs b/gnu/usr.bin/perl/ext/POSIX/POSIX.xs index 745cc90c14e..fa1ff5df53c 100644 --- a/gnu/usr.bin/perl/ext/POSIX/POSIX.xs +++ b/gnu/usr.bin/perl/ext/POSIX/POSIX.xs @@ -505,6 +505,12 @@ const struct lconv_offset lconv_integers[] = { {"n_sep_by_space", offsetof(struct lconv, n_sep_by_space)}, {"p_sign_posn", offsetof(struct lconv, p_sign_posn)}, {"n_sign_posn", offsetof(struct lconv, n_sign_posn)}, + {"int_p_cs_precedes", offsetof(struct lconv, int_p_cs_precedes)}, + {"int_p_sep_by_space", offsetof(struct lconv, int_p_sep_by_space)}, + {"int_n_cs_precedes", offsetof(struct lconv, int_n_cs_precedes)}, + {"int_n_sep_by_space", offsetof(struct lconv, int_n_sep_by_space)}, + {"int_p_sign_posn", offsetof(struct lconv, int_p_sign_posn)}, + {"int_n_sign_posn", offsetof(struct lconv, int_n_sign_posn)}, {NULL, 0} }; diff --git a/gnu/usr.bin/perl/ext/POSIX/lib/POSIX.pod b/gnu/usr.bin/perl/ext/POSIX/lib/POSIX.pod index 7141b873f79..5271a213ae3 100644 --- a/gnu/usr.bin/perl/ext/POSIX/lib/POSIX.pod +++ b/gnu/usr.bin/perl/ext/POSIX/lib/POSIX.pod @@ -752,6 +752,12 @@ Here is how to query the database for the B (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}; diff --git a/gnu/usr.bin/perl/ext/POSIX/t/posix.t b/gnu/usr.bin/perl/ext/POSIX/t/posix.t index 88fe2ca0d94..d7064470028 100644 --- a/gnu/usr.bin/perl/ext/POSIX/t/posix.t +++ b/gnu/usr.bin/perl/ext/POSIX/t/posix.t @@ -331,7 +331,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->{$_}; diff --git a/include/locale.h b/include/locale.h index 80f82b65c25..3ce65c56104 100644 --- a/include/locale.h +++ b/include/locale.h @@ -1,4 +1,4 @@ -/* $OpenBSD: locale.h,v 1.8 2011/07/03 18:51:01 jsg Exp $ */ +/* $OpenBSD: locale.h,v 1.9 2014/07/14 07:22:07 pelikan Exp $ */ /* $NetBSD: locale.h,v 1.6 1994/10/26 00:56:02 cgd Exp $ */ /* @@ -54,6 +54,12 @@ struct lconv { char n_sep_by_space; char p_sign_posn; char n_sign_posn; + char int_p_cs_precedes; + char int_p_sep_by_space; + char int_n_cs_precedes; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; }; #ifndef NULL diff --git a/lib/libc/locale/_def_monetary.c b/lib/libc/locale/_def_monetary.c index aa92c75d111..c050020ee4a 100644 --- a/lib/libc/locale/_def_monetary.c +++ b/lib/libc/locale/_def_monetary.c @@ -1,4 +1,4 @@ -/* $OpenBSD: _def_monetary.c,v 1.4 2005/08/08 08:05:35 espie Exp $ */ +/* $OpenBSD: _def_monetary.c,v 1.5 2014/07/14 07:22:07 pelikan Exp $ */ /* * Written by J.T. Conklin . * Public domain. @@ -19,12 +19,20 @@ const _MonetaryLocale _DefaultMonetaryLocale = "", CHAR_MAX, CHAR_MAX, + + CHAR_MAX, /* local p_cs_precedes */ + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + + CHAR_MAX, /* intl p_cs_precedes */ CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, - CHAR_MAX }; const _MonetaryLocale *_CurrentMonetaryLocale = &_DefaultMonetaryLocale; diff --git a/lib/libc/locale/localeconv.c b/lib/libc/locale/localeconv.c index 989eb4bca65..8421fa3d953 100644 --- a/lib/libc/locale/localeconv.c +++ b/lib/libc/locale/localeconv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: localeconv.c,v 1.5 2005/08/08 08:05:35 espie Exp $ */ +/* $OpenBSD: localeconv.c,v 1.6 2014/07/14 07:22:07 pelikan Exp $ */ /* * Written by J.T. Conklin . * Public domain. @@ -44,6 +44,12 @@ localeconv(void) ret.n_sep_by_space = _CurrentMonetaryLocale->n_sep_by_space; ret.p_sign_posn = _CurrentMonetaryLocale->p_sign_posn; ret.n_sign_posn = _CurrentMonetaryLocale->n_sign_posn; + ret.int_p_cs_precedes = _CurrentMonetaryLocale->int_p_cs_precedes; + ret.int_p_sep_by_space = _CurrentMonetaryLocale->int_p_sep_by_space; + ret.int_n_cs_precedes = _CurrentMonetaryLocale->int_n_cs_precedes; + ret.int_n_sep_by_space = _CurrentMonetaryLocale->int_n_sep_by_space; + ret.int_p_sign_posn = _CurrentMonetaryLocale->int_p_sign_posn; + ret.int_n_sign_posn = _CurrentMonetaryLocale->int_n_sign_posn; __mlocale_changed = 0; } diff --git a/lib/libc/locale/setlocale.3 b/lib/libc/locale/setlocale.3 index b570f19331d..6836da5a860 100644 --- a/lib/libc/locale/setlocale.3 +++ b/lib/libc/locale/setlocale.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: setlocale.3,v 1.14 2013/06/05 03:39:22 tedu Exp $ +.\" $OpenBSD: setlocale.3,v 1.15 2014/07/14 07:22:07 pelikan Exp $ .\" $NetBSD: setlocale.3,v 1.3 1997/07/14 23:19:47 kleink Exp $ .\" .\" Copyright (c) 1993 @@ -33,7 +33,7 @@ .\" .\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93 .\" -.Dd $Mdocdate: June 5 2013 $ +.Dd $Mdocdate: July 14 2014 $ .Dt SETLOCALE 3 .Os .Sh NAME @@ -150,6 +150,12 @@ struct lconv { char n_sep_by_space; char p_sign_posn; char n_sign_posn; + char int_p_cs_precedes; + char int_p_sep_by_space; + char int_n_cs_precedes; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; }; .Ed .Pp @@ -236,6 +242,30 @@ Just after Like .Fa p_sign_posn but for negative currency values. +.It Fa int_p_cs_precedes +Like +.Fa p_cs_precedes +but for the international symbol. +.It Fa int_n_cs_precedes +Like +.Fa n_cs_precedes +but for the international symbol. +.It Fa int_p_sep_by_space +Like +.Fa p_sep_by_space +but for the international symbol. +.It Fa int_n_sep_by_space +Like +.Fa n_sep_by_space +but for the international symbol. +.It Fa int_p_sign_posn +Like +.Fa p_sign_posn +but for the international symbol. +.It Fa int_n_sign_posn +Like +.Fa n_sign_posn +but for the international symbol. .El .Pp Unless mentioned above, diff --git a/sys/sys/localedef.h b/sys/sys/localedef.h index b6b5eb1af90..af45025157b 100644 --- a/sys/sys/localedef.h +++ b/sys/sys/localedef.h @@ -1,4 +1,4 @@ -/* $OpenBSD: localedef.h,v 1.3 1996/04/21 22:31:47 deraadt Exp $ */ +/* $OpenBSD: localedef.h,v 1.4 2014/07/14 07:22:07 pelikan Exp $ */ /* $NetBSD: localedef.h,v 1.4 1996/04/09 20:55:31 cgd Exp $ */ /* @@ -66,6 +66,12 @@ typedef struct char n_sep_by_space; char p_sign_posn; char n_sign_posn; + char int_p_cs_precedes; + char int_p_sep_by_space; + char int_n_cs_precedes; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; } _MonetaryLocale; extern const _MonetaryLocale *_CurrentMonetaryLocale; -- 2.20.1