CVS commit: src/tests/lib/libc/locale

2017-12-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Dec  7 22:23:14 UTC 2017

Modified Files:
src/tests/lib/libc/locale: t_strfmon.c

Log Message:
Update this test to expect the output that is supposed to be produced
by strfmon() rather than the output the old buggy implementation used
to produce.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_strfmon.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_strfmon.c
diff -u src/tests/lib/libc/locale/t_strfmon.c:1.1 src/tests/lib/libc/locale/t_strfmon.c:1.2
--- src/tests/lib/libc/locale/t_strfmon.c:1.1	Wed Aug 16 13:53:20 2017
+++ src/tests/lib/libc/locale/t_strfmon.c	Thu Dec  7 22:23:14 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strfmon.c,v 1.1 2017/08/16 13:53:20 joerg Exp $ */
+/* $NetBSD: t_strfmon.c,v 1.2 2017/12/07 22:23:14 kre Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_strfmon.c,v 1.1 2017/08/16 13:53:20 joerg Exp $");
+__RCSID("$NetBSD: t_strfmon.c,v 1.2 2017/12/07 22:23:14 kre Exp $");
 
 #include 
 #include 
@@ -50,9 +50,9 @@ ATF_TC_BODY(strfmon, tc)
 		const char *locale;
 		const char *expected;
 	} tests[] = {
-	{ "C", "[**1234.57] [**1234.57]" },
-	{ "de_DE.UTF-8", "[ **1234,57 €] [ **1.234,57 EUR ]" },
-	{ "en_GB.UTF-8", "[ £**1234.57] [ GBP **1,234.57]" },
+	{ "C", "[ **1234.57] [ **1234.57]" },
+	{ "de_DE.UTF-8", "[ **1234,57 €] [ **1.234,57 EUR]" },
+	{ "en_GB.UTF-8", "[ £**1234.57] [ GBP**1,234.57]" },
 	};
 	locale_t loc;
 	size_t i;



CVS commit: src/tests/lib/libc/locale

2017-11-30 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Dec  1 01:08:35 UTC 2017

Modified Files:
src/tests/lib/libc/locale: t_sprintf.c

Log Message:
Since the C standard allows for intermediate floating results to contain
more precision bits than the data type expects, but (kind of obviously)
does not allow such values to be stored in memory, expecting the value
returned from strtod() (an intermediate result) to be identical (that is,
equal) to a stored value is incorrect.

So instead go back to checking that the two numbers are very very close.
See comments added to the test for more explanation.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/locale/t_sprintf.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_sprintf.c
diff -u src/tests/lib/libc/locale/t_sprintf.c:1.6 src/tests/lib/libc/locale/t_sprintf.c:1.7
--- src/tests/lib/libc/locale/t_sprintf.c:1.6	Tue Nov 28 23:26:01 2017
+++ src/tests/lib/libc/locale/t_sprintf.c	Fri Dec  1 01:08:35 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sprintf.c,v 1.6 2017/11/28 23:26:01 kre Exp $ */
+/* $NetBSD: t_sprintf.c,v 1.7 2017/12/01 01:08:35 kre Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2017\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sprintf.c,v 1.6 2017/11/28 23:26:01 kre Exp $");
+__RCSID("$NetBSD: t_sprintf.c,v 1.7 2017/12/01 01:08:35 kre Exp $");
 
 #include 
 #include 
@@ -133,16 +133,44 @@ h_strto(const struct test *t)
 	ATF_REQUIRE(setlocale(LC_NUMERIC, t->locale) != NULL);
 
 	ATF_REQUIRE_EQ((int)strtol(t->int_input, NULL, 10), t->int_value);
-	d = strtod(t->double_input, NULL);
+
+	/*
+	 * Note that the C standard permits function values to be
+	 * returned with more precision than is expected by (floating)
+	 * data types, and on i386 (and potentially other implementations)
+	 * that is exactly what happens, meaning that the result from
+	 * strtod() is not identical to the expected value - it turns out
+	 * that it is the same if the value is constrained to the number
+	 * of mantissa bits in a double (so the %a values printed below
+	 * show the exact same bit patterns) and on i386 -ffloat-store
+	 * will cause gcc to constrain the result that way, but nothing
+	 * demands that be true, so instead, we simply test that the
+	 * value returned is very very close to that expected.
+	 *
+	 * 1e-12 is chosen as the allowable delta, as we know (from
+	 * the data in the "struct test" earlier in this file) that
+	 * its magnitude is ~ 10^5, with values of that magnitude,
+	 * 10^-12 difference is a 10^-17 relative difference, and
+	 * with a 56 bit mantissa (standard IEEE "double") a difference
+	 * that small vanishes (requires at least 57 mantissa bits to
+	 * be representable).   If the data values were to change, then
+	 * so might this delta (if they were not all the same, we would
+	 * move the delta into the struct rather than having it a constant
+	 * here.).
+	 *
+	 * Finally, note that our purpose here is not to test floating
+	 * point arithmetic, we're testing locale dependent string to
+	 * binary conversions.
+	 */
+
+	d = (double)strtod(t->double_input, NULL);
 	diff = fabs(d - t->double_value);
-#if 0
-	if (diff >= 1e-7)
-#endif
-		ATF_REQUIRE_EQ_MSG(d, t->double_value, "In %s:"
-		" d=strtod(t->double_input[%s], NULL)[%.12g = %a] !="
-		" t->double_value[%.12g = %a]: diff=%g",
-		t->locale, t->double_input, d, d,
-		t->double_value, t->double_value, diff);
+	if (diff >= 1e-12)
+		ATF_REQUIRE_EQ_MSG(d, t->double_value, "In %s: " 
+		"d=strtod(t->double_input[%s], NULL)[%.12g = %a] != "
+		"t->double_value[%.12g = %a]: diff=%g", t->locale,
+		t->double_input, d, d, t->double_value, t->double_value,
+		diff);
 }
 
 static void



CVS commit: src/tests/lib/libc/locale

2017-11-28 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Nov 28 23:26:01 UTC 2017

Modified Files:
src/tests/lib/libc/locale: t_sprintf.c

