Module Name:    src
Committed By:   dsl
Date:           Wed Aug  5 20:46:01 UTC 2009

Modified Files:
        src/lib/libc/stdio: vfwprintf.c

Log Message:
If the current locale doesn't define the 'thousands' grouping info
then use sane defaults (',' every 3 digits).
Fixes PR/40714


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/stdio/vfwprintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdio/vfwprintf.c
diff -u src/lib/libc/stdio/vfwprintf.c:1.15 src/lib/libc/stdio/vfwprintf.c:1.16
--- src/lib/libc/stdio/vfwprintf.c:1.15	Fri Feb 20 09:23:37 2009
+++ src/lib/libc/stdio/vfwprintf.c	Wed Aug  5 20:46:01 2009
@@ -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 @@
 			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++) == '*') {

Reply via email to