Module Name:    src
Committed By:   jruoho
Date:           Tue Jun 30 16:09:40 UTC 2020

Modified Files:
        src/distrib/sets/lists/debug: mi
        src/distrib/sets/lists/tests: mi
        src/tests/lib/libc/locale: t_mbtowc.c
        src/tests/lib/libc/stdlib: Makefile
Removed Files:
        src/tests/lib/libc/stdlib: t_mbtowc.c

Log Message:
After a comedy of errors, move t_mbtowc to its final resting place.


To generate a diff of this commit:
cvs rdiff -u -r1.320 -r1.321 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.865 -r1.866 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/locale/t_mbtowc.c
cvs rdiff -u -r1.31 -r1.32 src/tests/lib/libc/stdlib/Makefile
cvs rdiff -u -r1.3 -r0 src/tests/lib/libc/stdlib/t_mbtowc.c

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

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.320 src/distrib/sets/lists/debug/mi:1.321
--- src/distrib/sets/lists/debug/mi:1.320	Mon Jun 29 23:44:01 2020
+++ src/distrib/sets/lists/debug/mi	Tue Jun 30 16:09:40 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.320 2020/06/29 23:44:01 riastradh Exp $
+# $NetBSD: mi,v 1.321 2020/06/30 16:09:40 jruoho Exp $
 ./etc/mtree/set.debug                           comp-sys-root
 ./usr/lib					comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -2090,7 +2090,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_getenv.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_getenv_thread.debug	tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_hsearch.debug		tests-lib-debug		debug,atf,compattestfile
-./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_mbtowc.debug		tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_mbtowc.debug		tests-obsolete		obsolete
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_mi_vector_hash.debug	tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_mktemp.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_posix_memalign.debug	tests-lib-debug		debug,atf,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.865 src/distrib/sets/lists/tests/mi:1.866
--- src/distrib/sets/lists/tests/mi:1.865	Tue Jun 30 14:30:49 2020
+++ src/distrib/sets/lists/tests/mi	Tue Jun 30 16:09:40 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.865 2020/06/30 14:30:49 jruoho Exp $
+# $NetBSD: mi,v 1.866 2020/06/30 16:09:40 jruoho Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3075,7 +3075,7 @@
 ./usr/tests/lib/libc/stdlib/t_getenv_thread	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdlib/t_getopt		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdlib/t_hsearch		tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libc/stdlib/t_mbtowc		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/stdlib/t_mbtowc		tests-obsolete		obsolete
 ./usr/tests/lib/libc/stdlib/t_mi_vector_hash	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdlib/t_mktemp		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/stdlib/t_posix_memalign	tests-lib-tests		compattestfile,atf

Index: src/tests/lib/libc/locale/t_mbtowc.c
diff -u src/tests/lib/libc/locale/t_mbtowc.c:1.2 src/tests/lib/libc/locale/t_mbtowc.c:1.3
--- src/tests/lib/libc/locale/t_mbtowc.c:1.2	Thu May 25 18:28:54 2017
+++ src/tests/lib/libc/locale/t_mbtowc.c	Tue Jun 30 16:09:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mbtowc.c,v 1.2 2017/05/25 18:28:54 perseant Exp $ */
+/* $NetBSD: t_mbtowc.c,v 1.3 2020/06/30 16:09:40 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -53,13 +53,42 @@
  *
  */
 