Log Message:
Revert 1.4 (perhaps temporarily) and add even more diagnostics to those
added in 1.3 to see if it is possible to determine why the strict equality
test fails on i386, yet succeeds elsewhere.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/locale/t_sprintf.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_sprintf.c
diff -u src/tests/lib/libc/locale/t_sprintf.c:1.5 src/tests/lib/libc/locale/t_sprintf.c:1.6
--- src/tests/lib/libc/locale/t_sprintf.c:1.5	Fri Nov 24 21:30:43 2017
+++ src/tests/lib/libc/locale/t_sprintf.c	Tue Nov 28 23:26:01 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sprintf.c,v 1.5 2017/11/24 21:30:43 kre Exp $ */
+/* $NetBSD: t_sprintf.c,v 1.6 2017/11/28 23:26:01 kre Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2017\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sprintf.c,v 1.5 2017/11/24 21:30:43 kre Exp $");
+__RCSID("$NetBSD: t_sprintf.c,v 1.6 2017/11/28 23:26:01 kre Exp $");
 
 #include 
 #include 
@@ -134,11 +134,15 @@ h_strto(const struct test *t)
 
 	ATF_REQUIRE_EQ((int)strtol(t->int_input, NULL, 10), t->int_value);
 	d = strtod(t->double_input, NULL);
-	if ((diff = fabs(d - t->double_value)) > 1e-7)
-		ATF_REQUIRE_EQ_MSG(d, t->double_value, "In %s: d=strtod("
-		"t->double_input[%s], NULL)[%.9g] != t->double_value[%.9g]"
-		": diff=%g", t->locale, t->double_input, d,
-		t->double_value, diff);
+	diff = fabs(d - t->double_value);
+#if 0
+	if (diff >= 1e-7)
+#endif
+		ATF_REQUIRE_EQ_MSG(d, t->double_value, "In %s:"
+		" d=strtod(t->double_input[%s], NULL)[%.12g = %a] !="
+		" t->double_value[%.12g = %a]: diff=%g",
+		t->locale, t->double_input, d, d,
+		t->double_value, t->double_value, diff);
 }
 
 static void



CVS commit: src/tests/lib/libc/locale

2017-11-24 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Nov 24 21:30:43 UTC 2017

Modified Files:
src/tests/lib/libc/locale: t_sprintf.c

Log Message:
When comparing doubles (any floating point values) which have been
computed using different methods, don't expect to achieve identical
results (here, one constant is perhaps converted to binary from a string by
a cross compiler, the other is converted at run time).   Allow them to
have a small difference (for now, small is < 1e-7 - the constant is ~ 1e5,
so this is 12 orders of magnitude less) before failing (and include the
actual difference in the error message if it does fail.)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/locale/t_sprintf.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_sprintf.c
diff -u src/tests/lib/libc/locale/t_sprintf.c:1.4 src/tests/lib/libc/locale/t_sprintf.c:1.5
--- src/tests/lib/libc/locale/t_sprintf.c:1.4	Thu Nov 23 23:47:09 2017
+++ src/tests/lib/libc/locale/t_sprintf.c	Fri Nov 24 21:30:43 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sprintf.c,v 1.4 2017/11/23 23:47:09 kre Exp $ */
+/* $NetBSD: t_sprintf.c,v 1.5 2017/11/24 21:30:43 kre Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,9 +32,10 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2017\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sprintf.c,v 1.4 2017/11/23 23:47:09 kre Exp $");
+__RCSID("$NetBSD: t_sprintf.c,v 1.5 2017/11/24 21:30:43 kre Exp $");
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -125,7 +126,7 @@ h_sprintf(const struct test *t)
 static void
 h_strto(const struct test *t)
 {
-	double d;
+	double d, diff;
 
 	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
 	printf("Trying locale %s...\n", t->locale);
@@ -133,9 +134,11 @@ h_strto(const struct test *t)
 
 	ATF_REQUIRE_EQ((int)strtol(t->int_input, NULL, 10), t->int_value);
 	d = strtod(t->double_input, NULL);
-	ATF_REQUIRE_EQ_MSG(d, t->double_value, "In %s: "
-	"strtod(t->double_input[%s], NULL)[%g] != t->double_value[%g]",
-	t->locale, t->double_input, d, t->double_value);
+	if ((diff = fabs(d - t->double_value)) > 1e-7)
+		ATF_REQUIRE_EQ_MSG(d, t->double_value, "In %s: d=strtod("
+		"t->double_input[%s], NULL)[%.9g] != t->double_value[%.9g]"
+		": diff=%g", t->locale, t->double_input, d,
+		t->double_value, diff);
 }
 
 static void



CVS commit: src/tests/lib/libc/locale

2017-08-10 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Thu Aug 10 19:08:43 UTC 2017

Modified Files:
src/tests/lib/libc/locale: t_btowc.c

Log Message:
Separate the C/POSIX locale test from the rest; make it more thorough
and more correct.  This fixes a problem reported by martin@ when the
test is compiled with -funsigned-char.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/locale/t_btowc.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_btowc.c
diff -u src/tests/lib/libc/locale/t_btowc.c:1.2 src/tests/lib/libc/locale/t_btowc.c:1.3
--- src/tests/lib/libc/locale/t_btowc.c:1.2	Wed Jul 12 17:32:51 2017
+++ src/tests/lib/libc/locale/t_btowc.c	Thu Aug 10 19:08:43 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_btowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $ */
+/* $NetBSD: t_btowc.c,v 1.3 2017/08/10 19:08:43 perseant Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2017\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_btowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $");
+__RCSID("$NetBSD: t_btowc.c,v 1.3 2017/08/10 19:08:43 perseant Exp $");
 
 #include 
 #include 
@@ -52,13 +52,6 @@ struct test {
 	const wchar_t willegal[8]; /* ISO-10646 that do not map into charset */
 } tests[] = {
 	{
-		"C",
-		"\377",
-		"ABC123@\t",
-		{ 'A', 'B', 'C', '1', '2', '3', '@', '\t' },
-		{ 0x0430, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
-	},
-	{
 		"en_US.UTF-8",
 		"\200",
 		"ABC123@\t",
@@ -193,9 +186,39 @@ ATF_TC_BODY(stdc_iso_10646, tc)
 #endif /* ! __STDC_ISO_10646__ */
 }
 
+ATF_TC(btowc_posix);
+ATF_TC_HEAD(btowc_posix, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Checks btowc(3) and wctob(3) for POSIX locale");
+}
+ATF_TC_BODY(btowc_posix, tc)
+{
+	const char *cp;
+	unsigned char c;
+	char *str;
+	const wchar_t *wcp;
+	int i;
+
+	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "POSIX"), "POSIX");
+
+	/* btowc(EOF) -> WEOF */
+	ATF_REQUIRE_EQ(btowc(EOF), WEOF);
+
+	/* wctob(WEOF) -> EOF */
+	ATF_REQUIRE_EQ(wctob(WEOF), EOF);
+
+	/* All characters from 0 to 255, inclusive, map
+	   onto their unsigned char equivalent */
+	for (i = 0; i <= 255; i++) {
+		ATF_REQUIRE_EQ(btowc(i), (wchar_t)(unsigned char)(i));
+		ATF_REQUIRE_EQ((unsigned char)wctob(i), (wchar_t)i);
+	}
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, btowc);
+	ATF_TP_ADD_TC(tp, btowc_posix);
 	ATF_TP_ADD_TC(tp, stdc_iso_10646);
 
 	return atf_no_error();



CVS commit: src/tests/lib/libc/locale

2017-07-14 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Jul 14 14:09:53 UTC 2017

Modified Files:
src/tests/lib/libc/locale: t_wcstod.c

Log Message:
VAX doesn't have the test cases, so stub the body as well.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/locale/t_wcstod.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_wcstod.c
diff -u src/tests/lib/libc/locale/t_wcstod.c:1.4 src/tests/lib/libc/locale/t_wcstod.c:1.5
--- src/tests/lib/libc/locale/t_wcstod.c:1.4	Wed Jul 12 17:32:51 2017
+++ src/tests/lib/libc/locale/t_wcstod.c	Fri Jul 14 14:09:53 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wcstod.c,v 1.4 2017/07/12 17:32:51 perseant Exp $ */
+/* $NetBSD: t_wcstod.c,v 1.5 2017/07/14 14:09:53 joerg Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_wcstod.c,v 1.4 2017/07/12 17:32:51 perseant Exp $");
+__RCSID("$NetBSD: t_wcstod.c,v 1.5 2017/07/14 14:09:53 joerg Exp $");
 
 #include 
 #include 
@@ -392,6 +392,7 @@ ATF_TC_HEAD(wcstombs, tc)
 }
 ATF_TC_BODY(wcstombs, tc)
 {
+#if !defined(__vax__)
 	struct test *t;
 	size_t n;
 	char *buf;
@@ -411,6 +412,7 @@ ATF_TC_BODY(wcstombs, tc)
 		
 		free(buf);
 	}
+#endif
 }
 
 ATF_TC(wcstod);



CVS commit: src/tests/lib/libc/locale

2017-07-12 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Wed Jul 12 17:32:51 UTC 2017

Modified Files:
src/tests/lib/libc/locale: t_btowc.c t_io.c t_mbrtowc.c t_mbstowcs.c
t_sprintf.c t_wcstod.c t_wctomb.c t_wctype.c

Log Message:
Add ISO10646 versions of these tests, conditional on __STDC_ISO_10646__ .
Also make the tests a bit more verbose, to aid debugging when they fail.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_btowc.c \
src/tests/lib/libc/locale/t_mbrtowc.c \
src/tests/lib/libc/locale/t_mbstowcs.c \
src/tests/lib/libc/locale/t_wctype.c
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/locale/t_io.c \
src/tests/lib/libc/locale/t_wctomb.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/locale/t_sprintf.c
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/locale/t_wcstod.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_btowc.c
diff -u src/tests/lib/libc/locale/t_btowc.c:1.1 src/tests/lib/libc/locale/t_btowc.c:1.2
--- src/tests/lib/libc/locale/t_btowc.c:1.1	Thu Jun  1 15:45:02 2017
+++ src/tests/lib/libc/locale/t_btowc.c	Wed Jul 12 17:32:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_btowc.c,v 1.1 2017/06/01 15:45:02 perseant Exp $ */
+/* $NetBSD: t_btowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,11 +32,12 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2017\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_btowc.c,v 1.1 2017/06/01 15:45:02 perseant Exp $");
+__RCSID("$NetBSD: t_btowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $");
 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -85,18 +86,28 @@ static void
 h_iso10646(struct test *t)
 {
 	const char *cp;
-	unsigned char c;
+	int c, wc;
 	char *str;
 	const wchar_t *wcp;
 
+	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
+	printf("Trying locale: %s\n", t->locale);
+	ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
+	ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL);
+	(void)printf("Using locale: %s\n", str);
+
 	/* These should have valid wchar representations */
 	for (cp = t->legal, wcp = t->wlegal; *cp != '\0'; ++cp, ++wcp) {
-		c = (unsigned char)*cp;
+		c = (int)(unsigned char)*cp;
 		printf("Checking legal character 0x%x\n", c);
+		wc = btowc(c);
+
+		if (errno != 0)
+			printf(" btowc() failed with errno=%d\n", errno);
 
 		/* It should map to the known Unicode equivalent */
 		printf("btowc(0x%2.2x) = 0x%x, expecting 0x%x\n",
-			c, btowc(c), *wcp);
+		   c, wc, *wcp);
 		ATF_REQUIRE(btowc(c) == *wcp);
 	}
 
