Add support for the 6 new C99 struct lconv members dealing with formatting
international monetary values: int_p_cs_precedes, int_n_cs_precedes, int_p_sep_by_space, int_n_sep_by_space, int_p_sign_posn, int_n_sign_posn. This should not break existing binaries or LC_MONETARY data files. Reviewed by: ache MFC after: 1 month
This commit is contained in:
parent
16c1138c89
commit
f4da1a754d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=104711
@ -56,6 +56,12 @@ struct lconv {
|
|||||||
char n_sep_by_space;
|
char n_sep_by_space;
|
||||||
char p_sign_posn;
|
char p_sign_posn;
|
||||||
char n_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
|
#ifndef NULL
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "lmonetary.h"
|
#include "lmonetary.h"
|
||||||
#include "ldpart.h"
|
#include "ldpart.h"
|
||||||
@ -55,7 +56,13 @@ static const struct lc_monetary_T _C_monetary_locale = {
|
|||||||
numempty, /* n_cs_precedes */
|
numempty, /* n_cs_precedes */
|
||||||
numempty, /* n_sep_by_space */
|
numempty, /* n_sep_by_space */
|
||||||
numempty, /* p_sign_posn */
|
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;
|
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,
|
ret = __part_load_locale(name, &_monetary_using_locale,
|
||||||
_monetary_locale_buf, "LC_MONETARY",
|
_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);
|
(const char **)&_monetary_locale);
|
||||||
if (ret != _LDP_ERROR)
|
if (ret != _LDP_ERROR)
|
||||||
__mlocale_changed = 1;
|
__mlocale_changed = 1;
|
||||||
@ -98,6 +107,27 @@ __monetary_load_locale(const char *name)
|
|||||||
M_ASSIGN_CHAR(n_sep_by_space);
|
M_ASSIGN_CHAR(n_sep_by_space);
|
||||||
M_ASSIGN_CHAR(p_sign_posn);
|
M_ASSIGN_CHAR(p_sign_posn);
|
||||||
M_ASSIGN_CHAR(n_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);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,12 @@ struct lc_monetary_T {
|
|||||||
const char *n_sep_by_space;
|
const char *n_sep_by_space;
|
||||||
const char *p_sign_posn;
|
const char *p_sign_posn;
|
||||||
const char *n_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);
|
struct lc_monetary_T *__get_current_monetary_locale(void);
|
||||||
|
@ -85,6 +85,12 @@ localeconv()
|
|||||||
M_ASSIGN_CHAR(n_sep_by_space);
|
M_ASSIGN_CHAR(n_sep_by_space);
|
||||||
M_ASSIGN_CHAR(p_sign_posn);
|
M_ASSIGN_CHAR(p_sign_posn);
|
||||||
M_ASSIGN_CHAR(n_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;
|
__mlocale_changed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
.\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93
|
.\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd June 9, 1993
|
.Dd October 5, 2002
|
||||||
.Dt SETLOCALE 3
|
.Dt SETLOCALE 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -163,6 +163,12 @@ struct lconv {
|
|||||||
char n_sep_by_space;
|
char n_sep_by_space;
|
||||||
char p_sign_posn;
|
char p_sign_posn;
|
||||||
char n_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
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
@ -249,6 +255,30 @@ Just after
|
|||||||
Like
|
Like
|
||||||
.Fa p_sign_posn
|
.Fa p_sign_posn
|
||||||
but for negative currency values.
|
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
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
Unless mentioned above,
|
Unless mentioned above,
|
||||||
@ -311,7 +341,7 @@ The
|
|||||||
and
|
and
|
||||||
.Fn localeconv
|
.Fn localeconv
|
||||||
functions conform to
|
functions conform to
|
||||||
.St -isoC .
|
.St -isoC-99 .
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
The
|
The
|
||||||
.Fn setlocale
|
.Fn setlocale
|
||||||
|
Loading…
Reference in New Issue
Block a user