Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdio Do not use thousands grouping when none is sp...



details:   https://anonhg.NetBSD.org/src/rev/9c38c77fe521
branches:  trunk
changeset: 825349:9c38c77fe521
user:      perseant <perseant%NetBSD.org@localhost>
date:      Mon Jul 10 22:49:40 2017 +0000

description:
Do not use thousands grouping when none is specified by the locale.
Fixes PR standards/52282.

diffstat:

 lib/libc/stdio/vfwprintf.c |  18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diffs (41 lines):

diff -r 8a7029b45116 -r 9c38c77fe521 lib/libc/stdio/vfwprintf.c
--- a/lib/libc/stdio/vfwprintf.c        Mon Jul 10 22:41:46 2017 +0000
+++ b/lib/libc/stdio/vfwprintf.c        Mon Jul 10 22:49:40 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfwprintf.c,v 1.34 2014/01/20 14:11:03 yamt Exp $      */
+/*     $NetBSD: vfwprintf.c,v 1.35 2017/07/10 22:49:40 perseant 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.34 2014/01/20 14:11:03 yamt Exp $");
+__RCSID("$NetBSD: vfwprintf.c,v 1.35 2017/07/10 22:49:40 perseant Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -923,15 +923,15 @@
                        sign = '+';
                        goto rflag;
                case '\'':
-                       flags |= GROUPING;
                        thousands_sep = *(localeconv_l(loc)->thousands_sep);
                        grouping = localeconv_l(loc)->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";
+                       /* Use grouping if defined by locale */
+                       if (thousands_sep && grouping && *grouping)
+                               flags |= GROUPING;
+                       else {
+                               thousands_sep = '\0';
+                               grouping = "";
+                       }
                        goto rflag;
                case '.':
                        if ((ch = *fmt++) == '*') {



Home | Main Index | Thread Index | Old Index