@@ -120,6 +131,8 @@ h_btowc(struct test *t)
 	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
 	printf("Trying locale: %s\n", t->locale);
 	ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
+	ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL);
+	(void)printf("Using locale: %s\n", str);
 
 	/* btowc(EOF) -> WEOF */
 	ATF_REQUIRE_EQ(btowc(EOF), WEOF);
Index: src/tests/lib/libc/locale/t_mbrtowc.c
diff -u src/tests/lib/libc/locale/t_mbrtowc.c:1.1 src/tests/lib/libc/locale/t_mbrtowc.c:1.2
--- src/tests/lib/libc/locale/t_mbrtowc.c:1.1	Fri Jul 15 07:35:21 2011
+++ src/tests/lib/libc/locale/t_mbrtowc.c	Wed Jul 12 17:32:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mbrtowc.c,v 1.1 2011/07/15 07:35:21 jruoho Exp $ */
+/* $NetBSD: t_mbrtowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_mbrtowc.c,v 1.1 2011/07/15 07:35:21 jruoho Exp $");
+__RCSID("$NetBSD: t_mbrtowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $");
 
 #include 
 #include 
@@ -98,19 +98,31 @@ static struct test {
 }, {
 	"ja_JP.ISO2022-JP2",
 	"\033$BF|K\1348l\033(BA\033$B$\"\033(BB\033$B$$\033(B",
+#ifdef __STDC_ISO_10646__
+	{ 0x65E5, 0x672C, 0x8A9E, 0x41, 0x3042, 0x42, 0x3044 },
+#else
 	{ 0x4200467c, 0x42004b5c, 0x4200386c, 0x41, 0x42002422, 0x42, 0x42002424 },
+#endif
 	{ 5, 2, 2, 4, 5, 4, 5 },
 	7
 }, {
 	"ja_JP.SJIS",
 	"\223\372\226{\214\352A\202\240B\202\242",
-	{ 0x93fa, 0x967b, 0x8cea, 0x41, 0x82a0, 0x42, 0x82a2 },
+#ifdef __STDC_ISO_10646__
+	{ 0x65E5, 0x672C, 0x8A9E, 0x41, 0x3042, 0x42, 0x3044 },
+#else
+	{ 0x93FA, 0x967B, 0x8CEA, 0x41, 0x82A0, 0x42, 0x82A2 },
+#endif
 	{ 2, 2, 2, 1, 2, 1, 2 },
 	7
 }, {
 	"ja_JP.eucJP",
 	"\306\374\313\334\270\354A\244\242B\244\244",
-	{ 0xc6fc, 0xcbdc, 0xb8ec, 0x41, 0xa4a2, 0x42, 0xa4a4 },
+#ifdef __STDC_ISO_10646__
+	{ 0x65E5, 0x672C, 0x8A9E, 0x41, 0x3042, 0x42, 0x3044 },
+#else
+	{ 0xC6FC, 0xCBDC, 0xB8EC, 0x41, 0xA4A2, 0x42, 0xA4A4 },
+#endif
 	{ 2, 2, 2, 1, 2, 1, 2 },
 	7
 }, {
@@ -146,6 +158,8 @@ h_ctype2(const struct test *t, bool use_
 //	mbrtowc(0, 0, 0, ); /* XXX for ISO2022-JP */
 	stp = use_mbstate ?  : 0;
 
