diff --git a/include/locale.h b/include/locale.h index 8b6ad4d65c74..2477db4a3af4 100644 --- a/include/locale.h +++ b/include/locale.h @@ -56,6 +56,12 @@ struct lconv { char n_sep_by_space; char p_sign_posn; char n_sign_posn; + char int_p_cs_precedes; + char int_n_cs_precedes; + char int_p_sep_by_space; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; }; #ifndef NULL diff --git a/lib/libc/locale/lmonetary.c b/lib/libc/locale/lmonetary.c index 3dc6df0884a7..ad751f27ee6a 100644 --- a/lib/libc/locale/lmonetary.c +++ b/lib/libc/locale/lmonetary.c @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include "lmonetary.h" #include "ldpart.h" @@ -55,7 +56,13 @@ static const struct lc_monetary_T _C_monetary_locale = { numempty, /* n_cs_precedes */ numempty, /* n_sep_by_space */ numempty, /* p_sign_posn */ - numempty /* n_sign_posn */ + numempty, /* n_sign_posn */ + numempty, /* int_p_cs_precedes */ + numempty, /* int_n_cs_precedes */ + numempty, /* int_p_sep_by_space */ + numempty, /* int_n_sep_by_space */ + numempty, /* int_p_sign_posn */ + numempty /* int_n_sign_posn */ }; static struct lc_monetary_T _monetary_locale; @@ -79,7 +86,9 @@ __monetary_load_locale(const char *name) ret = __part_load_locale(name, &_monetary_using_locale, _monetary_locale_buf, "LC_MONETARY", - LCMONETARY_SIZE, LCMONETARY_SIZE, + LCMONETARY_SIZE, + offsetof(struct lc_monetary_T, int_p_cs_precedes) / + sizeof(char *), (const char **)&_monetary_locale); if (ret != _LDP_ERROR) __mlocale_changed = 1; @@ -98,6 +107,27 @@ __monetary_load_locale(const char *name) M_ASSIGN_CHAR(n_sep_by_space); M_ASSIGN_CHAR(p_sign_posn); M_ASSIGN_CHAR(n_sign_posn); + + /* + * The six additional C99 international monetary formatting + * parameters default to the national parameters when + * reading FreeBSD 4 LC_MONETARY data files. + */ +#define M_ASSIGN_ICHAR(NAME) \ + do { \ + if (_monetary_locale.int_##NAME == NULL) \ + _monetary_locale.int_##NAME = \ + _monetary_locale.NAME; \ + else \ + M_ASSIGN_CHAR(int_##NAME); \ + } while (0) + + M_ASSIGN_ICHAR(p_cs_precedes); + M_ASSIGN_ICHAR(n_cs_precedes); + M_ASSIGN_ICHAR(p_sep_by_space); + M_ASSIGN_ICHAR(n_sep_by_space); + M_ASSIGN_ICHAR(p_sign_posn); + M_ASSIGN_ICHAR(n_sign_posn); } return (ret); } diff --git a/lib/libc/locale/lmonetary.h b/lib/libc/locale/lmonetary.h index d32689793922..45ec3235b578 100644 --- a/lib/libc/locale/lmonetary.h +++ b/lib/libc/locale/lmonetary.h @@ -45,6 +45,12 @@ struct lc_monetary_T { const char *n_sep_by_space; const char *p_sign_posn; const char *n_sign_posn; + const char *int_p_cs_precedes; + const char *int_n_cs_precedes; + const char *int_p_sep_by_space; + const char *int_n_sep_by_space; + const char *int_p_sign_posn; + const char *int_n_sign_posn; }; struct lc_monetary_T *__get_current_monetary_locale(void); diff --git a/lib/libc/locale/localeconv.c b/lib/libc/locale/localeconv.c index 804e9fdad08e..d10ba1f97427 100644 --- a/lib/libc/locale/localeconv.c +++ b/lib/libc/locale/localeconv.c @@ -85,6 +85,12 @@ localeconv() M_ASSIGN_CHAR(n_sep_by_space); M_ASSIGN_CHAR(p_sign_posn); M_ASSIGN_CHAR(n_sign_posn); + M_ASSIGN_CHAR(int_p_cs_precedes); + M_ASSIGN_CHAR(int_n_cs_precedes); + M_ASSIGN_CHAR(int_p_sep_by_space); + M_ASSIGN_CHAR(int_n_sep_by_space); + M_ASSIGN_CHAR(int_p_sign_posn); + M_ASSIGN_CHAR(int_n_sign_posn); __mlocale_changed = 0; } diff --git a/lib/libc/locale/setlocale.3 b/lib/libc/locale/setlocale.3 index a1bb367bd7b1..75808672a823 100644 --- a/lib/libc/locale/setlocale.3 +++ b/lib/libc/locale/setlocale.3 @@ -35,7 +35,7 @@ .\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd June 9, 1993 +.Dd October 5, 2002 .Dt SETLOCALE 3 .Os .Sh NAME @@ -163,6 +163,12 @@ struct lconv { char n_sep_by_space; char p_sign_posn; char n_sign_posn; + char int_p_cs_precedes; + char int_n_cs_precedes; + char int_p_sep_by_space; + char int_n_sep_by_space; + char int_p_sign_posn; + char int_n_sign_posn; }; .Ed .Pp @@ -249,6 +255,30 @@ Just after Like .Fa p_sign_posn but for negative currency values. +.It Fa int_p_cs_precedes +Same as +.Fa p_cs_precedes , +but for internationally formatted monetary quantities. +.It Fa int_n_cs_precedes +Same as +.Fa n_cs_precedes , +but for internationally formatted monetary quantities. +.It Fa int_p_sep_by_space +Same as +.Fa p_sep_by_space , +but for internationally formatted monetary quantities. +.It Fa int_n_sep_by_space +Same as +.Fa n_sep_by_space , +but for internationally formatted monetary quantities. +.It Fa int_p_sign_posn +Same as +.Fa p_sign_posn , +but for internationally formatted monetary quantities. +.It Fa int_n_sign_posn +Same as +.Fa n_sign_posn , +but for internationally formatted monetary quantities. .El .Pp Unless mentioned above, @@ -311,7 +341,7 @@ The and .Fn localeconv functions conform to -.St -isoC . +.St -isoC-99 . .Sh HISTORY The .Fn setlocale