summaryrefslogtreecommitdiff
path: root/libc/stdio/printf.c
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2002-11-03 21:00:15 +0000
committerManuel Novoa III <mjn3@codepoet.org>2002-11-03 21:00:15 +0000
commit94314dec1eef25cefca3c19db08aaa9b8c7026c3 (patch)
treeb28547b9f518c00f9d7c3085de68ec0bea59718d /libc/stdio/printf.c
parent868df46adcf4637aadd773cbe42521ef980370b2 (diff)
It was easy enough to respect locale-specific decimal point for printf
floating point output, so at least implement that. But grouping will have to wait for the rewrite of _dtostr.
Diffstat (limited to 'libc/stdio/printf.c')
-rw-r--r--libc/stdio/printf.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/libc/stdio/printf.c b/libc/stdio/printf.c
index d08ac56b0..88f248a75 100644
--- a/libc/stdio/printf.c
+++ b/libc/stdio/printf.c
@@ -418,8 +418,6 @@ size_t parse_printf_format(register const char *template,
* In other words, we don't currently support glibc's 'I' flag.
* We do accept it, but it is currently ignored. */
-/* TODO -- Implement grouping flag... on hold (locale support). */
-
int vfprintf(FILE * __restrict stream, register const char * __restrict format,
va_list arg)
{
@@ -1792,6 +1790,15 @@ static const char *fmts[] = {
};
/*****************************************************************************/
+#include <locale.h>
+
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning REMINDER: implement grouping for floating point
+#endif
+
+#ifndef __LOCALE_C_ONLY
+#define CUR_LOCALE (__global_locale)
+#endif /* __LOCALE_C_ONLY */
size_t _dtostr(FILE * fp, long double x, struct printf_info *info)
{
@@ -2014,9 +2021,15 @@ size_t _dtostr(FILE * fp, long double x, struct printf_info *info)
if (PRINT_INFO_FLAG_VAL(info,alt)
/* flag[FLAG_HASH] */
|| (i) || ((o_mode != 'g') && (preci > 0))) {
+#ifdef __LOCALE_C_ONLY
*pdrvr++ = 2; /* need decimal */
*ppc++ = 1; /* needed for width calc */
ppc++;
+#else /* __LOCALE_C_ONLY */
+ *pdrvr++ = 1;
+ *ppc++ = strlen(CUR_LOCALE.decimal_point);
+ *ppc++ = (INT_OR_PTR)(CUR_LOCALE.decimal_point);
+#endif /* __LOCALE_C_ONLY */
}
if (++o_exp < 0) { /* have 0s right of decimal */