+	printf("First using 

CVS commit: src/tests/lib/libc/locale

2017-06-07 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Wed Jun  7 22:59:42 UTC 2017

Modified Files:
src/tests/lib/libc/locale: t_sprintf.c

Log Message:
Change t_sprintf to an expected failure, since we don't respect the empty
thousands separator of the C/POSIX locale (PR standards/52282).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_sprintf.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_sprintf.c
diff -u src/tests/lib/libc/locale/t_sprintf.c:1.1 src/tests/lib/libc/locale/t_sprintf.c:1.2
--- src/tests/lib/libc/locale/t_sprintf.c:1.1	Tue May 30 23:44:02 2017
+++ src/tests/lib/libc/locale/t_sprintf.c	Wed Jun  7 22:59:42 2017
@@ -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.2 2017/06/07 22:59:42 perseant 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 
 __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.2 2017/06/07 22:59:42 perseant Exp $");
 
 #include 
 #include 
@@ -53,14 +53,6 @@ static struct test {
 	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 @@ static struct test {
 		"-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 "" 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 @@ h_sprintf(const struct test *t)
 	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



CVS commit: src/tests/lib/libc/locale

2017-05-30 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Tue May 30 23:44:02 UTC 2017

Modified Files:
src/tests/lib/libc/locale: Makefile
Added Files:
src/tests/lib/libc/locale: t_digittoint.c t_sprintf.c t_wctype.c

Log Message:
Add test cases for sprintf/sscanf/strto{d,l} and the is* and isw* ctype 
functions, for single-byte encodings


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/locale/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/locale/t_digittoint.c \
src/tests/lib/libc/locale/t_sprintf.c \
src/tests/lib/libc/locale/t_wctype.c

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

Modified files:

Index: src/tests/lib/libc/locale/Makefile
diff -u src/tests/lib/libc/locale/Makefile:1.7 src/tests/lib/libc/locale/Makefile:1.8
--- src/tests/lib/libc/locale/Makefile:1.7	Tue May 30 02:11:03 2017
+++ src/tests/lib/libc/locale/Makefile	Tue May 30 23:44:02 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2017/05/30 02:11:03 perseant Exp $
+# $NetBSD: Makefile,v 1.8 2017/05/30 23:44:02 perseant Exp $
 
 .include 
 
@@ -15,6 +15,9 @@ TESTS_C+=	t_wcstod
 TESTS_C+=	t_wctomb
 TESTS_C+=	t_io
 TESTS_C+=	t_toupper
+#TESTS_C+=	t_digittoint
+TESTS_C+=	t_sprintf
+TESTS_C+=	t_wctype
 
 COPTS.t_wctomb.c += -Wno-stack-protector
 

Added files:

Index: src/tests/lib/libc/locale/t_digittoint.c
diff -u /dev/null src/tests/lib/libc/locale/t_digittoint.c:1.1
--- /dev/null	Tue May 30 23:44:02 2017
+++ src/tests/lib/libc/locale/t_digittoint.c	Tue May 30 23:44:02 2017
@@ -0,0 +1,101 @@
+/* $NetBSD: t_digittoint.c,v 1.1 2017/05/30 23:44:02 perseant 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
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__COPYRIGHT("@(#) Copyright (c) 2017\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_digittoint.c,v 1.1 2017/05/30 23:44:02 perseant Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static struct test {
+	const char *locale;
+	const char *digits;
+} tests[] = {
+	{
+		"C",
+		"0123456789AbcDeF",
+	}, {
+		"en_US.UTF-8",
+		"0123456789AbcDeF",
+	}, {
+		"ru_RU.KOI-8",
+		"0123456789AbcDeF",
+	}, {
+		NULL,
+		NULL,
+	}
+};
+
+static void
+h_digittoint(const struct test *t)
+{
+	int i;
+
+	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
+	printf("Trying locale %s...\n", t->locale);
+	ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
+
+	for (i = 0; i < 16; i++) {
+		printf(" char %2.2x in position %d\n", t->digits[i], i);
+		ATF_REQUIRE_EQ(digittoint(t->digits[i]), i);
+	}
+}
+
+ATF_TC(digittoint);
+
+ATF_TC_HEAD(digittoint, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+		"Checks digittoint under diferent locales");
+}
+
+ATF_TC_BODY(digittoint, tc)
+{
+	struct test *t;
+
+	for (t = [0]; t->locale != NULL; ++t)
+		h_digittoint(t);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+	ATF_TP_ADD_TC(tp, digittoint);
+
+	return atf_no_error();
+}
Index: src/tests/lib/libc/locale/t_sprintf.c
diff -u /dev/null src/tests/lib/libc/locale/t_sprintf.c:1.1
--- /dev/null	Tue May 30 23:44:02 2017
+++ src/tests/lib/libc/locale/t_sprintf.c	Tue May 30 23:44:02 2017
@@ -0,0 +1,183 @@
+/* $NetBSD: t_sprintf.c,v 1.1 2017/05/30 23:44:02 perseant 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
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are 

CVS commit: src/tests/lib/libc/locale

2017-05-29 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Tue May 30 02:11:03 UTC 2017

Modified Files:
src/tests/lib/libc/locale: Makefile
Added Files:
src/tests/lib/libc/locale: t_toupper.c

Log Message:
Add simple test case for toupper/tolower


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/locale/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/locale/t_toupper.c

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

Modified files:

Index: src/tests/lib/libc/locale/Makefile
diff -u src/tests/lib/libc/locale/Makefile:1.6 src/tests/lib/libc/locale/Makefile:1.7
--- src/tests/lib/libc/locale/Makefile:1.6	Tue May 28 16:57:56 2013
+++ src/tests/lib/libc/locale/Makefile	Tue May 30 02:11:03 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.6 2013/05/28 16:57:56 joerg Exp $
+# $NetBSD: Makefile,v 1.7 2017/05/30 02:11:03 perseant Exp $
 
 .include 
 
@@ -14,6 +14,7 @@ TESTS_C+=	t_wcsspn
 TESTS_C+=	t_wcstod
 TESTS_C+=	t_wctomb
 TESTS_C+=	t_io
+TESTS_C+=	t_toupper
 
 COPTS.t_wctomb.c += -Wno-stack-protector
 

Added files:

Index: src/tests/lib/libc/locale/t_toupper.c
diff -u /dev/null src/tests/lib/libc/locale/t_toupper.c:1.1
--- /dev/null	Tue May 30 02:11:03 2017
+++ src/tests/lib/libc/locale/t_toupper.c	Tue May 30 02:11:03 2017
@@ -0,0 +1,131 @@
+/* $NetBSD: t_toupper.c,v 1.1 2017/05/30 02:11:03 perseant 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
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__COPYRIGHT("@(#) Copyright (c) 2017\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_toupper.c,v 1.1 2017/05/30 02:11:03 perseant Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static struct test {
+	const char *locale;
+	const char *lower;
+	const char *upper;
+} tests[] = {
+	{
+		"C",
+		"abcde12345",
+		"ABCDE12345",
+	}, {
+		"ru_RU.KOI8-R",
+		"abcde12345\xc1\xc2\xd7\xc7\xc4\xc5\xa3",
+		"ABCDE12345\xe1\xe2\xf7\xe7\xe4\xe5\xb3",
+	}, {
+		NULL,
+		NULL,
+		NULL,
+	}
+};
+
+static void
+h_swapcase(const struct test *t, int upperp)
+{
+	unsigned int i;
+	unsigned char answer, reported;
+
+	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
+	printf("Trying locale %s...\n", t->locale);
+	ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
+
+	for (i = 0; i < strlen(t->lower); i++) {
+		printf("Comparing char %d, lower %2.2x, with upper %2.2x\n",
+			i, (unsigned char)t->lower[i], (unsigned char)t->upper[i]);
+		if (upperp) {
+			answer = t->upper[i];
+			reported = toupper((int)(unsigned char)t->lower[i]);
+		} else {
+			answer = t->lower[i];
+			reported = tolower((int)(unsigned char)t->upper[i]);
+		}
+		printf("  expecting %2.2x, reported %2.2x\n", answer, reported);
+		ATF_REQUIRE_EQ(reported, answer);
+	}
+}
+
+ATF_TC(toupper);
+
+ATF_TC_HEAD(toupper, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+		"Checks toupper under diferent locales");
+}
+
+ATF_TC_BODY(toupper, tc)
+{
+	struct test *t;
+
+	for (t = [0]; t->locale != NULL; ++t)
+		h_swapcase(t, 1);
+}
+
+ATF_TC(tolower);
+
+ATF_TC_HEAD(tolower, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+		"Checks tolower under diferent locales");
+}
+
+ATF_TC_BODY(tolower, tc)
+{
+	struct test *t;
+
+	/* atf_tc_expect_fail("%s", "LC_COLLATE not supported"); */
+	for (t = [0]; t->locale != NULL; ++t)
+		h_swapcase(t, 0);
+	/* atf_tc_expect_pass(); */
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+	ATF_TP_ADD_TC(tp, toupper);
+	ATF_TP_ADD_TC(tp, tolower);
+
+	return atf_no_error();
+}



CVS commit: src/tests/lib/libc/locale

2017-05-25 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Thu May 25 18:28:54 UTC 2017

Modified Files:
src/tests/lib/libc/locale: t_mbtowc.c t_wctomb.c

Log Message:
Add a member to the test data structure that indicates whether the given
encoding is state-dependent, and test the results of wctomb(NULL, '\0') and
mbtowc(NULL, NULL, 0) against this instead of against each other.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_mbtowc.c
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/locale/t_wctomb.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_mbtowc.c
diff -u src/tests/lib/libc/locale/t_mbtowc.c:1.1 src/tests/lib/libc/locale/t_mbtowc.c:1.2
--- src/tests/lib/libc/locale/t_mbtowc.c:1.1	Sat Apr  9 17:45:25 2011
+++ src/tests/lib/libc/locale/t_mbtowc.c	Thu May 25 18:28:54 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mbtowc.c,v 1.1 2011/04/09 17:45:25 pgoyette Exp $ */
+/* $NetBSD: t_mbtowc.c,v 1.2 2017/05/25 18:28:54 perseant Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_mbtowc.c,v 1.1 2011/04/09 17:45:25 pgoyette Exp $");
+__RCSID("$NetBSD: t_mbtowc.c,v 1.2 2017/05/25 18:28:54 perseant Exp $");
 
 #include 
 #include 
@@ -69,21 +69,20 @@ __RCSID("$NetBSD: t_mbtowc.c,v 1.1 2011/
 #include 
 
 static void
-h_mbtowc(const char *locale, const char *illegal, const char *legal)
+h_mbtowc(const char *locale, const char *illegal, const char *legal, size_t stateful)
 {
 	char buf[64];
-	size_t stateful, ret;
+	size_t ret;
 	char *str;
 
 	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
+	(void)printf("Trying locale: %s\n", locale);
 	ATF_REQUIRE(setlocale(LC_CTYPE, locale) != NULL);
 
 	ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL);
 	(void)printf("Using locale: %s\n", str);
-
-	stateful = wctomb(NULL, L'\0');
 	(void)printf("Locale is state-%sdependent\n",
-		stateful ? "in" : "");
+		!stateful ? "in" : "");
 
 	/* initialize internal state */
 	ret = mbtowc(NULL, NULL, 0);
@@ -101,8 +100,7 @@ h_mbtowc(const char *locale, const char 
 	/* if this is stateless encoding, this re-initialization is not required. */
 	if (stateful) {
 		/* re-initialize internal state */
-		ret = mbtowc(NULL, NULL, 0);
-		ATF_REQUIRE(stateful ? ret : !ret);
+		mbtowc(NULL, NULL, 0);
 	}
 
 	/* valid multibyte sequence case */
@@ -126,13 +124,13 @@ ATF_TC_HEAD(mbtowc, tc)
 }
 ATF_TC_BODY(mbtowc, tc)
 {
-	h_mbtowc("en_US.UTF-8", "\240", "\302\240");
-	h_mbtowc("ja_JP.ISO2022-JP", "\033$B", "\033$B$\"\033(B");
-	h_mbtowc("ja_JP.SJIS", "\202", "\202\240");
-	h_mbtowc("ja_JP.eucJP", "\244", "\244\242");
-	h_mbtowc("zh_CN.GB18030", "\241", "\241\241");
-	h_mbtowc("zh_TW.Big5", "\241", "\241@");
-	h_mbtowc("zh_TW.eucTW", "\241", "\241\241");
+	h_mbtowc("en_US.UTF-8", "\240", "\302\240", 0);
+	h_mbtowc("ja_JP.ISO2022-JP", "\033$B", "\033$B$\"\033(B", 1);
+	h_mbtowc("ja_JP.SJIS", "\202", "\202\240", 0);
+	h_mbtowc("ja_JP.eucJP", "\244", "\244\242", 0);
+	h_mbtowc("zh_CN.GB18030", "\241", "\241\241", 0);
+	h_mbtowc("zh_TW.Big5", "\241", "\241@", 0);
+	h_mbtowc("zh_TW.eucTW", "\241", "\241\241", 0);
 }
 
 ATF_TP_ADD_TCS(tp)

Index: src/tests/lib/libc/locale/t_wctomb.c
diff -u src/tests/lib/libc/locale/t_wctomb.c:1.3 src/tests/lib/libc/locale/t_wctomb.c:1.4
--- src/tests/lib/libc/locale/t_wctomb.c:1.3	Mon Mar 25 15:31:03 2013
+++ src/tests/lib/libc/locale/t_wctomb.c	Thu May 25 18:28:54 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wctomb.c,v 1.3 2013/03/25 15:31:03 gson Exp $ */
+/* $NetBSD: t_wctomb.c,v 1.4 2017/05/25 18:28:54 perseant Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_wctomb.c,v 1.3 2013/03/25 15:31:03 gson Exp $");
+__RCSID("$NetBSD: t_wctomb.c,v 1.4 2017/05/25 18:28:54 perseant Exp $");
 
 #include 
 #include 
@@ -76,6 +76,7 @@ static struct test {
 	const char *data;
 	size_t wclen;
 	size_t mblen[16];
+	size_t stateful;
 } tests[] = {
 {
 	"ja_JP.ISO2022-JP",
@@ -87,13 +88,15 @@ static struct test {
 	"\xb1\xb2\xb3"	/* "aiu" */
 	"\x1b(B",	/* ISO 646 */
 	3 + 3 + 3,
-	{ 3+2, 2, 2, 3+1, 1, 1, 3+1, 1, 1, 3+1 }
+	{ 3+2, 2, 2, 3+1, 1, 1, 3+1, 1, 1, 3+1 },
+	1,
 }, {
 	"C", 
 	"ABC",
 	3,
-	{ 1, 1, 1, 1 }
-}, { NULL, NULL, 0, { } }
+	{ 1, 1, 1, 1 },
+	0,
+}, { NULL, NULL, 0, { }, 0 }
 };
 
 static void
