summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/vfwprintf.c
diff options
context:
space:
mode:
authordsl <dsl@NetBSD.org>2009-08-05 20:46:01 +0000
committerdsl <dsl@NetBSD.org>2009-08-05 20:46:01 +0000
commitf687cf7e680a7a7283db2daaeb1300c2adbef63d (patch)
treeb10474aa91a53eca60c857d8158b0c80f4a418ed /lib/libc/stdio/vfwprintf.c
parentbba2c41d59b8de336d95739b54c80ef71799b749 (diff)
If the current locale doesn't define the 'thousands' grouping info
then use sane defaults (',' every 3 digits). Fixes PR/40714
Diffstat (limited to 'lib/libc/stdio/vfwprintf.c')
-rw-r--r--lib/libc/stdio/vfwprintf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c
index caf642f5975..2abb8fa7278 100644
--- a/lib/libc/stdio/vfwprintf.c
+++ b/lib/libc/stdio/vfwprintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfwprintf.c,v 1.15 2009/02/20 09:23:37 roy Exp $ */
+/* $NetBSD: vfwprintf.c,v 1.16 2009/08/05 20:46:01 dsl Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
__FBSDID("$FreeBSD: src/lib/libc/stdio/vfwprintf.c,v 1.27 2007/01/09 00:28:08 imp Exp $");
#else
-__RCSID("$NetBSD: vfwprintf.c,v 1.15 2009/02/20 09:23:37 roy Exp $");
+__RCSID("$NetBSD: vfwprintf.c,v 1.16 2009/08/05 20:46:01 dsl Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -897,6 +897,12 @@ reswitch: switch (ch) {
flags |= GROUPING;
thousands_sep = *(localeconv()->thousands_sep);
grouping = localeconv()->grouping;
+ /* If the locale doesn't define the above, use sane
+ * defaults - otherwise silly things happen! */
+ if (thousands_sep == 0)
+ thousands_sep = ',';
+ if (!grouping || !*grouping)
+ grouping = "\3";
goto rflag;
case '.':
if ((ch = *fmt++) == '*') {