Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src Pull up following revision(s) (requested by martin in tic...
details: https://anonhg.NetBSD.org/src/rev/936358acb41b
branches: netbsd-8
changeset: 434739:936358acb41b
user: bouyer <bouyer%NetBSD.org@localhost>
date: Wed Mar 14 18:37:00 2018 +0000
description:
Pull up following revision(s) (requested by martin in ticket #630):
lib/libc/stdio/vfwprintf.c: revision 1.35
lib/libc/stdio/vfwprintf.c: revision 1.36
tests/lib/libc/locale/t_sprintf.c: revision 1.2
Change t_sprintf to an expected failure, since we don't respect the empty
thousands separator of the C/POSIX locale (PR standards/52282).
Do not use thousands grouping when none is specified by the locale.
Fixes PR standards/52282.
A more correct fix for PR standards/52282.
diffstat:
lib/libc/stdio/vfwprintf.c | 18 +++++++-------
tests/lib/libc/locale/t_sprintf.c | 44 +++++++++++++++++++++++++++++---------
2 files changed, 42 insertions(+), 20 deletions(-)
diffs (132 lines):
diff -r 8b358b15d9cf -r 936358acb41b lib/libc/stdio/vfwprintf.c
--- a/lib/libc/stdio/vfwprintf.c Tue Mar 13 15:50:31 2018 +0000
+++ b/lib/libc/stdio/vfwprintf.c Wed Mar 14 18:37:00 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfwprintf.c,v 1.34 2014/01/20 14:11:03 yamt Exp $ */
+/* $NetBSD: vfwprintf.c,v 1.34.18.1 2018/03/14 18:37:00 bouyer 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.34.18.1 2018/03/14 18:37:00 bouyer 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 = NULL;
+ }
goto rflag;
case '.':
if ((ch = *fmt++) == '*') {
diff -r 8b358b15d9cf -r 936358acb41b tests/lib/libc/locale/t_sprintf.c
--- a/tests/lib/libc/locale/t_sprintf.c Tue Mar 13 15:50:31 2018 +0000
+++ b/tests/lib/libc/locale/t_sprintf.c Wed Mar 14 18:37:00 2018 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: t_sprintf.c,v 1.1 2017/05/30 23:44:02 perseant Exp $ */
+/* $NetBSD: t_sprintf.c,v 1.1.2.1 2018/03/14 18:37:00 bouyer Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
- * by Konrad Schroder
+ * by Konrad Schroder.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2017\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sprintf.c,v 1.1 2017/05/30 23:44:02 perseant Exp $");
+__RCSID("$NetBSD: t_sprintf.c,v 1.1.2.1 2018/03/14 18:37:00 bouyer Exp $");
#include <locale.h>
#include <stdio.h>
@@ -53,14 +53,6 @@
const char *double_input;
} tests[] = {
{
- "C",
- -12345,
- "-12,345",
- "-12345",
- -12345.6789,
- "-12,345.678900",
- "-12345.678900",
- }, {
"en_US.UTF-8",
-12345,
"-12,345",
@@ -77,6 +69,30 @@
"-12\240345,678900",
"-12345,678900",
}, {
+ "it_IT.ISO8859-1",
+ -12345,
+ "-12.345",
+ "-12345",
+ -12345.6789,
+ "-12.345,678900",
+ "-12345,678900",
+ }, {
+ "POSIX",
+ /*
+ * POSIX-1.2008 specifies that the C and POSIX
+ * locales shall be identical (section 7.2) and
+ * that the POSIX locale shall have an empty
+ * thousands separator and "<period>" as its
+ * decimal point (section 7.3.4). *printf
+ * ought to honor these settings.
+ */
+ -12345,
+ "-12345",
+ "-12345",
+ -12345.6789,
+ "-12345.678900",
+ "-12345.678900",
+ }, {
NULL,
0,
NULL,
@@ -95,12 +111,18 @@
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
printf("Trying locale %s...\n", t->locale);
ATF_REQUIRE(setlocale(LC_NUMERIC, t->locale) != NULL);
+ printf("Using locale: %s\n", setlocale(LC_ALL, NULL));
+
+ if (!strcmp("POSIX", t->locale))
+ atf_tc_expect_fail("%s", "PR standards/52282, printf doesn't respect empty thousands separator");
sprintf(buf, "%'f", t->double_value);
ATF_REQUIRE_STREQ(buf, t->double_result);
sprintf(buf, "%'d", t->int_value);
ATF_REQUIRE_STREQ(buf, t->int_result);
+
+ atf_tc_expect_pass();
}
static void
Home |
Main Index |
Thread Index |
Old Index