@@ -109,19 +112,24 @@ h_wctomb(const struct test *t, char tc)
 	size_t sz, ret, i;
 
 	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
+	(void)printf("Trying locale: %s\n", t->locale);
 	ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
 
+	if (tc == TC_WCRTOMB_ST) {
+		(void)memset(, 0, sizeof(st));
+		stp = 
+	} else {
+		(void)printf("Checking correct 

CVS commit: src/tests/lib/libc/locale

2014-05-05 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Tue May  6 00:41:26 UTC 2014

Modified Files:
src/tests/lib/libc/locale: t_mbsnrtowcs.c

Log Message:
include string.h for memset


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_mbsnrtowcs.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_mbsnrtowcs.c
diff -u src/tests/lib/libc/locale/t_mbsnrtowcs.c:1.1 src/tests/lib/libc/locale/t_mbsnrtowcs.c:1.2
--- src/tests/lib/libc/locale/t_mbsnrtowcs.c:1.1	Tue May 28 16:57:56 2013
+++ src/tests/lib/libc/locale/t_mbsnrtowcs.c	Tue May  6 00:41:26 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mbsnrtowcs.c,v 1.1 2013/05/28 16:57:56 joerg Exp $ */
+/* $NetBSD: t_mbsnrtowcs.c,v 1.2 2014/05/06 00:41:26 yamt Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,9 +30,10 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: t_mbsnrtowcs.c,v 1.1 2013/05/28 16:57:56 joerg Exp $);
+__RCSID($NetBSD: t_mbsnrtowcs.c,v 1.2 2014/05/06 00:41:26 yamt Exp $);
 
 #include locale.h
+#include string.h
 #include wchar.h
 
 #include atf-c.h



CVS commit: src/tests/lib/libc/locale

2014-01-20 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Mon Jan 20 14:14:56 UTC 2014

Modified Files:
src/tests/lib/libc/locale: t_io.c

Log Message:
- fix funopen usage
- some more checks
- remove a bogus test case (bad_eucJP_getwc)  PR/47660 (Julio Merino)
- add XXX comments


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/locale/t_io.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_io.c
diff -u src/tests/lib/libc/locale/t_io.c:1.2 src/tests/lib/libc/locale/t_io.c:1.3
--- src/tests/lib/libc/locale/t_io.c:1.2	Sun Mar 17 05:02:13 2013
+++ src/tests/lib/libc/locale/t_io.c	Mon Jan 20 14:14:56 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_io.c,v 1.2 2013/03/17 05:02:13 jmmv Exp $ */
+/* $NetBSD: t_io.c,v 1.3 2014/01/20 14:14:56 yamt Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include sys/cdefs.h
 __COPYRIGHT(@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.);
-__RCSID($NetBSD: t_io.c,v 1.2 2013/03/17 05:02:13 jmmv Exp $);
+__RCSID($NetBSD: t_io.c,v 1.3 2014/01/20 14:14:56 yamt Exp $);
 
 #include sys/param.h
 #include errno.h
@@ -53,10 +53,11 @@ ATF_TC_HEAD(bad_big5_wprintf, tc)
 
 ATF_TC_BODY(bad_big5_wprintf, tc)
 {
+	/* XXX implementation detail knowledge (wchat_t encoding) */
 	wchar_t ibuf[] = { 0xcf10, 0 };
 	setlocale(LC_CTYPE, zh_TW.Big5);
-	atf_tc_expect_fail(PR lib/47660);
-	ATF_REQUIRE_EQ(wprintf(L%ls\n, ibuf), -1);
+	ATF_REQUIRE_ERRNO(EILSEQ, wprintf(L%ls\n, ibuf)  0);
+	ATF_REQUIRE(ferror(stdout));
 }
 
 ATF_TC(bad_big5_swprintf);
@@ -67,10 +68,12 @@ ATF_TC_HEAD(bad_big5_swprintf, tc)
 
 ATF_TC_BODY(bad_big5_swprintf, tc)
 {
+	/* XXX implementation detail knowledge (wchat_t encoding) */
 	wchar_t ibuf[] = { 0xcf10, 0 };
 	wchar_t obuf[20];
 	setlocale(LC_CTYPE, zh_TW.Big5);
-	ATF_REQUIRE_EQ(swprintf(obuf, sizeof(obuf), L%ls\n, ibuf), -1);
+	ATF_REQUIRE_ERRNO(EILSEQ,
+			  swprintf(obuf, sizeof(obuf), L%ls\n, ibuf)  0);
 }
 
 ATF_TC(good_big5_wprintf);
@@ -81,9 +84,9 @@ ATF_TC_HEAD(good_big5_wprintf, tc)
 
 ATF_TC_BODY(good_big5_wprintf, tc)
 {
+	/* XXX implementation detail knowledge (wchat_t encoding) */
 	wchar_t ibuf[] = { 0xcf40, 0 };
 	setlocale(LC_CTYPE, zh_TW.Big5);
-	// WTF? swprintf() fails, wprintf succeeds?
 	ATF_REQUIRE_EQ(wprintf(L%ls\n, ibuf), 2);
 }
 
@@ -95,15 +98,28 @@ ATF_TC_HEAD(good_big5_swprintf, tc)
 
 ATF_TC_BODY(good_big5_swprintf, tc)
 {
+	/* XXX implementation detail knowledge (wchat_t encoding) */
 	wchar_t ibuf[] = { 0xcf40, 0 };
 	wchar_t obuf[20];
 	setlocale(LC_CTYPE, zh_TW.Big5);
 	ATF_REQUIRE_EQ(swprintf(obuf, sizeof(obuf), L%ls\n, ibuf), 2);
 }
 
-static int readfn(void *p, char *buf, int len) {
-	memcpy(buf, p, MIN(len, 2));
-	return 2;
+struct ibuf {
+	off_t off;
+	size_t buflen;
+	const char *buf;
+};
+
+static int
+readfn(void *vp, char *buf, int len)
+{
+	struct ibuf *ib = vp;
+	size_t todo = MIN((size_t)len, ib-buflen - ib-off);
+
+	memcpy(buf, ib-buf + ib-off, todo);
+	ib-off += todo;
+	return todo;
 }
 
 ATF_TC(good_big5_getwc);
@@ -114,11 +130,16 @@ ATF_TC_HEAD(good_big5_getwc, tc)
 
 ATF_TC_BODY(good_big5_getwc, tc)
 {
-	char ibuf[] = { 0xcf, 0x40 };
-	FILE *fp = funopen(ibuf, readfn, NULL, NULL, NULL);
+	const char buf[] = { 0xcf, 0x40 };
+	struct ibuf ib = {
+		.buf = buf,
+		.buflen = sizeof(buf),
+	};
+	FILE *fp = funopen(ib, readfn, NULL, NULL, NULL);
 
 	ATF_REQUIRE(fp != NULL);
 	setlocale(LC_CTYPE, zh_TW.Big5);
+	/* XXX implementation detail knowledge (wchat_t encoding) */
 	ATF_REQUIRE_EQ(getwc(fp), 0xcf40);
 	fclose(fp);
 }
@@ -131,8 +152,12 @@ ATF_TC_HEAD(bad_big5_getwc, tc)
 
 ATF_TC_BODY(bad_big5_getwc, tc)
 {
-	char ibuf[] = { 0xcf, 0x20 };
-	FILE *fp = funopen(ibuf, readfn, NULL, NULL, NULL);
+	const char buf[] = { 0xcf, 0x20 };
+	struct ibuf ib = {
+		.buf = buf,
+		.buflen = sizeof(buf),
+	};
+	FILE *fp = funopen(ib, readfn, NULL, NULL, NULL);
 
 	ATF_REQUIRE(fp != NULL);
 	setlocale(LC_CTYPE, zh_TW.Big5);
@@ -140,26 +165,6 @@ ATF_TC_BODY(bad_big5_getwc, tc)
 	fclose(fp);
 }
 
-ATF_TC(bad_eucJP_getwc);
-ATF_TC_HEAD(bad_eucJP_getwc, tc)
-{
-	atf_tc_set_md_var(tc, descr, Test bad eucJP wchar getwc);
-}
-
-ATF_TC_BODY(bad_eucJP_getwc, tc)
-{
-	char ibuf[] = { 0xcf, 0x20 };
-	FILE *fp = funopen(ibuf, readfn, NULL, NULL, NULL);
-
-	ATF_REQUIRE(fp != NULL);
-	setlocale(LC_CTYPE, ja_JP.eucJP);
-	// WTF? Not even returning what it read?
-	ATF_CHECK_EQ(getwc(fp), 0xcf20);
-	atf_tc_expect_fail(PR lib/47660);
-	ATF_REQUIRE_EQ(getwc(fp), WEOF);
-	fclose(fp);
-}
-
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, bad_big5_wprintf);
@@ -168,7 +173,6 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, good_big5_swprintf);
 	ATF_TP_ADD_TC(tp, good_big5_getwc);
 	ATF_TP_ADD_TC(tp, bad_big5_getwc);