+/*-
+ * Copyright (c) 2005 Miloslav Trmac
+ * All rights reserved.
+ *
+ * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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_mbtowc.c,v 1.2 2017/05/25 18:28:54 perseant Exp $");
+__RCSID("$NetBSD: t_mbtowc.c,v 1.3 2020/06/30 16:09:40 jruoho Exp $");
 
 #include <errno.h>
+#include <langinfo.h>
 #include <locale.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -69,7 +98,8 @@ __RCSID("$NetBSD: t_mbtowc.c,v 1.2 2017/
 #include <atf-c.h>
 
 static void
-h_mbtowc(const char *locale, const char *illegal, const char *legal, size_t stateful)
+h_mbtowc(const char *locale, const char *illegal,
+    const char *legal, size_t stateful)
 {
 	char buf[64];
 	size_t ret;
@@ -97,7 +127,10 @@ h_mbtowc(const char *locale, const char 
 	(void)printf("errno: %s\n", strerror(errno));
 	ATF_REQUIRE_EQ(errno, EILSEQ);
 
-	/* if this is stateless encoding, this re-initialization is not required. */
+	/*
+	 * If this is stateless encoding, this
+	 * re-initialization is not required.
+	 */
 	if (stateful) {
 		/* re-initialize internal state */
 		mbtowc(NULL, NULL, 0);
@@ -117,12 +150,13 @@ h_mbtowc(const char *locale, const char 
 	(void)printf("Ok.\n");
 }
 
-ATF_TC(mbtowc);
-ATF_TC_HEAD(mbtowc, tc)
+ATF_TC(mbtowc_basic);
+ATF_TC_HEAD(mbtowc_basic, tc)
 {
-	atf_tc_set_md_var(tc, "descr", "Checks mbtowc(3)");
+	atf_tc_set_md_var(tc, "descr", "A basic test of mbtowc(3)");
 }
-ATF_TC_BODY(mbtowc, tc)
+
+ATF_TC_BODY(mbtowc_basic, tc)
 {
 	h_mbtowc("en_US.UTF-8", "\240", "\302\240", 0);
 	h_mbtowc("ja_JP.ISO2022-JP", "\033$B", "\033$B$\"\033(B", 1);
@@ -133,9 +167,41 @@ ATF_TC_BODY(mbtowc, tc)
 	h_mbtowc("zh_TW.eucTW", "\241", "\241\241", 0);
 }
 
+ATF_TC(mbtowc_sign);
+ATF_TC_HEAD(mbtowc_sign, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test mbtowc(3) sign conversion");
+}
+
+ATF_TC_BODY(mbtowc_sign, tc)
+{
+	char back[MB_LEN_MAX];
+	wchar_t wc;
+	size_t i;
+	int ret;
+
+	(void)setlocale(LC_ALL, "");
+	(void)printf("Charset: %s\n", nl_langinfo(CODESET));
+	ret = mbtowc(&wc, "\xe4", 1);
+	(void)printf("mbtowc(): %d\n", ret);
+
+	if (ret > 0) {
+		(void)printf("Result: 0x%08lX\n",(unsigned long)wc);
+		ret = wctomb(back, wc);
+		(void)printf("wctomb(): %d\n", ret);
+		for(i = 0; ret > 0 && i < (size_t)ret; i++)
+			printf("%02X ",(unsigned char)back[i]);
+		putchar('\n');
+	}
+
+	ATF_REQUIRE(ret > 0);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
-	ATF_TP_ADD_TC(tp, mbtowc);
+
+	ATF_TP_ADD_TC(tp, mbtowc_basic);
+	ATF_TP_ADD_TC(tp, mbtowc_sign);
 
 	return atf_no_error();
 }

Index: src/tests/lib/libc/stdlib/Makefile
diff -u src/tests/lib/libc/stdlib/Makefile:1.31 src/tests/lib/libc/stdlib/Makefile:1.32
--- src/tests/lib/libc/stdlib/Makefile:1.31	Mon Jun 29 14:22:11 2020
+++ src/tests/lib/libc/stdlib/Makefile	Tue Jun 30 16:09:40 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.31 2020/06/29 14:22:11 jruoho Exp $
+# $NetBSD: Makefile,v 1.32 2020/06/30 16:09:40 jruoho Exp $
 
 .include <bsd.own.mk>
 
@@ -11,7 +11,6 @@ TESTS_C+=	t_getenv
 TESTS_C+=	t_getenv_thread
 TESTS_C+=	t_exit
 TESTS_C+=	t_hsearch
-TESTS_C+=	t_mbtowc
 TESTS_C+=	t_mktemp
 TESTS_C+=	t_mi_vector_hash
 TESTS_C+=	t_posix_memalign

Reply via email to