-	ATF_TP_ADD_TC(tp, bad_eucJP_getwc);
 
 	return atf_no_error();
 }



CVS commit: src/tests/lib/libc/locale

2014-01-20 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Tue Jan 21 00:32:16 UTC 2014

Modified Files:
src/tests/lib/libc/locale: t_io.c

Log Message:
fix comment typos pointed out by uebayasi


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/locale/t_io.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_io.c
diff -u src/tests/lib/libc/locale/t_io.c:1.3 src/tests/lib/libc/locale/t_io.c:1.4
--- src/tests/lib/libc/locale/t_io.c:1.3	Mon Jan 20 14:14:56 2014
+++ src/tests/lib/libc/locale/t_io.c	Tue Jan 21 00:32:16 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_io.c,v 1.3 2014/01/20 14:14:56 yamt Exp $ */
+/* $NetBSD: t_io.c,v 1.4 2014/01/21 00:32:16 yamt Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include sys/cdefs.h
 __COPYRIGHT(@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.);
-__RCSID($NetBSD: t_io.c,v 1.3 2014/01/20 14:14:56 yamt Exp $);
+__RCSID($NetBSD: t_io.c,v 1.4 2014/01/21 00:32:16 yamt Exp $);
 
 #include sys/param.h
 #include errno.h
@@ -53,7 +53,7 @@ ATF_TC_HEAD(bad_big5_wprintf, tc)
 
 ATF_TC_BODY(bad_big5_wprintf, tc)
 {
-	/* XXX implementation detail knowledge (wchat_t encoding) */
+	/* XXX implementation detail knowledge (wchar_t encoding) */
 	wchar_t ibuf[] = { 0xcf10, 0 };
 	setlocale(LC_CTYPE, zh_TW.Big5);
 	ATF_REQUIRE_ERRNO(EILSEQ, wprintf(L%ls\n, ibuf)  0);
@@ -68,7 +68,7 @@ ATF_TC_HEAD(bad_big5_swprintf, tc)
 
 ATF_TC_BODY(bad_big5_swprintf, tc)
 {
-	/* XXX implementation detail knowledge (wchat_t encoding) */
+	/* XXX implementation detail knowledge (wchar_t encoding) */
 	wchar_t ibuf[] = { 0xcf10, 0 };
 	wchar_t obuf[20];
 	setlocale(LC_CTYPE, zh_TW.Big5);
@@ -84,7 +84,7 @@ ATF_TC_HEAD(good_big5_wprintf, tc)
 
 ATF_TC_BODY(good_big5_wprintf, tc)
 {
-	/* XXX implementation detail knowledge (wchat_t encoding) */
+	/* XXX implementation detail knowledge (wchar_t encoding) */
 	wchar_t ibuf[] = { 0xcf40, 0 };
 	setlocale(LC_CTYPE, zh_TW.Big5);
 	ATF_REQUIRE_EQ(wprintf(L%ls\n, ibuf), 2);
@@ -98,7 +98,7 @@ ATF_TC_HEAD(good_big5_swprintf, tc)
 
 ATF_TC_BODY(good_big5_swprintf, tc)
 {
-	/* XXX implementation detail knowledge (wchat_t encoding) */
+	/* XXX implementation detail knowledge (wchar_t encoding) */
 	wchar_t ibuf[] = { 0xcf40, 0 };
 	wchar_t obuf[20];
 	setlocale(LC_CTYPE, zh_TW.Big5);
@@ -139,7 +139,7 @@ ATF_TC_BODY(good_big5_getwc, tc)
 
 	ATF_REQUIRE(fp != NULL);
 	setlocale(LC_CTYPE, zh_TW.Big5);
-	/* XXX implementation detail knowledge (wchat_t encoding) */
+	/* XXX implementation detail knowledge (wchar_t encoding) */
 	ATF_REQUIRE_EQ(getwc(fp), 0xcf40);
 	fclose(fp);
 }



CVS commit: src/tests/lib/libc/locale

2013-03-25 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Mon Mar 25 15:31:03 UTC 2013

Modified Files:
src/tests/lib/libc/locale: t_wctomb.c

Log Message:
Don't size an array using MB_CUR_MAX while one locale is in effect and
then use it with another locale having a larger MB_CUR_MAX.  This
should fix the t_wctomb:wcrtomb_state test failures seen on i386.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/locale/t_wctomb.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_wctomb.c
diff -u src/tests/lib/libc/locale/t_wctomb.c:1.2 src/tests/lib/libc/locale/t_wctomb.c:1.3
--- src/tests/lib/libc/locale/t_wctomb.c:1.2	Sat Jun 11 18:03:18 2011
+++ src/tests/lib/libc/locale/t_wctomb.c	Mon Mar 25 15:31:03 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wctomb.c,v 1.2 2011/06/11 18:03:18 christos Exp $ */
+/* $NetBSD: t_wctomb.c,v 1.3 2013/03/25 15:31:03 gson Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
 #include sys/cdefs.h
 __COPYRIGHT(@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.);
-__RCSID($NetBSD: t_wctomb.c,v 1.2 2011/06/11 18:03:18 christos Exp $);
+__RCSID($NetBSD: t_wctomb.c,v 1.3 2013/03/25 15:31:03 gson Exp $);
 
 #include stdio.h
 #include stdlib.h
@@ -63,6 +63,7 @@ __RCSID($NetBSD: t_wctomb.c,v 1.2 2011/
 #include vis.h
 #include wchar.h
 #include string.h
+#include limits.h
 
 #include atf-c.h
 
@@ -100,7 +101,7 @@ h_wctomb(const struct test *t, char tc)
 {
 	wchar_t wcs[16 + 2];
 	char buf[128];
-	char cs[MB_CUR_MAX];
+	char cs[MB_LEN_MAX];
 	const char *pcs;
 	char *str;
 	mbstate_t st;



CVS commit: src/tests/lib/libc/locale

2013-03-16 Thread Julio Merino
Module Name:src
Committed By:   jmmv
Date:   Sun Mar 17 05:02:14 UTC 2013

Modified Files:
src/tests/lib/libc/locale: t_io.c

Log Message:
Mark two routinely-broken tests as expected failures referencing PR lib/47660.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_io.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_io.c
diff -u src/tests/lib/libc/locale/t_io.c:1.1 src/tests/lib/libc/locale/t_io.c:1.2
--- src/tests/lib/libc/locale/t_io.c:1.1	Thu Feb 28 21:52:02 2013
+++ src/tests/lib/libc/locale/t_io.c	Sun Mar 17 05:02:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: t_io.c,v 1.1 2013/02/28 21:52:02 christos Exp $ */
+/* $NetBSD: t_io.c,v 1.2 2013/03/17 05:02:13 jmmv Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include sys/cdefs.h
 __COPYRIGHT(@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.);
-__RCSID($NetBSD: t_io.c,v 1.1 2013/02/28 21:52:02 christos Exp $);
+__RCSID($NetBSD: t_io.c,v 1.2 2013/03/17 05:02:13 jmmv Exp $);
 
 #include sys/param.h
 #include errno.h
@@ -55,6 +55,7 @@ ATF_TC_BODY(bad_big5_wprintf, tc)
 {
 	wchar_t ibuf[] = { 0xcf10, 0 };
 	setlocale(LC_CTYPE, zh_TW.Big5);
+	atf_tc_expect_fail(PR lib/47660);
 	ATF_REQUIRE_EQ(wprintf(L%ls\n, ibuf), -1);
 }
 
@@ -154,6 +155,7 @@ ATF_TC_BODY(bad_eucJP_getwc, tc)
 	setlocale(LC_CTYPE, ja_JP.eucJP);
 	// WTF? Not even returning what it read?
 	ATF_CHECK_EQ(getwc(fp), 0xcf20);
+	atf_tc_expect_fail(PR lib/47660);
 	ATF_REQUIRE_EQ(getwc(fp), WEOF);
 	fclose(fp);
 }



CVS commit: src/tests/lib/libc/locale

2013-02-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 28 21:52:02 UTC 2013

Modified Files:
src/tests/lib/libc/locale: Makefile
Added Files:
src/tests/lib/libc/locale: t_io.c

Log Message:
regression tests for wide char i/o. Currently there are failures.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/locale/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/locale/t_io.c

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

Modified files:

Index: src/tests/lib/libc/locale/Makefile
diff -u src/tests/lib/libc/locale/Makefile:1.4 src/tests/lib/libc/locale/Makefile:1.5
--- src/tests/lib/libc/locale/Makefile:1.4	Mon Nov 21 18:50:45 2011
+++ src/tests/lib/libc/locale/Makefile	Thu Feb 28 16:52:02 2013
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2011/11/21 23:50:45 joerg Exp $
+# $NetBSD: Makefile,v 1.5 2013/02/28 21:52:02 christos Exp $
 
 .include bsd.own.mk
 
@@ -12,6 +12,7 @@ TESTS_C+=	t_wcspbrk
 TESTS_C+=	t_wcsspn
 TESTS_C+=	t_wcstod
 TESTS_C+=	t_wctomb
+TESTS_C+=	t_io
 
 COPTS.t_wctomb.c += -Wno-stack-protector
 

Added files:

Index: src/tests/lib/libc/locale/t_io.c
diff -u /dev/null src/tests/lib/libc/locale/t_io.c:1.1
--- /dev/null	Thu Feb 28 16:52:02 2013
+++ src/tests/lib/libc/locale/t_io.c	Thu Feb 28 16:52:02 2013
@@ -0,0 +1,172 @@
+/* $NetBSD: t_io.c,v 1.1 2013/02/28 21:52:02 christos Exp $ */
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include sys/cdefs.h
+__COPYRIGHT(@(#) Copyright (c) 2011\
+ The NetBSD Foundation, inc. All rights reserved.);
+__RCSID($NetBSD: t_io.c,v 1.1 2013/02/28 21:52:02 christos Exp $);
+
+#include sys/param.h
+#include errno.h
+#include locale.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include wchar.h
+
+#include atf-c.h
+
+
+ATF_TC(bad_big5_wprintf);
+ATF_TC_HEAD(bad_big5_wprintf, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test bad big5 wchar wprintf);
+}
+
+ATF_TC_BODY(bad_big5_wprintf, tc)
+{
+	wchar_t ibuf[] = { 0xcf10, 0 };
+	setlocale(LC_CTYPE, zh_TW.Big5);
+	ATF_REQUIRE_EQ(wprintf(L%ls\n, ibuf), -1);
+}
+
+ATF_TC(bad_big5_swprintf);
+ATF_TC_HEAD(bad_big5_swprintf, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test bad big5 wchar swprintf);
+}
+
+ATF_TC_BODY(bad_big5_swprintf, tc)
+{
+	wchar_t ibuf[] = { 0xcf10, 0 };
+	wchar_t obuf[20];
+	setlocale(LC_CTYPE, zh_TW.Big5);
+	ATF_REQUIRE_EQ(swprintf(obuf, sizeof(obuf), L%ls\n, ibuf), -1);
+}
+
+ATF_TC(good_big5_wprintf);
+ATF_TC_HEAD(good_big5_wprintf, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test good big5 wchar wprintf);
+}
+
+ATF_TC_BODY(good_big5_wprintf, tc)
+{
+	wchar_t ibuf[] = { 0xcf40, 0 };
+	setlocale(LC_CTYPE, zh_TW.Big5);
+	// WTF? swprintf() fails, wprintf succeeds?
+	ATF_REQUIRE_EQ(wprintf(L%ls\n, ibuf), 2);
+}
+
+ATF_TC(good_big5_swprintf);
+ATF_TC_HEAD(good_big5_swprintf, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test good big5 wchar swprintf);
+}
+
+ATF_TC_BODY(good_big5_swprintf, tc)
+{
+	wchar_t ibuf[] = { 0xcf40, 0 };
+	wchar_t obuf[20];
+	setlocale(LC_CTYPE, zh_TW.Big5);
+	ATF_REQUIRE_EQ(swprintf(obuf, sizeof(obuf), L%ls\n, ibuf), 2);
+}
+
+static int readfn(void *p, char *buf, int len) {
+	memcpy(buf, p, MIN(len, 2));
+	return 2;
+}
+
+ATF_TC(good_big5_getwc);
+ATF_TC_HEAD(good_big5_getwc, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test good big5 wchar getwc);
+}
+
+ATF_TC_BODY(good_big5_getwc, tc)
+{
+	char ibuf[] = { 0xcf, 0x40 };
+	FILE *fp = funopen(ibuf, readfn, NULL, NULL, NULL);
+
+	ATF_REQUIRE(fp != NULL);
+	

CVS commit: src/tests/lib/libc/locale

2011-10-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct  1 17:54:13 UTC 2011

Modified Files:
src/tests/lib/libc/locale: t_wcstod.c

Log Message:
no more ifdef vax


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_wcstod.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_wcstod.c
diff -u src/tests/lib/libc/locale/t_wcstod.c:1.1 src/tests/lib/libc/locale/t_wcstod.c:1.2
--- src/tests/lib/libc/locale/t_wcstod.c:1.1	Sat Apr  9 13:45:25 2011
+++ src/tests/lib/libc/locale/t_wcstod.c	Sat Oct  1 13:54:13 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wcstod.c,v 1.1 2011/04/09 17:45:25 pgoyette Exp $ */
+/* $NetBSD: t_wcstod.c,v 1.2 2011/10/01 17:54:13 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -56,13 +56,14 @@
 #include sys/cdefs.h
 __COPYRIGHT(@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.);
-__RCSID($NetBSD: t_wcstod.c,v 1.1 2011/04/09 17:45:25 pgoyette Exp $);
+__RCSID($NetBSD: t_wcstod.c,v 1.2 2011/10/01 17:54:13 christos Exp $);
 
 #include errno.h
 #include math.h
 #include stdlib.h
 #include string.h
 #include wchar.h
+#include float.h
 
 #include atf-c.h
 
@@ -70,7 +71,7 @@ __RCSID($NetBSD: t_wcstod.c,v 1.1 2011/
 #define	ALT_MINUS_HUGE_VAL	-2
 #define	ALT_NAN			-3
 
-#if !defined(__vax__)
+#ifdef _FLOAT_IEEE754
 static struct test {
 	const wchar_t *wcs;
 	size_t len;
@@ -382,7 +383,7 @@ static struct test {
 
 { NULL, 0, 0, 0 }
 };
-#endif /* !defined(__vax__) */
+#endif /* defined(_FLOAT_IEEE754) */
 
 ATF_TC(wcstod);
 ATF_TC_HEAD(wcstod, tc)
@@ -391,12 +392,9 @@ ATF_TC_HEAD(wcstod, tc)
 }
 ATF_TC_BODY(wcstod, tc)
 {
-#if defined(__vax__)
-#else
+#ifdef _FLOAT_IEEE754
 	struct test *t;
-#endif
 
-#if !defined(__vax__)
 	for (t = tests[0]; t-wcs != NULL; ++t) {
 		double d;
 		size_t n;
@@ -443,9 +441,9 @@ ATF_TC_BODY(wcstod, tc)
 
 		(void)printf(\n);
 	}
-#else /* !defined(__vax__) */
-	atf_tc_skip(Test is unavailable on vax.);
-#endif /* !defined(__vax__) */
+#else /* !_FLOAT_IEEE754 */
+	atf_tc_skip(Test is unavailable on this architecture.);
+#endif /* _FLOAT_IEEE754 */
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/tests/lib/libc/locale

2011-10-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct  1 17:56:11 UTC 2011

Modified Files:
src/tests/lib/libc/locale: t_wcstod.c

Log Message:
Undo previous, Checking for vax is more appropriate.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/locale/t_wcstod.c

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

Modified files:

Index: src/tests/lib/libc/locale/t_wcstod.c
diff -u src/tests/lib/libc/locale/t_wcstod.c:1.2 src/tests/lib/libc/locale/t_wcstod.c:1.3
--- src/tests/lib/libc/locale/t_wcstod.c:1.2	Sat Oct  1 13:54:13 2011
+++ src/tests/lib/libc/locale/t_wcstod.c	Sat Oct  1 13:56:11 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wcstod.c,v 1.2 2011/10/01 17:54:13 christos Exp $ */
+/* $NetBSD: t_wcstod.c,v 1.3 2011/10/01 17:56:11 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -56,14 +56,13 @@
 #include sys/cdefs.h
 __COPYRIGHT(@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.);
-__RCSID($NetBSD: t_wcstod.c,v 1.2 2011/10/01 17:54:13 christos Exp $);
+__RCSID($NetBSD: t_wcstod.c,v 1.3 2011/10/01 17:56:11 christos Exp $);
 
 #include errno.h
 #include math.h
 #include stdlib.h
 #include string.h
 #include wchar.h
-#include float.h
 
 #include atf-c.h
 
@@ -71,7 +70,7 @@ __RCSID($NetBSD: t_wcstod.c,v 1.2 2011/
 #define	ALT_MINUS_HUGE_VAL	-2
 #define	ALT_NAN			-3
 
-#ifdef _FLOAT_IEEE754
+#if !defined(__vax__)
 static struct test {
 	const wchar_t *wcs;
 	size_t len;
@@ -383,7 +382,7 @@ static struct test {
 
 { NULL, 0, 0, 0 }
 };
-#endif /* defined(_FLOAT_IEEE754) */
+#endif /* !defined(__vax__) */
 
 ATF_TC(wcstod);
 ATF_TC_HEAD(wcstod, tc)
@@ -392,9 +391,12 @@ ATF_TC_HEAD(wcstod, tc)
 }
 ATF_TC_BODY(wcstod, tc)
 {
-#ifdef _FLOAT_IEEE754
+#if defined(__vax__)
+#else
 	struct test *t;
+#endif
 
+#if !defined(__vax__)
 	for (t = tests[0]; t-wcs != NULL; ++t) {
 		double d;
 		size_t n;
@@ -441,9 +443,9 @@ ATF_TC_BODY(wcstod, tc)
 
 		(void)printf(\n);
 	}
-#else /* !_FLOAT_IEEE754 */
-	atf_tc_skip(Test is unavailable on this architecture.);
-#endif /* _FLOAT_IEEE754 */
+#else /* !defined(__vax__) */
+	atf_tc_skip(Test is unavailable on vax.);
+#endif /* !defined(__vax__) */
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/tests/lib/libc/locale

2011-04-11 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Mon Apr 11 17:16:43 UTC 2011

Modified Files:
src/tests/lib/libc/locale: Makefile

Log Message:
Fix build with stack smash protection enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/Makefile

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

Modified files:

Index: src/tests/lib/libc/locale/Makefile
diff -u src/tests/lib/libc/locale/Makefile:1.1 src/tests/lib/libc/locale/Makefile:1.2
--- src/tests/lib/libc/locale/Makefile:1.1	Sat Apr  9 17:45:25 2011
+++ src/tests/lib/libc/locale/Makefile	Mon Apr 11 17:16:43 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2011/04/09 17:45:25 pgoyette Exp $
+# $NetBSD: Makefile,v 1.2 2011/04/11 17:16:43 tron Exp $
 
 .include bsd.own.mk
 
@@ -10,4 +10,6 @@
 TESTS_C+=	t_wcstod
 TESTS_C+=	t_wctomb
 
+COPTS.t_wctomb.c += -Wno-stack-protector
+
 .include bsd.test.mk