CVS commit: src/tests/fs/lfs

2020-08-23 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Sun Aug 23 16:03:54 UTC 2020

Modified Files:
src/tests/fs/lfs: t_rfw.c

Log Message:
Expand test to cover more failure cases.  Change from skipped to expect fail
in anticipation of working roll-forward code.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/fs/lfs/t_rfw.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/fs/lfs/t_rfw.c
diff -u src/tests/fs/lfs/t_rfw.c:1.1 src/tests/fs/lfs/t_rfw.c:1.2
--- src/tests/fs/lfs/t_rfw.c:1.1	Tue Aug 18 03:02:50 2020
+++ src/tests/fs/lfs/t_rfw.c	Sun Aug 23 16:03:54 2020
@@ -1,11 +1,11 @@
-/*	$NetBSD: t_rfw.c,v 1.1 2020/08/18 03:02:50 perseant Exp $	*/
+/*	$NetBSD: t_rfw.c,v 1.2 2020/08/23 16:03:54 perseant Exp $	*/
 
 #include 
 #include 
-#include 
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -25,7 +25,6 @@
 
 /* Debugging conditions */
 /* #define FORCE_SUCCESS */ /* Don't actually revert, everything worked */
-/* #define FORCE_SYSCTL */ /* Don't check - necessary for FORCE_SUCCESS */
 
 /* Write a well-known byte pattern into a file, appending if it exists */
 int write_file(const char *, int);
@@ -33,6 +32,12 @@ int write_file(const char *, int);
 /* Check the byte pattern and size of the file */
 int check_file(const char *, int);
 
+/* Check the file system for consistency */
+int fsck(void);
+
+/* Actually run the test, differentiating the orphaned delete problem */
+void test(int);
+
 ATF_TC(rfw);
 ATF_TC_HEAD(rfw, tc)
 {
@@ -41,42 +46,39 @@ ATF_TC_HEAD(rfw, tc)
 	atf_tc_set_md_var(tc, "timeout", "20");
 }
 
+#define MAXLINE 132
+#define CHUNKSIZE 300
+
 #define IMGNAME "disk.img"
 #define FAKEBLK "/dev/blk"
 #define LOGFILE "newfs.log"
 #define SBLOCK0_COPY "sb0.dd"
 #define SBLOCK1_COPY "sb1.dd"
-#define MAXLINE 132
-#define CHUNKSIZE 300
+
+#define MP "/mp"
+#define UNCHANGED_CONTROL MP "/3-unchanged-control"
+#define TO_BE_DELETED MP "/4-to-be-deleted"
+#define TO_BE_APPENDEDMP "/5-to-be-appended"
+#define NEWLY_CREATED MP "/6-newly-created"
+
+long long sbaddr[2] = { -1, -1 };
+const char *sblock[2] = { SBLOCK0_COPY, SBLOCK1_COPY };
+
 ATF_TC_BODY(rfw, tc)
 {
 	struct ufs_args args;
 	FILE *pipe;
-#if (!defined FORCE_SUCCESS && !defined FORCE_SYSCTL)
-	int o_sysctl_rfw;
-	int n_sysctl_rfw;
-	int mib[3];
-	size_t len;
-#endif
 	char buf[MAXLINE];
-	long long sb0addr = -1, sb1addr = -1;
+	int i;
+
+	setvbuf(stdout, NULL, _IONBF, 0);
 
 	/*
 	 * Initialize.
 	 */
-#if (!defined FORCE_SUCCESS && !defined FORCE_SYSCTL)
-	/* Set sysctl to allow roll-forward */
-	fprintf(stderr, "* Set sysctl\n");
-	mib[0] = CTL_VFS;
-	mib[1] = 5; /* LFS */
-	mib[2] = LFS_DO_RFW;
-	len = sizeof(o_sysctl_rfw);
-	if (sysctl(mib, 3, _sysctl_rfw, ,
-		_sysctl_rfw, sizeof(n_sysctl_rfw)) < 0)
-		atf_tc_skip("roll-forward not enabled in kernel");
-#endif /* !FORCE_SUCCESS && !FORCE_SYSCTL */
+	atf_tc_expect_fail("roll-forward not yet implemented");
 
-	/* Create filesystem */
+	/* Create filesystem, note superblock locations */
 	fprintf(stderr, "* Create file system\n");
 	if (system("newfs_lfs -D -F -s 1 ./" IMGNAME " > " LOGFILE) == -1)
 		atf_tc_fail_errno("newfs failed");
@@ -84,20 +86,20 @@ ATF_TC_BODY(rfw, tc)
 	if (pipe == NULL)
 		atf_tc_fail_errno("newfs failed to execute");
 	while (fgets(buf, MAXLINE, pipe) != NULL) {
-		if (sscanf(buf, "%lld,%lld", , ) == 2)
+		if (sscanf(buf, "%lld,%lld", sbaddr, sbaddr + 1) == 2)
 			break;
 	}
 	while (fgets(buf, MAXLINE, pipe) != NULL)
 		;
 	fclose(pipe);
-	if (sb0addr < 0 || sb1addr < 0)
+	if (sbaddr[0] < 0 || sbaddr[1] < 0)
 		atf_tc_fail("superblock not found");
 	fprintf(stderr, "* Superblocks at %lld and %lld\n",
-		sb0addr, sb1addr);
+		sbaddr[0], sbaddr[1]);
 
 	/* Set up rump */
 	rump_init();
-	if (rump_sys_mkdir("/mp", 0777) == -1)
+	if (rump_sys_mkdir(MP, 0777) == -1)
 		atf_tc_fail_errno("cannot create mountpoint");
 	rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK);
 
@@ -107,61 +109,63 @@ ATF_TC_BODY(rfw, tc)
 	 */
 
 	/* Mount filesystem */
-	fprintf(stderr, "* Mount fs [1]\n");
+	fprintf(stderr, "* Mount fs [1, initial]\n");
 	memset(, 0, sizeof(args));
 	args.fspec = __UNCONST(FAKEBLK);
-	if (rump_sys_mount(MOUNT_LFS, "/mp", 0, , sizeof(args)) == -1)
+	if (rump_sys_mount(MOUNT_LFS, MP, 0, , sizeof(args)) == -1)
 		atf_tc_fail_errno("rump_sys_mount failed");
 
 	/* Payload */
 	fprintf(stderr, "* Initial payload\n");
-	write_file("/mp/to_be_deleted", CHUNKSIZE);
-	write_file("/mp/to_be_appended", CHUNKSIZE);
-
-	/* Unmount */
-	rump_sys_unmount("/mp", 0);
+	write_file(UNCHANGED_CONTROL, CHUNKSIZE);
+	write_file(TO_BE_DELETED, CHUNKSIZE);
+	write_file(TO_BE_APPENDED, CHUNKSIZE);
+	rump_sys_sync();
+	rump_sys_sync();
+	sleep(1); /* XXX yuck - but we need the superblocks dirty */
 
 	/* Make copies of superblocks */
-	sprintf(buf, "dd if=%s of=%s bs=512 iseek=%lld count=16 conv=sync",

CVS commit: src

2020-08-17 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Tue Aug 18 03:02:51 UTC 2020

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/fs/lfs: Makefile
Added Files:
src/tests/fs/lfs: t_rfw.c

Log Message:
Add skipped test for in-kernel roll-forward agent


To generate a diff of this commit:
cvs rdiff -u -r1.327 -r1.328 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.892 -r1.893 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.2 -r1.3 src/tests/fs/lfs/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/fs/lfs/t_rfw.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.327 src/distrib/sets/lists/debug/mi:1.328
--- src/distrib/sets/lists/debug/mi:1.327	Fri Aug 14 00:53:16 2020
+++ src/distrib/sets/lists/debug/mi	Tue Aug 18 03:02:50 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.327 2020/08/14 00:53:16 riastradh Exp $
+# $NetBSD: mi,v 1.328 2020/08/18 03:02:50 perseant 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
@@ -1666,6 +1666,7 @@
 ./usr/libdata/debug/usr/tests/fs/hfs/t_pathconvert.debug		tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/fs/kernfs/t_basic.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/fs/lfs/t_pr.debugtests-fs-debug		debug,atf,rump
+./usr/libdata/debug/usr/tests/fs/lfs/t_rfw.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/fs/msdosfs/t_snapshot.debug		tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/fs/nfs/nfsservice/rumpnfsd.debug			tests-fs-debug		debug,atf,rump
 ./usr/libdata/debug/usr/tests/fs/nfs/t_mountd.debug			tests-fs-debug		debug,atf,rump

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.892 src/distrib/sets/lists/tests/mi:1.893
--- src/distrib/sets/lists/tests/mi:1.892	Sun Aug 16 20:43:01 2020
+++ src/distrib/sets/lists/tests/mi	Tue Aug 18 03:02:50 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.892 2020/08/16 20:43:01 rillig Exp $
+# $NetBSD: mi,v 1.893 2020/08/18 03:02:50 perseant Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1501,6 +1501,7 @@
 ./usr/tests/fs/lfs/Atffiletests-fs-tests		atf,rump
 ./usr/tests/fs/lfs/Kyuafiletests-fs-tests		atf,rump,kyua
 ./usr/tests/fs/lfs/t_pr	tests-fs-tests		atf,rump
+./usr/tests/fs/lfs/t_rfwtests-fs-tests		atf,rump
 ./usr/tests/fs/msdosfs	tests-fs-tests		compattestfile,atf
 ./usr/tests/fs/msdosfs/Atffiletests-fs-tests		atf,rump
 ./usr/tests/fs/msdosfs/Kyuafiletests-fs-tests		atf,rump,kyua

Index: src/tests/fs/lfs/Makefile
diff -u src/tests/fs/lfs/Makefile:1.2 src/tests/fs/lfs/Makefile:1.3
--- src/tests/fs/lfs/Makefile:1.2	Sun Mar  1 18:08:13 2020
+++ src/tests/fs/lfs/Makefile	Tue Aug 18 03:02:50 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2020/03/01 18:08:13 christos Exp $
+#	$NetBSD: Makefile,v 1.3 2020/08/18 03:02:50 perseant Exp $
 #
 
 .include 
@@ -6,7 +6,7 @@
 TESTSDIR=	${TESTSBASE}/fs/lfs
 WARNS=		4
 
-TESTS_C=	t_pr
+TESTS_C=	t_pr t_rfw
 
 LDADD+=-lrumpfs_lfs -lrumpfs_ffs# fs drivers
 LDADD+=-lrumpdev_disk -lrumpdev	# disk device

Added files:

Index: src/tests/fs/lfs/t_rfw.c
diff -u /dev/null src/tests/fs/lfs/t_rfw.c:1.1
--- /dev/null	Tue Aug 18 03:02:51 2020
+++ src/tests/fs/lfs/t_rfw.c	Tue Aug 18 03:02:50 2020
@@ -0,0 +1,272 @@
+/*	$NetBSD: t_rfw.c,v 1.1 2020/08/18 03:02:50 perseant Exp $	*/
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "h_macros.h"
+
+/* Debugging conditions */
+/* #define FORCE_SUCCESS */ /* Don't actually revert, everything worked */
+/* #define FORCE_SYSCTL */ /* Don't check - necessary for FORCE_SUCCESS */
+
+/* Write a well-known byte pattern into a file, appending if it exists */
+int write_file(const char *, int);
+
+/* Check the byte pattern and size of the file */
+int check_file(const char *, int);
+
+ATF_TC(rfw);
+ATF_TC_HEAD(rfw, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+		"LFS roll-forward creates an inconsistent filesystem");
+	atf_tc_set_md_var(tc, "timeout", "20");
+}
+
+#define IMGNAME "disk.img"
+#define FAKEBLK "/dev/blk"
+#define LOGFILE "newfs.log"
+#define SBLOCK0_COPY "sb0.dd"
+#define SBLOCK1_COPY "sb1.dd"
+#define MAXLINE 132
+#define CHUNKSIZE 300
+ATF_TC_BODY(rfw, tc)
+{
+	struct ufs_args args;
+	FILE *pipe;
+#if (!defined FORCE_SUCCESS && !defined FORCE_SYSCTL)
+	int o_sysctl_rfw;
+	int n_sysctl_rfw;
+	int mib[3];
+	size_t len;
+#endif
+	char buf[MAXLINE];
+	long long sb0addr = -1, sb1addr = -1;
+
+	/*
+	 * Initialize.
+	 */
+#if (!defined FORCE_SUCCESS && !defined FORCE_SYSCTL)
+	/* Set sysctl to allow 

CVS commit: [perseant-stdc-iso10646] src/lib/libc/citrus

2018-01-29 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Jan 29 22:08:59 UTC 2018

Modified Files:
src/lib/libc/citrus [perseant-stdc-iso10646]: Makefile.inc
citrus_trie.c citrus_trie.h
src/lib/libc/citrus/modules [perseant-stdc-iso10646]: citrus_big5.c
citrus_big5_k2u.h citrus_big5_u2k.h citrus_euc.c citrus_euc_k2u.h
citrus_euc_u2k.h citrus_iso2022.c citrus_iso2022_k2u.h
citrus_iso2022_u2k.h citrus_mskanji.c citrus_mskanji_k2u.h
citrus_mskanji_u2k.h

Log Message:
Fix issues with trie implementation.  Now passes the locale tests when 
__STDC_ISO_10646__ is defined, with the exception of tests requiring LC_COLLATE 
support.


To generate a diff of this commit:
cvs rdiff -u -r1.8.40.1 -r1.8.40.2 src/lib/libc/citrus/Makefile.inc
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/lib/libc/citrus/citrus_trie.c \
src/lib/libc/citrus/citrus_trie.h
cvs rdiff -u -r1.15.18.4 -r1.15.18.5 \
src/lib/libc/citrus/modules/citrus_big5.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
src/lib/libc/citrus/modules/citrus_big5_k2u.h \
src/lib/libc/citrus/modules/citrus_big5_u2k.h \
src/lib/libc/citrus/modules/citrus_euc_k2u.h \
src/lib/libc/citrus/modules/citrus_euc_u2k.h \
src/lib/libc/citrus/modules/citrus_iso2022_k2u.h \
src/lib/libc/citrus/modules/citrus_iso2022_u2k.h \
src/lib/libc/citrus/modules/citrus_mskanji_k2u.h \
src/lib/libc/citrus/modules/citrus_mskanji_u2k.h
cvs rdiff -u -r1.17.20.4 -r1.17.20.5 src/lib/libc/citrus/modules/citrus_euc.c
cvs rdiff -u -r1.23.22.4 -r1.23.22.5 \
src/lib/libc/citrus/modules/citrus_iso2022.c
cvs rdiff -u -r1.14.22.4 -r1.14.22.5 \
src/lib/libc/citrus/modules/citrus_mskanji.c

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

diffs are larger than 1MB and have been omitted


CVS commit: [perseant-stdc-iso10646] src

2018-01-22 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Tue Jan 23 03:12:11 UTC 2018

Modified Files:
src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_ctype.h
citrus_none.c
src/tests/lib/libc/locale [perseant-stdc-iso10646]: t_toupper.c

Log Message:
Make the tests pass once more when __STDC_ISO_10646__ is not defined.


To generate a diff of this commit:
cvs rdiff -u -r1.3.22.2 -r1.3.22.3 src/lib/libc/citrus/citrus_ctype.h
cvs rdiff -u -r1.22.2.2 -r1.22.2.3 src/lib/libc/citrus/citrus_none.c
cvs rdiff -u -r1.1 -r1.1.4.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/lib/libc/citrus/citrus_ctype.h
diff -u src/lib/libc/citrus/citrus_ctype.h:1.3.22.2 src/lib/libc/citrus/citrus_ctype.h:1.3.22.3
--- src/lib/libc/citrus/citrus_ctype.h:1.3.22.2	Mon Jul 31 04:23:35 2017
+++ src/lib/libc/citrus/citrus_ctype.h	Tue Jan 23 03:12:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: citrus_ctype.h,v 1.3.22.2 2017/07/31 04:23:35 perseant Exp $	*/
+/*	$NetBSD: citrus_ctype.h,v 1.3.22.3 2018/01/23 03:12:11 perseant Exp $	*/
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -206,8 +206,8 @@ _citrus_ctype_kt2ucs(_citrus_ctype_t cc,
 }
 #else
 /* Define away the calls to these functions */
-#define _citrus_ctype_ucs2kt(cl, ktp, wc) do {} while (0)
-#define _citrus_ctype_kt2ucs(cl, up, kt) do {} while (0)
+#define _citrus_ctype_ucs2kt(cl, ktp, wc) do { *ktp = wc; } while (0)
+#define _citrus_ctype_kt2ucs(cl, up, kt) do { *up = kt; } while (0)
 #endif
 
 extern _citrus_ctype_rec_t _citrus_ctype_default;

Index: src/lib/libc/citrus/citrus_none.c
diff -u src/lib/libc/citrus/citrus_none.c:1.22.2.2 src/lib/libc/citrus/citrus_none.c:1.22.2.3
--- src/lib/libc/citrus/citrus_none.c:1.22.2.2	Fri Jul 21 20:22:29 2017
+++ src/lib/libc/citrus/citrus_none.c	Tue Jan 23 03:12:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: citrus_none.c,v 1.22.2.2 2017/07/21 20:22:29 perseant Exp $	*/
+/*	$NetBSD: citrus_none.c,v 1.22.2.3 2018/01/23 03:12:11 perseant Exp $	*/
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_none.c,v 1.22.2.2 2017/07/21 20:22:29 perseant Exp $");
+__RCSID("$NetBSD: citrus_none.c,v 1.22.2.3 2018/01/23 03:12:11 perseant Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include 
@@ -493,6 +493,10 @@ _citrus_NONE_ctype_ucs2kt(void * __restr
 			  wchar_kuten_t * __restrict ktp,
 			  wchar_ucs4_t wc)
 {
+#ifndef __STDC_ISO_10646__
+	*ktp = wc;
+	return 0;
+#else /* __STDC_ISO_10646__ */
 	struct _NONE_Info *nip = (struct _NONE_Info *)cl;
 	struct unicode2kuten_lookup *uk = NULL;
 
@@ -514,6 +518,7 @@ _citrus_NONE_ctype_ucs2kt(void * __restr
 	else
 		*ktp = WEOF;
 	return 0;
+#endif /* __STDC_ISO_10646__ */
 }
 
 static int
@@ -522,6 +527,10 @@ _citrus_NONE_ctype_kt2ucs(void * __restr
 			  wchar_ucs4_t * __restrict up,
 			  wchar_kuten_t kt)
 {
+#ifndef __STDC_ISO_10646__
+	*up = kt;
+	return 0;
+#else /* __STDC_ISO_10646__ */
 	if (cl == NULL) {
 		*up = kt;
 		return 0;
@@ -529,6 +538,7 @@ _citrus_NONE_ctype_kt2ucs(void * __restr
 
 	*up = ((struct _NONE_Info *)cl)->forward[kt];
 	return 0;
+#endif /* __STDC_ISO_10646__ */
 }
 
 /* -- */

Index: src/tests/lib/libc/locale/t_toupper.c
diff -u src/tests/lib/libc/locale/t_toupper.c:1.1 src/tests/lib/libc/locale/t_toupper.c:1.1.4.1
--- src/tests/lib/libc/locale/t_toupper.c:1.1	Tue May 30 02:11:03 2017
+++ src/tests/lib/libc/locale/t_toupper.c	Tue Jan 23 03:12:11 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_toupper.c,v 1.1 2017/05/30 02:11:03 perseant Exp $ */
+/* $NetBSD: t_toupper.c,v 1.1.4.1 2018/01/23 03:12:11 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_toupper.c,v 1.1 2017/05/30 02:11:03 perseant Exp $");
+__RCSID("$NetBSD: t_toupper.c,v 1.1.4.1 2018/01/23 03:12:11 perseant Exp $");
 
 #include 
 #include 
@@ -71,6 +71,7 @@ h_swapcase(const struct test *t, int upp
 	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
 	printf("Trying locale %s...\n", t->locale);
 	ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
+	printf("Using locale: %s\n", setlocale(LC_ALL, NULL));
 
 	for (i = 0; i < strlen(t->lower); i++) {
 		printf("Comparing char %d, lower %2.2x, with upper %2.2x\n",



CVS commit: [perseant-stdc-iso10646] src/lib/libc/citrus

2018-01-21 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Sun Jan 21 19:35:10 UTC 2018

Added Files:
src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_trie.c
citrus_trie.h

Log Message:
Add files missing from previous commit


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/lib/libc/citrus/citrus_trie.c \
src/lib/libc/citrus/citrus_trie.h

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

Added files:

Index: src/lib/libc/citrus/citrus_trie.c
diff -u /dev/null src/lib/libc/citrus/citrus_trie.c:1.1.2.1
--- /dev/null	Sun Jan 21 19:35:10 2018
+++ src/lib/libc/citrus/citrus_trie.c	Sun Jan 21 19:35:10 2018
@@ -0,0 +1,404 @@
+#include "citrus_trie.h"
+#ifdef DEBUG_TRIE
+# include "modules/citrus_euc_data.h"
+# include "citrus_trie_test.h"
+#endif
+
+static void citrus_trie_dump_table_recursive(citrus_trie_node_t, size_t, FILE *, int);
+static void citrus_trie_load_table_recursive(citrus_trie_node_t, size_t, FILE *);
+static void citrus_trie_init_recursive(citrus_trie_node_t *, VALUE_TYPE *, int, int *, int *);
+
+citrus_trie_header_t
+citrus_trie_create(unsigned int flags, size_t bitwidth,
+		   size_t nlevels, size_t off, size_t len)
+{
+	citrus_trie_header_t h;
+
+	h = (citrus_trie_header_t)malloc(sizeof(*h));
+	h->th_flags = flags;
+	h->th_bitwidth = bitwidth;
+	h->th_bitmask = (1 << bitwidth) - 1;
+	h->th_off = off;
+	h->th_level = nlevels - 1;
+#ifdef DEBUG_TRIE
+	h->th_size = sizeof(*h);
+#endif
+	h->th_root = citrus_trie_node_create(h, h->th_level, len);
+
+	return h;
+}
+
+citrus_trie_node_t
+citrus_trie_node_create(citrus_trie_header_t h, size_t level, size_t len)
+{
+	int i;
+	citrus_trie_node_t t;
+
+	t = (citrus_trie_node_t)citrus_trie_malloc(h, sizeof(*t));
+	t->tr_len = len;
+	if (len > 0) {
+		t->tr_u = (union citrus_trie_node_union *)citrus_trie_malloc(h, len * sizeof(*t->tr_u));
+		if (level == 0) {
+			for (i = 0; i < len; i++)
+t->tr_u[i].u_value = INVALID_VALUE;
+		} else {
+			for (i = 0; i < len; i++)
+t->tr_u[i].u_child = NULL;
+		}
+	} else
+		t->tr_u = NULL;
+
+	return t;
+}
+
+int
+citrus_trie_node_insert(citrus_trie_header_t h, citrus_trie_node_t t, size_t level, citrus_trie_key_t key, VALUE_TYPE value)
+{
+	size_t idx, i, olen;
+
+	idx = (key >> (level * h->th_bitwidth)) & h->th_bitmask;
+	if (idx < h->th_off)
+		return EINVAL;
+
+	idx -= h->th_off;
+	if (t->tr_len <= idx) {
+		olen = t->tr_len;
+		t->tr_len = idx + 1;
+#ifdef DEBUG_TRIE
+		h->th_size += (t->tr_len - olen) * sizeof(*t->tr_u);
+#endif
+		t->tr_u = (union citrus_trie_node_union *)realloc(t->tr_u, t->tr_len * sizeof(*t->tr_u));
+		for (i = olen; i < t->tr_len; i++) {
+			if (level == 0)
+t->tr_u[i].u_value = INVALID_VALUE;
+			else
+t->tr_u[i].u_child = NULL;
+		}
+	}
+
+	if (level == 0) {
+		t->tr_u[idx].u_value = value;
+		return 0;
+	} else {
+		if (t->tr_u[idx].u_child == NULL)
+			t->tr_u[idx].u_child = citrus_trie_node_create(h, level - 1, 0);
+		return citrus_trie_node_insert(h, t->tr_u[idx].u_child, level - 1,
+	key, value);
+	}
+}
+
+int
+citrus_trie_insert(citrus_trie_header_t h, citrus_trie_key_t key, VALUE_TYPE value)
+{
+	int r = citrus_trie_node_insert(h, h->th_root, h->th_level, key, value);
+#ifdef DEBUG_TRIE
+	int c = citrus_trie_lookup(h, key);
+	if (c != value)
+		fprintf(stderr, "Error on insert: key %x expected %x got %x\n", (unsigned)key, value, c);
+#endif
+	return r;
+}
+
+VALUE_TYPE
+citrus_trie_node_lookup(citrus_trie_header_t h, citrus_trie_node_t t, size_t level, citrus_trie_key_t key)
+{
+	size_t idx;
+
+	idx = (key >> (level * h->th_bitwidth)) & h->th_bitmask;
+	if (idx < h->th_off)
+		return INVALID_VALUE;
+
+	idx -= h->th_off;
+	if (idx >= t->tr_len)
+		return INVALID_VALUE;
+
+	if (level == 0) {
+		return t->tr_u[idx].u_value;
+	}
+	return citrus_trie_node_lookup(h, t->tr_u[idx].u_child, level - 1, key);
+}
+
+VALUE_TYPE
+citrus_trie_lookup(citrus_trie_header_t h, citrus_trie_key_t key)
+{
+	return citrus_trie_node_lookup(h, h->th_root, h->th_level, key);
+}
+
+/*
+ * Assume VALUE_TYPE flat[N][2].
+ */
+citrus_trie_header_t
+citrus_trie_create_from_flat(VALUE_TYPE *flat, size_t bitwidth, int count) {
+	VALUE_TYPE ne_key;
+	int i, j;
+	unsigned val;
+	citrus_trie_header_t h;
+	size_t bitmask = (1 << bitwidth) - 1;
+	size_t maxshift = (8 * sizeof(VALUE_TYPE)) / bitwidth;
+	size_t min = bitmask, max = 0, level = 0;
+
+	/* Loop through every element to see what
+	   level, off and len should be */
+	for (i = 0; i < count; i++) {
+		ne_key = flat[i * 2];
+		for (j = 0; j < maxshift; j++) {
+			val = (ne_key >> (j * bitwidth)) & bitmask;
+			if (level < j + 1 && val)
+level = j + 1;
+			if (min > val)
+min = val;
+			if (max < val)
+max = val;
+		}
+	}
+
+	h = citrus_trie_create(0x0, bitwidth, level, min, max - min + 1);
+
+	/* Now add every value */
+	for (i = 0; i < count; i++) {
+		ne_key = flat[i * 2];
+		
+		citrus_trie_insert(h, ne_key, flat[i * 2 

CVS commit: [perseant-stdc-iso10646] src

2018-01-20 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Sat Jan 20 19:36:29 UTC 2018

Modified Files:
src/include [perseant-stdc-iso10646]: wchar.h
src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_lc_collate.c
src/lib/libc/citrus/modules [perseant-stdc-iso10646]: citrus_big5.c
citrus_euc.c citrus_iso2022.c citrus_mskanji.c
src/lib/libc/locale [perseant-stdc-iso10646]: collate.h
collate_locale.c ducet_collation_data.h unicode_ucd.c
src/tools [perseant-stdc-iso10646]: Makefile
src/usr.bin/localedef [perseant-stdc-iso10646]: Makefile collate.c
Added Files:
src/lib/libc/citrus/modules [perseant-stdc-iso10646]: citrus_big5_k2u.h
citrus_big5_u2k.h citrus_euc_k2u.h citrus_euc_u2k.h
citrus_iso2022_k2u.h citrus_iso2022_u2k.h citrus_mskanji_k2u.h
citrus_mskanji_u2k.h
Removed Files:
src/usr.bin/localedef [perseant-stdc-iso10646]: localedef parser.c
parser.h

Log Message:
Use multilevel tables (tries) to convert kuten <-> unicode.
Get rid of dchains, replace with chain/rchain conversions through keys
allocated from the PUA.


To generate a diff of this commit:
cvs rdiff -u -r1.42.8.1 -r1.42.8.2 src/include/wchar.h
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/lib/libc/citrus/citrus_lc_collate.c
cvs rdiff -u -r1.15.18.3 -r1.15.18.4 \
src/lib/libc/citrus/modules/citrus_big5.c
cvs rdiff -u -r0 -r1.1.2.1 src/lib/libc/citrus/modules/citrus_big5_k2u.h \
src/lib/libc/citrus/modules/citrus_big5_u2k.h \
src/lib/libc/citrus/modules/citrus_euc_k2u.h \
src/lib/libc/citrus/modules/citrus_euc_u2k.h \
src/lib/libc/citrus/modules/citrus_iso2022_k2u.h \
src/lib/libc/citrus/modules/citrus_iso2022_u2k.h \
src/lib/libc/citrus/modules/citrus_mskanji_k2u.h \
src/lib/libc/citrus/modules/citrus_mskanji_u2k.h
cvs rdiff -u -r1.17.20.3 -r1.17.20.4 src/lib/libc/citrus/modules/citrus_euc.c
cvs rdiff -u -r1.23.22.3 -r1.23.22.4 \
src/lib/libc/citrus/modules/citrus_iso2022.c
cvs rdiff -u -r1.14.22.3 -r1.14.22.4 \
src/lib/libc/citrus/modules/citrus_mskanji.c
cvs rdiff -u -r1.1.40.1 -r1.1.40.2 src/lib/libc/locale/collate.h
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/lib/libc/locale/collate_locale.c \
src/lib/libc/locale/unicode_ucd.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/lib/libc/locale/ducet_collation_data.h
cvs rdiff -u -r1.191 -r1.191.2.1 src/tools/Makefile
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/usr.bin/localedef/Makefile \
src/usr.bin/localedef/collate.c
cvs rdiff -u -r1.1.2.1 -r0 src/usr.bin/localedef/localedef \
src/usr.bin/localedef/parser.c src/usr.bin/localedef/parser.h

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

diffs are larger than 1MB and have been omitted


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: [perseant-stdc-iso10646] src

2017-08-07 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Aug  7 14:27:11 UTC 2017

Modified Files:
src/lib/libc/locale [perseant-stdc-iso10646]: _wctrans_local.h rune.c
src/usr.bin [perseant-stdc-iso10646]: Makefile

Log Message:
Make it compile again when __STDC_ISO_10646__ is not defined.


To generate a diff of this commit:
cvs rdiff -u -r1.9.40.1 -r1.9.40.2 src/lib/libc/locale/_wctrans_local.h
cvs rdiff -u -r1.46.22.2 -r1.46.22.3 src/lib/libc/locale/rune.c
cvs rdiff -u -r1.229 -r1.229.4.1 src/usr.bin/Makefile

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/locale/_wctrans_local.h
diff -u src/lib/libc/locale/_wctrans_local.h:1.9.40.1 src/lib/libc/locale/_wctrans_local.h:1.9.40.2
--- src/lib/libc/locale/_wctrans_local.h:1.9.40.1	Fri Jul 21 20:22:29 2017
+++ src/lib/libc/locale/_wctrans_local.h	Mon Aug  7 14:27:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: _wctrans_local.h,v 1.9.40.1 2017/07/21 20:22:29 perseant Exp $	*/
+/*	$NetBSD: _wctrans_local.h,v 1.9.40.2 2017/08/07 14:27:11 perseant Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -40,7 +40,7 @@ __END_DECLS
 static __inline wint_t
 _towctrans_priv(wint_ucs4_t c, _WCTransEntry const *te, const _RuneLocale *rl)
 {
-	wint_kuten_t ktc;
+	wint_kuten_t ktc = 0;
 
 	_citrus_ctype_ucs2kt(rl->rl_citrus_ctype, , c);
 	ktc = (_RUNE_ISCACHED(ktc)

Index: src/lib/libc/locale/rune.c
diff -u src/lib/libc/locale/rune.c:1.46.22.2 src/lib/libc/locale/rune.c:1.46.22.3
--- src/lib/libc/locale/rune.c:1.46.22.2	Fri Jul 21 20:22:29 2017
+++ src/lib/libc/locale/rune.c	Mon Aug  7 14:27:11 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rune.c,v 1.46.22.2 2017/07/21 20:22:29 perseant Exp $	*/
+/*	$NetBSD: rune.c,v 1.46.22.3 2017/08/07 14:27:11 perseant Exp $	*/
 /*-
  * Copyright (c)2010 Citrus Project,
  * All rights reserved.
@@ -312,12 +312,10 @@ do {	\
 
 #define CONVERT_MAP(name)		\
 do {	\
-	wint_ucs4_t map;		\
-	wint_kuten_t kmap;		\
+	wint_kuten_t map;		\
 	int c;\
 	\
 	map = _towctrans_priv(wc, _wctrans_##name(rl), rl);		\
-	_citrus_ctype_ucs2kt(rl->rl_citrus_ctype, , map);		\
 	if (map == wc || (_citrus_ctype_wctob(rl->rl_citrus_ctype,	\
 	map, )  || c == EOF))	\
 		c = i;			\

Index: src/usr.bin/Makefile
diff -u src/usr.bin/Makefile:1.229 src/usr.bin/Makefile:1.229.4.1
--- src/usr.bin/Makefile:1.229	Sun May 21 15:28:42 2017
+++ src/usr.bin/Makefile	Mon Aug  7 14:27:11 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.229 2017/05/21 15:28:42 riastradh Exp $
+#	$NetBSD: Makefile,v 1.229.4.1 2017/08/07 14:27:11 perseant Exp $
 #	from: @(#)Makefile	8.3 (Berkeley) 1/7/94
 
 .include 
@@ -15,7 +15,7 @@ SUBDIR= apply asa at audio audiocfg \
 	getopt gettext gprof \
 	head hexdump iconv id indent infocmp innetgr ipcrm ipcs join jot \
 	kdump ktrace ktruss lam last lastcomm ldd leave \
-	locale locate lock logger login logname look lorder m4 \
+	locale localedef locate lock logger login logname look lorder m4 \
 	machine mail make man menuc mesg midiplay midirecord mixerctl \
 	mkcsmapper mkdep mkesdb mkfifo mklocale mkstr mktemp mkubootimage \
 	moduli msgc msgs \



CVS commit: [perseant-stdc-iso10646] src/lib/libc/locale

2017-08-01 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Tue Aug  1 19:35:51 UTC 2017

Added Files:
src/lib/libc/locale [perseant-stdc-iso10646]: collate.h
ducet_collation_data.h unicode_dm_data.h

Log Message:
Add files missing from last commit (commitid: 7B1ZL3FMi0tUSk1A):

Support loading collation data from file.  Began with FreeBSD's
xlocale_collate, but had to change it somewhat to accommodate the
requirements of the Unicode Collation Algorithm (in particular,
there are maps from single-character collation elements to
multiple collation weight vectors, and multiple-to-multiple
mappings as well).


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.40.1 src/lib/libc/locale/collate.h
cvs rdiff -u -r0 -r1.1.2.1 src/lib/libc/locale/ducet_collation_data.h \
src/lib/libc/locale/unicode_dm_data.h

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

diffs are larger than 1MB and have been omitted


CVS commit: [perseant-stdc-iso10646] src/lib/libc

2017-07-30 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Jul 31 04:29:50 UTC 2017

Modified Files:
src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_lc_collate.c
src/lib/libc/locale [perseant-stdc-iso10646]: collate_local.h
collate_locale.c unicode_collate.c unicode_nfd_qc_data.h
unicode_ucd.c unicode_ucd.h

Log Message:
Support loading collation data from file.  Began with FreeBSD's
xlocale_collate, but had to change it somewhat to accommodate the
requirements of the Unicode Collation Algorithm (in particular,
there are maps from single-character collation elements to
multiple collation weight vectors, and multiple-to-multiple
mappings as well).


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/lib/libc/citrus/citrus_lc_collate.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/lib/libc/locale/collate_local.h \
src/lib/libc/locale/collate_locale.c \
src/lib/libc/locale/unicode_collate.c \
src/lib/libc/locale/unicode_nfd_qc_data.h \
src/lib/libc/locale/unicode_ucd.c src/lib/libc/locale/unicode_ucd.h

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/citrus/citrus_lc_collate.c
diff -u src/lib/libc/citrus/citrus_lc_collate.c:1.1.2.1 src/lib/libc/citrus/citrus_lc_collate.c:1.1.2.2
--- src/lib/libc/citrus/citrus_lc_collate.c:1.1.2.1	Fri Jul 14 15:53:07 2017
+++ src/lib/libc/citrus/citrus_lc_collate.c	Mon Jul 31 04:29:50 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_lc_collate.c,v 1.1.2.1 2017/07/14 15:53:07 perseant Exp $ */
+/* $NetBSD: citrus_lc_collate.c,v 1.1.2.2 2017/07/31 04:29:50 perseant Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_lc_collate.c,v 1.1.2.1 2017/07/14 15:53:07 perseant Exp $");
+__RCSID("$NetBSD: citrus_lc_collate.c,v 1.1.2.2 2017/07/31 04:29:50 perseant Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "reentrant.h"
@@ -65,13 +65,13 @@ __RCSID("$NetBSD: citrus_lc_collate.c,v 
 /*
  * macro required by nb_lc_template(_decl).h
  */
-#define _CATEGORY_TYPE  _CollateLocale
+#define _CATEGORY_TYPE  struct xlocale_collate
 
 #include "nb_lc_template_decl.h"
 
 static int
 _citrus_LC_COLLATE_create_impl(const char * __restrict root,
-const char * __restrict name, _CollateLocale ** __restrict pdata)
+const char * __restrict name, struct xlocale_collate ** __restrict pdata)
 {
 	char path[PATH_MAX + 1];
 	int ret;
@@ -92,7 +92,7 @@ _citrus_LC_COLLATE_create_impl(const cha
 }
 
 static __inline void
-_PREFIX(update_global)(_CollateLocale *data)
+_PREFIX(update_global)(struct xlocale_collate *data)
 {
 	_DIAGASSERT(data != NULL);
 }

Index: src/lib/libc/locale/collate_local.h
diff -u src/lib/libc/locale/collate_local.h:1.1.2.1 src/lib/libc/locale/collate_local.h:1.1.2.2
--- src/lib/libc/locale/collate_local.h:1.1.2.1	Fri Jul 14 15:53:08 2017
+++ src/lib/libc/locale/collate_local.h	Mon Jul 31 04:29:50 2017
@@ -1,26 +1,45 @@
-/*	$NetBSD: collate_local.h,v 1.1.2.1 2017/07/14 15:53:08 perseant Exp $	*/
+/*	$NetBSD: collate_local.h,v 1.1.2.2 2017/07/31 04:29:50 perseant Exp $	*/
 
 #ifndef	_COLLATE_LOCAL_H_
 #define	_COLLATE_LOCAL_H_
 
 #include 
+#include "collate.h"
 
 #include "unicode_ucd.h"
 
 typedef struct _CollateLocale {
 	void		*coll_variable;
 	size_t		 coll_variable_len;
-	struct ucd_coll *coll_data;
+	struct ucd_coll*coll_data; /* XXX obsolescent */
 	size_t   coll_data_len;
+	const struct _FileCollateLocale *coll_fcl;
+#define coll_collinfo  coll_fcl->fcl_collinfo
+#define coll_char_data coll_fcl->fcl_char_data
+	const collate_subst_t  *coll_subst;
+	const collate_chain_t  *coll_chains;
+	const collate_large_t  *coll_large;
 } _CollateLocale;
 
+typedef struct _FileCollateLocale {
+	collate_info_t  fcl_collinfo;
+	collate_char_t  fcl_char_data[0x100];
+/*
+These fields are variable length (perhaps 0)
+	and follow the previous fields in the file:
+	collate_chain_t *chains;
+	collate_large_t *large;
+	collate_subst_t *subst;
+*/
+} _FileCollateLocale;
+
 /*
  * global variables
  */
-extern __dso_hidden const _CollateLocale _DefaultCollateLocale;
+extern __dso_hidden const struct xlocale_collate _DefaultCollateLocale;
 
 __BEGIN_DECLS
-int _collate_load(const char * __restrict, size_t, _CollateLocale ** __restrict);
+int _collate_load(const char * __restrict, size_t, struct xlocale_collate ** __restrict);
 __END_DECLS
 
 #endif	/* !_COLLATE_LOCAL_H_ */
Index: src/lib/libc/locale/collate_locale.c
diff -u src/lib/libc/locale/collate_locale.c:1.1.2.1 src/lib/libc/locale/collate_locale.c:1.1.2.2
--- src/lib/libc/locale/collate_locale.c:1.1.2.1	Fri Jul 14 15:53:08 2017
+++ src/lib/libc/locale/collate_locale.c	Mon Jul 31 04:29:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: collate_locale.c,v 1.1.2.1 2017/07/14 15:53:08 perseant Exp $	*/
+/*	$NetBSD: collate_locale.c,v 1.1.2.2 

CVS commit: [perseant-stdc-iso10646] src/lib/libc/citrus

2017-07-30 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Jul 31 04:23:35 UTC 2017

Modified Files:
src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_ctype.h
citrus_ctype_template.h
src/lib/libc/citrus/modules [perseant-stdc-iso10646]: citrus_big5.c
citrus_euc.c citrus_iso2022.c citrus_mskanji.c

Log Message:
Make the compilation conditional on __STDC_ISO_10646__, so that applications
that need one of the East Asian locales but don't want __STDC_ISO_10646__
don't have to pay the penalty for it.


To generate a diff of this commit:
cvs rdiff -u -r1.3.22.1 -r1.3.22.2 src/lib/libc/citrus/citrus_ctype.h
cvs rdiff -u -r1.36.22.1 -r1.36.22.2 \
src/lib/libc/citrus/citrus_ctype_template.h
cvs rdiff -u -r1.15.18.2 -r1.15.18.3 \
src/lib/libc/citrus/modules/citrus_big5.c
cvs rdiff -u -r1.17.20.2 -r1.17.20.3 src/lib/libc/citrus/modules/citrus_euc.c
cvs rdiff -u -r1.23.22.2 -r1.23.22.3 \
src/lib/libc/citrus/modules/citrus_iso2022.c
cvs rdiff -u -r1.14.22.2 -r1.14.22.3 \
src/lib/libc/citrus/modules/citrus_mskanji.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/citrus/citrus_ctype.h
diff -u src/lib/libc/citrus/citrus_ctype.h:1.3.22.1 src/lib/libc/citrus/citrus_ctype.h:1.3.22.2
--- src/lib/libc/citrus/citrus_ctype.h:1.3.22.1	Fri Jul 21 20:22:29 2017
+++ src/lib/libc/citrus/citrus_ctype.h	Mon Jul 31 04:23:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: citrus_ctype.h,v 1.3.22.1 2017/07/21 20:22:29 perseant Exp $	*/
+/*	$NetBSD: citrus_ctype.h,v 1.3.22.2 2017/07/31 04:23:35 perseant Exp $	*/
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -30,6 +30,7 @@
 #ifndef _CITRUS_CTYPE_H_
 #define _CITRUS_CTYPE_H_
 
+#include  /* For __STDC_ISO_10646__ */
 #include "citrus_ctype_local.h"
 
 typedef struct _citrus_ctype_rec *_citrus_ctype_t;
@@ -185,6 +186,7 @@ _citrus_ctype_wctob(_citrus_ctype_t cc, 
 	return (*cc->cc_ops->co_wctob)(cc, c, cresult);
 }
 
+#ifdef __STDC_ISO_10646__
 static __inline int
 _citrus_ctype_ucs2kt(_citrus_ctype_t cc,
 		  wchar_kuten_t * __restrict ktp,
@@ -202,6 +204,11 @@ _citrus_ctype_kt2ucs(_citrus_ctype_t cc,
 	_DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_kt2ucs);
 	return (*cc->cc_ops->co_kt2ucs)(cc->cc_closure, up, kt);
 }
+#else
+/* Define away the calls to these functions */
+#define _citrus_ctype_ucs2kt(cl, ktp, wc) do {} while (0)
+#define _citrus_ctype_kt2ucs(cl, up, kt) do {} while (0)
+#endif
 
 extern _citrus_ctype_rec_t _citrus_ctype_default;
 

Index: src/lib/libc/citrus/citrus_ctype_template.h
diff -u src/lib/libc/citrus/citrus_ctype_template.h:1.36.22.1 src/lib/libc/citrus/citrus_ctype_template.h:1.36.22.2
--- src/lib/libc/citrus/citrus_ctype_template.h:1.36.22.1	Fri Jul 21 20:22:29 2017
+++ src/lib/libc/citrus/citrus_ctype_template.h	Mon Jul 31 04:23:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: citrus_ctype_template.h,v 1.36.22.1 2017/07/21 20:22:29 perseant Exp $	*/
+/*	$NetBSD: citrus_ctype_template.h,v 1.36.22.2 2017/07/31 04:23:35 perseant Exp $	*/
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -118,6 +118,7 @@
  *
  */
 
+#include  /* For __STDC_ISO_10646__ */
 
 /* prototypes */
 
@@ -938,6 +939,7 @@ _FUNCNAME(ctype_wctob)(_citrus_ctype_rec
 	return 0;
 }
 
+#ifdef __STDC_ISO_10646__
 static __inline int
 /*ARGSUSED*/
 _FUNCNAME(ctype_ucs2kt)(void * __restrict cl,
@@ -953,4 +955,8 @@ _FUNCNAME(ctype_kt2ucs)(void * __restric
 {
 	return _FUNCNAME(kt2ucs)(_CEI_TO_EI(_TO_CEI(cl)), up, kt);
 }
-
+#else
+/* Define away the calls to these functions */
+#define _FUNCNAME(ctype_ucs2kt)(cl, ktp, wc) do {} while (0)
+#define _FUNCNAME(ctype_kt2ucs)(cl, up, kt) do {} while (0)
+#endif

Index: src/lib/libc/citrus/modules/citrus_big5.c
diff -u src/lib/libc/citrus/modules/citrus_big5.c:1.15.18.2 src/lib/libc/citrus/modules/citrus_big5.c:1.15.18.3
--- src/lib/libc/citrus/modules/citrus_big5.c:1.15.18.2	Fri Jul 21 20:22:29 2017
+++ src/lib/libc/citrus/modules/citrus_big5.c	Mon Jul 31 04:23:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: citrus_big5.c,v 1.15.18.2 2017/07/21 20:22:29 perseant Exp $	*/
+/*	$NetBSD: citrus_big5.c,v 1.15.18.3 2017/07/31 04:23:35 perseant Exp $	*/
 
 /*-
  * Copyright (c)2002, 2006 Citrus Project,
@@ -60,7 +60,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_big5.c,v 1.15.18.2 2017/07/21 20:22:29 perseant Exp $");
+__RCSID("$NetBSD: citrus_big5.c,v 1.15.18.3 2017/07/31 04:23:35 perseant Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include 
@@ -134,6 +134,7 @@ typedef struct {
 #define _ENCODING_IS_STATE_DEPENDENT	0
 #define _STATE_NEEDS_EXPLICIT_INIT(_ps_)	0
 
+#ifdef __STDC_ISO_10646__
 #include "citrus_big5_data.h"
 
 static __inline int
@@ -188,6 +189,9 @@ _FUNCNAME(kt2ucs)(_ENCODING_INFO * __res
 
 	return 0;
 }
+#else
+#include "citrus_u2k_template.h"
+#endif
 
 static __inline void
 /*ARGSUSED*/

Index: src/lib/libc/citrus/modules/citrus_euc.c
diff -u 

CVS commit: src/distrib/sets/lists

2017-07-23 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Sun Jul 23 19:26:06 UTC 2017

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi

Log Message:
Add missing setlist entries for DUCET collation test.


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.757 -r1.758 src/distrib/sets/lists/tests/mi

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.220 src/distrib/sets/lists/debug/mi:1.221
--- src/distrib/sets/lists/debug/mi:1.220	Fri Jul 14 14:57:43 2017
+++ src/distrib/sets/lists/debug/mi	Sun Jul 23 19:26:05 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.220 2017/07/14 14:57:43 perseant Exp $
+# $NetBSD: mi,v 1.221 2017/07/23 19:26:05 perseant 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
@@ -1947,6 +1947,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_ctype2.debug		tests-obsolete		obsolete,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_btowc.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_digittoint.debug	tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/locale/t_ducet.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_io.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_mbrtowc.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_mbsnrtowcs.debug	tests-lib-debug		debug,atf,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.757 src/distrib/sets/lists/tests/mi:1.758
--- src/distrib/sets/lists/tests/mi:1.757	Tue Jul 18 02:16:07 2017
+++ src/distrib/sets/lists/tests/mi	Sun Jul 23 19:26:06 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.757 2017/07/18 02:16:07 ozaki-r Exp $
+# $NetBSD: mi,v 1.758 2017/07/23 19:26:06 perseant Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2544,6 +2544,7 @@
 ./usr/tests/lib/libc/locale/t_ctype2		tests-obsolete		obsolete
 ./usr/tests/lib/libc/locale/t_btowc		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_digittoint	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/locale/t_ducet		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_io		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_mbrtowc		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_mbsnrtowcs	tests-lib-tests		compattestfile,atf



CVS commit: [perseant-stdc-iso10646] src/tests/lib/libc/locale

2017-07-23 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Sun Jul 23 19:16:11 UTC 2017

Modified Files:
src/tests/lib/libc/locale [perseant-stdc-iso10646]: Makefile
ducet_test.h t_ducet.c

Log Message:
Add Unicode copyright notice and more verbose DUCET test.


To generate a diff of this commit:
cvs rdiff -u -r1.10.2.1 -r1.10.2.2 src/tests/lib/libc/locale/Makefile
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/tests/lib/libc/locale/ducet_test.h \
src/tests/lib/libc/locale/t_ducet.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.10.2.1 src/tests/lib/libc/locale/Makefile:1.10.2.2
--- src/tests/lib/libc/locale/Makefile:1.10.2.1	Fri Jul 14 15:53:08 2017
+++ src/tests/lib/libc/locale/Makefile	Sun Jul 23 19:16:11 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10.2.1 2017/07/14 15:53:08 perseant Exp $
+# $NetBSD: Makefile,v 1.10.2.2 2017/07/23 19:16:11 perseant Exp $
 
 .include 
 

Index: src/tests/lib/libc/locale/ducet_test.h
diff -u src/tests/lib/libc/locale/ducet_test.h:1.1.2.1 src/tests/lib/libc/locale/ducet_test.h:1.1.2.2
--- src/tests/lib/libc/locale/ducet_test.h:1.1.2.1	Fri Jul 14 15:53:08 2017
+++ src/tests/lib/libc/locale/ducet_test.h	Sun Jul 23 19:16:11 2017
@@ -6,6 +6,39 @@
 /* UCA Version: 10.0.0*/
 /* UCD Version: 10.0.0*/
 /* For a description of the format and usage, see CollationTest.html*/
+/*
+ * Copyright © 1991-2017 Unicode, Inc. All rights reserved.
+ * Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of the Unicode data files and any associated documentation
+ * (the "Data Files") or Unicode software and any associated documentation
+ * (the "Software") to deal in the Data Files or Software
+ * without restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, and/or sell copies of
+ * the Data Files or Software, and to permit persons to whom the Data Files
+ * or Software are furnished to do so, provided that either
+ * (a) this copyright and permission notice appear with all copies
+ * of the Data Files or Software, or
+ * (b) this copyright and permission notice appear in associated
+ * Documentation.
+ * 
+ * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+ * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
+ * NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
+ * DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THE DATA FILES OR SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in these Data Files or Software without prior
+ * written authorization of the copyright holder.
+ */
 #define MAX_TS_LEN 7
 wchar_t ducet_test_data[][MAX_TS_LEN] = {
 {0x0338, 0x0334, 0x0},
Index: src/tests/lib/libc/locale/t_ducet.c
diff -u src/tests/lib/libc/locale/t_ducet.c:1.1.2.1 src/tests/lib/libc/locale/t_ducet.c:1.1.2.2
--- src/tests/lib/libc/locale/t_ducet.c:1.1.2.1	Fri Jul 14 15:53:08 2017
+++ src/tests/lib/libc/locale/t_ducet.c	Sun Jul 23 19:16:11 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ducet.c,v 1.1.2.1 2017/07/14 15:53:08 perseant Exp $ */
+/* $NetBSD: t_ducet.c,v 1.1.2.2 2017/07/23 19:16:11 perseant Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2011\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_ducet.c,v 1.1.2.1 2017/07/14 15:53:08 perseant Exp $");
+__RCSID("$NetBSD: t_ducet.c,v 1.1.2.2 2017/07/23 19:16:11 perseant Exp $");
 
 #include 
 #include 
@@ -98,7 +98,7 @@ ATF_TC_BODY(wcsxfrm_ducet, tc)
 	wchar_t *tmp, *oline = NULL, *line;
 	wchar_t xfb1[BUFLEN], xfb2[BUFLEN]; /* Gross overestimates */
 	wchar_t *oxf = xfb1, *xf = xfb2;
-	int i, lineno = 0;
+	int i, lineno = 0, result;
 
 	setlocale(LC_COLLATE, "en_US.UTF-8"); /* should be "vanilla" DUCET, but en_US will do */
 	ATF_REQUIRE_STREQ("en_US.UTF-8", setlocale(LC_COLLATE, NULL));
@@ -122,7 +122,18 @@ ATF_TC_BODY(wcsxfrm_ducet, tc)
 		printf("\n");
 		
 		wcsxfrm(xf, line, BUFLEN);
-		ATF_CHECK(wcscmp(oxf, xf) < 0);
+		result = wcscmp(oxf, xf);
+		if (result > 0) {
+			printf("FAILED result was %d\nweights were ", result);
+			for (i = 0; oxf[i] != 0; i++)
+printf("0x%lx ", (long)oline[i]);
+			printf(" and ");
+			for (i = 0; xf[i] != 0; 

CVS commit: [perseant-stdc-iso10646, trunk] src

2017-07-23 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Sun Jul 23 18:51:21 UTC 2017

Modified Files:
src/tests/lib/libc/locale: Makefile
src/lib/libc/iconv [perseant-stdc-iso10646]: iconv.c
Added Files:
src/tests/lib/libc/locale: ducet_test.h t_ducet.c
src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_u2k_template.h

Log Message:
Add missing files from last commit:

Move Unicode <-> ku/ten mapping into the individual codec modules.
Mapping is based on existing iconv data for single-byte encodings,
and included for several, but not all, multibyte encodings.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.1 src/lib/libc/citrus/citrus_u2k_template.h
cvs rdiff -u -r1.13 -r1.13.34.1 src/lib/libc/iconv/iconv.c
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/locale/Makefile
cvs rdiff -u -r0 -r1.2 src/tests/lib/libc/locale/ducet_test.h \
src/tests/lib/libc/locale/t_ducet.c

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

diffs are larger than 1MB and have been omitted


CVS commit: [perseant-stdc-iso10646] src/lib/libc

2017-07-21 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Fri Jul 21 20:22:29 UTC 2017

Modified Files:
src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_ctype.c
citrus_ctype.h citrus_ctype_fallback.c citrus_ctype_fallback.h
citrus_ctype_local.h citrus_ctype_template.h citrus_iconv.h
citrus_iconv_local.h citrus_namespace.h citrus_none.c
citrus_stdenc.h citrus_stdenc_local.h citrus_stdenc_template.h
src/lib/libc/citrus/modules [perseant-stdc-iso10646]: citrus_big5.c
citrus_dechanyu.c citrus_euc.c citrus_euctw.c citrus_gbk2k.c
citrus_hz.c citrus_iconv_none.c citrus_iconv_std.c citrus_iso2022.c
citrus_johab.c citrus_mskanji.c citrus_ues.c citrus_utf1632.c
citrus_utf7.c citrus_utf8.c citrus_viqr.c citrus_zw.c
src/lib/libc/locale [perseant-stdc-iso10646]: Makefile.inc _wctrans.c
_wctrans_local.h _wctype.c iswctype_mb.c multibyte.h
multibyte_amd1.c multibyte_c90.c rune.c
Added Files:
src/lib/libc/citrus/modules [perseant-stdc-iso10646]:
citrus_big5_data.h citrus_euc_data.h citrus_iso2022_data.h
citrus_mskanji_data.h
Removed Files:
src/lib/libc/locale [perseant-stdc-iso10646]: rune_iso10646.c
rune_iso10646.h u2k.h

Log Message:
Move Unicode <-> ku/ten mapping into the individual codec modules.
Mapping is based on existing iconv data for single-byte encodings,
and included for several, but not all, multibyte encodings.


To generate a diff of this commit:
cvs rdiff -u -r1.7.22.1 -r1.7.22.2 src/lib/libc/citrus/citrus_ctype.c
cvs rdiff -u -r1.3 -r1.3.22.1 src/lib/libc/citrus/citrus_ctype.h \
src/lib/libc/citrus/citrus_ctype_fallback.c
cvs rdiff -u -r1.2 -r1.2.22.1 src/lib/libc/citrus/citrus_ctype_fallback.h
cvs rdiff -u -r1.4 -r1.4.22.1 src/lib/libc/citrus/citrus_ctype_local.h
cvs rdiff -u -r1.36 -r1.36.22.1 src/lib/libc/citrus/citrus_ctype_template.h
cvs rdiff -u -r1.5.64.1 -r1.5.64.2 src/lib/libc/citrus/citrus_iconv.h
cvs rdiff -u -r1.3.64.1 -r1.3.64.2 src/lib/libc/citrus/citrus_iconv_local.h
cvs rdiff -u -r1.8.42.1 -r1.8.42.2 src/lib/libc/citrus/citrus_namespace.h
cvs rdiff -u -r1.22.2.1 -r1.22.2.2 src/lib/libc/citrus/citrus_none.c
cvs rdiff -u -r1.4.80.1 -r1.4.80.2 src/lib/libc/citrus/citrus_stdenc.h
cvs rdiff -u -r1.4.64.1 -r1.4.64.2 src/lib/libc/citrus/citrus_stdenc_local.h \
src/lib/libc/citrus/citrus_stdenc_template.h
cvs rdiff -u -r1.15.18.1 -r1.15.18.2 \
src/lib/libc/citrus/modules/citrus_big5.c
cvs rdiff -u -r0 -r1.1.2.1 src/lib/libc/citrus/modules/citrus_big5_data.h \
src/lib/libc/citrus/modules/citrus_euc_data.h \
src/lib/libc/citrus/modules/citrus_iso2022_data.h \
src/lib/libc/citrus/modules/citrus_mskanji_data.h
cvs rdiff -u -r1.5.22.1 -r1.5.22.2 \
src/lib/libc/citrus/modules/citrus_dechanyu.c \
src/lib/libc/citrus/modules/citrus_zw.c
cvs rdiff -u -r1.17.20.1 -r1.17.20.2 src/lib/libc/citrus/modules/citrus_euc.c
cvs rdiff -u -r1.12.22.1 -r1.12.22.2 \
src/lib/libc/citrus/modules/citrus_euctw.c
cvs rdiff -u -r1.8.22.1 -r1.8.22.2 src/lib/libc/citrus/modules/citrus_gbk2k.c
cvs rdiff -u -r1.4.18.1 -r1.4.18.2 src/lib/libc/citrus/modules/citrus_hz.c
cvs rdiff -u -r1.3.38.1 -r1.3.38.2 \
src/lib/libc/citrus/modules/citrus_iconv_none.c
cvs rdiff -u -r1.16.34.1 -r1.16.34.2 \
src/lib/libc/citrus/modules/citrus_iconv_std.c
cvs rdiff -u -r1.23.22.1 -r1.23.22.2 \
src/lib/libc/citrus/modules/citrus_iso2022.c
cvs rdiff -u -r1.6.10.1 -r1.6.10.2 src/lib/libc/citrus/modules/citrus_johab.c
cvs rdiff -u -r1.14.22.1 -r1.14.22.2 \
src/lib/libc/citrus/modules/citrus_mskanji.c
cvs rdiff -u -r1.4.22.1 -r1.4.22.2 src/lib/libc/citrus/modules/citrus_ues.c
cvs rdiff -u -r1.12.34.1 -r1.12.34.2 \
src/lib/libc/citrus/modules/citrus_utf1632.c
cvs rdiff -u -r1.6.22.1 -r1.6.22.2 src/lib/libc/citrus/modules/citrus_utf7.c \
src/lib/libc/citrus/modules/citrus_viqr.c
cvs rdiff -u -r1.18.22.1 -r1.18.22.2 \
src/lib/libc/citrus/modules/citrus_utf8.c
cvs rdiff -u -r1.64.20.1 -r1.64.20.2 src/lib/libc/locale/Makefile.inc
cvs rdiff -u -r1.17 -r1.17.40.1 src/lib/libc/locale/_wctrans.c
cvs rdiff -u -r1.9 -r1.9.40.1 src/lib/libc/locale/_wctrans_local.h
cvs rdiff -u -r1.9.40.1 -r1.9.40.2 src/lib/libc/locale/_wctype.c
cvs rdiff -u -r1.13.22.1 -r1.13.22.2 src/lib/libc/locale/iswctype_mb.c
cvs rdiff -u -r1.6 -r1.6.20.1 src/lib/libc/locale/multibyte.h
cvs rdiff -u -r1.14.20.1 -r1.14.20.2 src/lib/libc/locale/multibyte_amd1.c
cvs rdiff -u -r1.12.20.1 -r1.12.20.2 src/lib/libc/locale/multibyte_c90.c
cvs rdiff -u -r1.46.22.1 -r1.46.22.2 src/lib/libc/locale/rune.c
cvs rdiff -u -r1.1.2.1 -r0 src/lib/libc/locale/rune_iso10646.c \
src/lib/libc/locale/rune_iso10646.h src/lib/libc/locale/u2k.h

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

diffs are larger than 1MB and have been omitted


CVS commit: [perseant-stdc-iso10646] src/distrib/sets/lists

2017-07-18 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Tue Jul 18 14:55:29 UTC 2017

Modified Files:
src/distrib/sets/lists/debug [perseant-stdc-iso10646]: mi
src/distrib/sets/lists/tests [perseant-stdc-iso10646]: mi

Log Message:
Add t_ducet test


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.220.2.1 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.757 -r1.757.2.1 src/distrib/sets/lists/tests/mi

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.220 src/distrib/sets/lists/debug/mi:1.220.2.1
--- src/distrib/sets/lists/debug/mi:1.220	Fri Jul 14 14:57:43 2017
+++ src/distrib/sets/lists/debug/mi	Tue Jul 18 14:55:29 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.220 2017/07/14 14:57:43 perseant Exp $
+# $NetBSD: mi,v 1.220.2.1 2017/07/18 14:55:29 perseant 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
@@ -1947,6 +1947,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_ctype2.debug		tests-obsolete		obsolete,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_btowc.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_digittoint.debug	tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/locale/t_ducet.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_io.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_mbrtowc.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_mbsnrtowcs.debug	tests-lib-debug		debug,atf,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.757 src/distrib/sets/lists/tests/mi:1.757.2.1
--- src/distrib/sets/lists/tests/mi:1.757	Tue Jul 18 02:16:07 2017
+++ src/distrib/sets/lists/tests/mi	Tue Jul 18 14:55:29 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.757 2017/07/18 02:16:07 ozaki-r Exp $
+# $NetBSD: mi,v 1.757.2.1 2017/07/18 14:55:29 perseant Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2544,6 +2544,7 @@
 ./usr/tests/lib/libc/locale/t_ctype2		tests-obsolete		obsolete
 ./usr/tests/lib/libc/locale/t_btowc		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_digittoint	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/locale/t_ducet		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_io		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_mbrtowc		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_mbsnrtowcs	tests-lib-tests		compattestfile,atf



CVS commit: [perseant-stdc-iso10646] src

2017-07-14 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Fri Jul 14 15:53:08 UTC 2017

Modified Files:
src/include [perseant-stdc-iso10646]: wchar.h
src/lib/libc/citrus [perseant-stdc-iso10646]: Makefile.inc
citrus_ctype.c citrus_iconv.c citrus_iconv.h citrus_iconv_local.h
citrus_namespace.h citrus_none.c citrus_stdenc.h
citrus_stdenc_local.h citrus_stdenc_template.h
src/lib/libc/citrus/modules [perseant-stdc-iso10646]: citrus_big5.c
citrus_dechanyu.c citrus_euc.c citrus_euctw.c citrus_gbk2k.c
citrus_hz.c citrus_iconv_none.c citrus_iconv_std.c citrus_iso2022.c
citrus_johab.c citrus_mskanji.c citrus_ues.c citrus_utf1632.c
citrus_utf7.c citrus_utf8.c citrus_viqr.c citrus_zw.c
src/lib/libc/locale [perseant-stdc-iso10646]: Makefile.inc _wcstod.h
_wctype.c global_locale.c iswctype_mb.c multibyte_amd1.c
multibyte_c90.c rune.c runetable.c runetype_local.h setlocale.c
setlocale_local.h wcscoll.c wcsxfrm.c
src/tests/lib/libc/locale [perseant-stdc-iso10646]: Makefile
t_wcscoll.c
Added Files:
src/lib/libc/citrus [perseant-stdc-iso10646]: citrus_lc_collate.c
src/lib/libc/locale [perseant-stdc-iso10646]: collate_local.h
collate_locale.c rune_iso10646.c rune_iso10646.h u2k.h
unicode_ccc_data.h unicode_collate.c unicode_collate.h
unicode_collation_data.h unicode_decomp_data.h unicode_lc_collate.c
unicode_nfd_qc_data.h unicode_reserved_cp_data.h
unicode_reserved_range_data.h unicode_ucd.c unicode_ucd.h
src/tests/lib/libc/locale [perseant-stdc-iso10646]: ducet_test.h
t_ducet.c

Log Message:
Initial commit of a mostly-working implementation of __STDC_ISO_10646__,
with collation support using the Unicode Collation Algorithm.

The conversion from men/ku/ten form to Unicode is a gross hack at present.
Fixing this, and fleshing out the LC_COLLATE locale component, are next
on the agenda.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.42.8.1 src/include/wchar.h
cvs rdiff -u -r1.8 -r1.8.40.1 src/lib/libc/citrus/Makefile.inc
cvs rdiff -u -r1.7 -r1.7.22.1 src/lib/libc/citrus/citrus_ctype.c
cvs rdiff -u -r1.10 -r1.10.34.1 src/lib/libc/citrus/citrus_iconv.c
cvs rdiff -u -r1.5 -r1.5.64.1 src/lib/libc/citrus/citrus_iconv.h
cvs rdiff -u -r1.3 -r1.3.64.1 src/lib/libc/citrus/citrus_iconv_local.h
cvs rdiff -u -r0 -r1.1.2.1 src/lib/libc/citrus/citrus_lc_collate.c
cvs rdiff -u -r1.8 -r1.8.42.1 src/lib/libc/citrus/citrus_namespace.h
cvs rdiff -u -r1.22 -r1.22.2.1 src/lib/libc/citrus/citrus_none.c
cvs rdiff -u -r1.4 -r1.4.80.1 src/lib/libc/citrus/citrus_stdenc.h
cvs rdiff -u -r1.4 -r1.4.64.1 src/lib/libc/citrus/citrus_stdenc_local.h \
src/lib/libc/citrus/citrus_stdenc_template.h
cvs rdiff -u -r1.15 -r1.15.18.1 src/lib/libc/citrus/modules/citrus_big5.c
cvs rdiff -u -r1.5 -r1.5.22.1 src/lib/libc/citrus/modules/citrus_dechanyu.c \
src/lib/libc/citrus/modules/citrus_zw.c
cvs rdiff -u -r1.17 -r1.17.20.1 src/lib/libc/citrus/modules/citrus_euc.c
cvs rdiff -u -r1.12 -r1.12.22.1 src/lib/libc/citrus/modules/citrus_euctw.c
cvs rdiff -u -r1.8 -r1.8.22.1 src/lib/libc/citrus/modules/citrus_gbk2k.c
cvs rdiff -u -r1.4 -r1.4.18.1 src/lib/libc/citrus/modules/citrus_hz.c
cvs rdiff -u -r1.3 -r1.3.38.1 src/lib/libc/citrus/modules/citrus_iconv_none.c
cvs rdiff -u -r1.16 -r1.16.34.1 \
src/lib/libc/citrus/modules/citrus_iconv_std.c
cvs rdiff -u -r1.23 -r1.23.22.1 src/lib/libc/citrus/modules/citrus_iso2022.c
cvs rdiff -u -r1.6 -r1.6.10.1 src/lib/libc/citrus/modules/citrus_johab.c
cvs rdiff -u -r1.14 -r1.14.22.1 src/lib/libc/citrus/modules/citrus_mskanji.c
cvs rdiff -u -r1.4 -r1.4.22.1 src/lib/libc/citrus/modules/citrus_ues.c
cvs rdiff -u -r1.12 -r1.12.34.1 src/lib/libc/citrus/modules/citrus_utf1632.c
cvs rdiff -u -r1.6 -r1.6.22.1 src/lib/libc/citrus/modules/citrus_utf7.c \
src/lib/libc/citrus/modules/citrus_viqr.c
cvs rdiff -u -r1.18 -r1.18.22.1 src/lib/libc/citrus/modules/citrus_utf8.c
cvs rdiff -u -r1.64 -r1.64.20.1 src/lib/libc/locale/Makefile.inc \
src/lib/libc/locale/setlocale.c
cvs rdiff -u -r1.4 -r1.4.22.1 src/lib/libc/locale/_wcstod.h \
src/lib/libc/locale/wcscoll.c
cvs rdiff -u -r1.9 -r1.9.40.1 src/lib/libc/locale/_wctype.c
cvs rdiff -u -r0 -r1.1.2.1 src/lib/libc/locale/collate_local.h \
src/lib/libc/locale/collate_locale.c src/lib/libc/locale/rune_iso10646.c \
src/lib/libc/locale/rune_iso10646.h src/lib/libc/locale/u2k.h \
src/lib/libc/locale/unicode_ccc_data.h \
src/lib/libc/locale/unicode_collate.c \
src/lib/libc/locale/unicode_collate.h \
src/lib/libc/locale/unicode_collation_data.h \
src/lib/libc/locale/unicode_decomp_data.h \
src/lib/libc/locale/unicode_lc_collate.c \
src/lib/libc/locale/unicode_nfd_qc_data.h \
src/lib/libc/locale/unicode_reserved_cp_data.h \

CVS commit: src

2017-07-14 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Fri Jul 14 14:57:43 UTC 2017

Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/lib/libc/locale: Makefile
Added Files:
src/tests/lib/libc/locale: t_wcscoll.c

Log Message:
Add a simple collation test.  This test is expected to fail on HEAD since
we do not yet have a working implementation of wcscoll.


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.755 -r1.756 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/locale/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/locale/t_wcscoll.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.219 src/distrib/sets/lists/debug/mi:1.220
--- src/distrib/sets/lists/debug/mi:1.219	Tue Jul 11 15:21:31 2017
+++ src/distrib/sets/lists/debug/mi	Fri Jul 14 14:57:43 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.219 2017/07/11 15:21:31 joerg Exp $
+# $NetBSD: mi,v 1.220 2017/07/14 14:57:43 perseant 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
@@ -1954,6 +1954,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_mbtowc.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_sprintf.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_toupper.debug		tests-lib-debug		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/locale/t_wcscoll.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_wcscspn.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_wcspbrk.debug		tests-lib-debug		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_wcsspn.debug		tests-lib-debug		debug,atf,compattestfile

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.755 src/distrib/sets/lists/tests/mi:1.756
--- src/distrib/sets/lists/tests/mi:1.755	Tue Jul 11 15:21:32 2017
+++ src/distrib/sets/lists/tests/mi	Fri Jul 14 14:57:43 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.755 2017/07/11 15:21:32 joerg Exp $
+# $NetBSD: mi,v 1.756 2017/07/14 14:57:43 perseant Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2551,6 +2551,7 @@
 ./usr/tests/lib/libc/locale/t_mbtowc		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_sprintf		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_toupper		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/locale/t_wcscoll		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_wcscspn		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_wcspbrk		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_wcsspn		tests-lib-tests		compattestfile,atf

Index: src/tests/lib/libc/locale/Makefile
diff -u src/tests/lib/libc/locale/Makefile:1.9 src/tests/lib/libc/locale/Makefile:1.10
--- src/tests/lib/libc/locale/Makefile:1.9	Thu Jun  1 15:45:02 2017
+++ src/tests/lib/libc/locale/Makefile	Fri Jul 14 14:57:43 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.9 2017/06/01 15:45:02 perseant Exp $
+# $NetBSD: Makefile,v 1.10 2017/07/14 14:57:43 perseant Exp $
 
 .include 
 
@@ -19,6 +19,7 @@ TESTS_C+=	t_digittoint
 TESTS_C+=	t_sprintf
 TESTS_C+=	t_wctype
 TESTS_C+=	t_btowc
+TESTS_C+=	t_wcscoll
 
 COPTS.t_wctomb.c += -Wno-stack-protector
 COPTS.t_digittoint.c += -Wno-unused-variable

Added files:

Index: src/tests/lib/libc/locale/t_wcscoll.c
diff -u /dev/null src/tests/lib/libc/locale/t_wcscoll.c:1.1
--- /dev/null	Fri Jul 14 14:57:43 2017
+++ src/tests/lib/libc/locale/t_wcscoll.c	Fri Jul 14 14:57:43 2017
@@ -0,0 +1,151 @@
+/* $NetBSD: t_wcscoll.c,v 1.1 2017/07/14 14:57:43 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 N

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/lib/libc/stdio

2017-07-11 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Tue Jul 11 19:36:38 UTC 2017

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

Log Message:
A more correct fix for PR standards/52282.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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.35 src/lib/libc/stdio/vfwprintf.c:1.36
--- src/lib/libc/stdio/vfwprintf.c:1.35	Mon Jul 10 22:49:40 2017
+++ src/lib/libc/stdio/vfwprintf.c	Tue Jul 11 19:36:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfwprintf.c,v 1.35 2017/07/10 22:49:40 perseant Exp $	*/
+/*	$NetBSD: vfwprintf.c,v 1.36 2017/07/11 19:36:38 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.35 2017/07/10 22:49:40 perseant Exp $");
+__RCSID("$NetBSD: vfwprintf.c,v 1.36 2017/07/11 19:36:38 perseant Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -930,7 +930,7 @@ reswitch:	switch (ch) {
 flags |= GROUPING;
 			else {
 thousands_sep = '\0';
-grouping = "";
+grouping = NULL;
 			}
 			goto rflag;
 		case '.':



CVS commit: src/lib/libc/stdio

2017-07-10 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Jul 10 22:49:40 UTC 2017

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

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


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/lib/libc/stdio/vfwprintf.c:1.35
--- src/lib/libc/stdio/vfwprintf.c:1.34	Mon Jan 20 14:11:03 2014
+++ src/lib/libc/stdio/vfwprintf.c	Mon Jul 10 22:49:40 2017
@@ -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 @@ reswitch:	switch (ch) {
 			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++) == '*') {



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

2017-06-01 Thread Konrad Schroder
ed.");
-__RCSID("$NetBSD: t_digittoint.c,v 1.1 2017/05/30 23:44:02 perseant Exp $");
+__RCSID("$NetBSD: t_digittoint.c,v 1.2 2017/06/01 15:45:02 perseant Exp $");
 
 #include 
 #include 
@@ -42,6 +42,11 @@ __RCSID("$NetBSD: t_digittoint.c,v 1.1 2
 
 #include 
 
+/* Use this until we have a better way to tell if it is defined */
+#ifdef digittoint
+# define DIGITTOINT_DEFINED
+#endif
+
 static struct test {
 	const char *locale;
 	const char *digits;
@@ -61,6 +66,7 @@ static struct test {
 	}
 };
 
+#ifdef DIGITTOINT_DEFINED
 static void
 h_digittoint(const struct test *t)
 {
@@ -75,6 +81,7 @@ h_digittoint(const struct test *t)
 		ATF_REQUIRE_EQ(digittoint(t->digits[i]), i);
 	}
 }
+#endif /* DIGITTOINT_DEFINED */
 
 ATF_TC(digittoint);
 
@@ -88,8 +95,12 @@ ATF_TC_BODY(digittoint, tc)
 {
 	struct test *t;
 
+#ifdef DIGITTOINT_DEFINED
 	for (t = [0]; t->locale != NULL; ++t)
 		h_digittoint(t);
+#else /* ! DIGITTOINT_DEFINED */
+	atf_tc_skip("digittoint(3) not present to test");
+#endif /* DIGITTOINT_DEFINED */
 }
 
 ATF_TP_ADD_TCS(tp)

Added files:

Index: src/tests/lib/libc/locale/t_btowc.c
diff -u /dev/null src/tests/lib/libc/locale/t_btowc.c:1.1
--- /dev/null	Thu Jun  1 15:45:02 2017
+++ src/tests/lib/libc/locale/t_btowc.c	Thu Jun  1 15:45:02 2017
@@ -0,0 +1,189 @@
+/* $NetBSD: t_btowc.c,v 1.1 2017/06/01 15:45: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_btowc.c,v 1.1 2017/06/01 15:45:02 perseant Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+struct test {
+	const char *locale;
+	const char *illegal; /* Illegal single-byte characters, if any */
+	const char *legal;   /* Legal single-byte characters */
+	/* The next two are only used if __STDC_ISO_10646__ is defined */
+	const wchar_t wlegal[8]; /* The same characters, but in ISO-10646 */
+	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",
+		{ 'A', 'B', 'C', '1', '2', '3', '@', '\t' },
+		{ 0xfdd0, 0x10fffe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
+	},
+	{
+"ru_RU.KOI8-R",
+		"", /* No illegal characters in KOI8-R */
+"A\xc2\xd7\xc7\xc4\xc5\xa3",
+		{ 'A', 0x0431, 0x432, 0x0433, 0x0434, 0x0435, 0x0451, 0x0 },
+		{ 0x00c5, 0x00e6, 0x00fe, 0x0630, 0x06fc, 0x56cd, 0x0, 0x0 }
+	},
+	{
+		NULL,
+NULL,
+NULL,
+		{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
+		{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
+	},
+};
+
+#ifdef __STDC_ISO_10646__
+static void
+h_iso10646(struct test *t)
+{
+	const char *cp;
+	unsigned char c;
+	char *str;
+	const wchar_t *wcp;
+
+	/* These should have valid wchar representations */
+	for (cp = t->legal, wcp = t->wlegal; *cp != '\0'; ++cp, ++wcp) {
+		c = (unsigned char)*cp;
+		printf("Checking legal character 0x%x\n", c);
+
+		/* It should map to the known Unicode equivalent */
+		printf("btowc(0x%2.2x) = 0x%x, expecting 0x%x\n",
+			c, btowc(c), *wcp);
+		ATF_REQUIRE(btowc(c) == *wcp);
+	}
+
+	/* These are invalid characters in the target set */
+	for (wcp = 

CVS commit: src/distrib/sets/lists/tests

2017-05-30 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Wed May 31 00:18:21 UTC 2017

Modified Files:
src/distrib/sets/lists/tests: mi

Log Message:
Add new locale tests to distrib sets, thanks pgoyette@ for the reminder


To generate a diff of this commit:
cvs rdiff -u -r1.750 -r1.751 src/distrib/sets/lists/tests/mi

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/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.750 src/distrib/sets/lists/tests/mi:1.751
--- src/distrib/sets/lists/tests/mi:1.750	Tue May 30 05:35:03 2017
+++ src/distrib/sets/lists/tests/mi	Wed May 31 00:18:21 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.750 2017/05/30 05:35:03 pgoyette Exp $
+# $NetBSD: mi,v 1.751 2017/05/31 00:18:21 perseant Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -2546,12 +2546,14 @@
 ./usr/tests/lib/libc/locale/t_mbsnrtowcs	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_mbstowcs		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_mbtowc		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/locale/t_sprintf		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_toupper		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_wcscspn		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_wcspbrk		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_wcsspn		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_wcstod		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/locale/t_wctomb		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libc/locale/t_wctype		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/net			tests-lib-tests	compattestfile,atf
 ./usr/tests/lib/libc/net/Atffile		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libc/net/Kyuafile		tests-lib-tests		compattestfile,atf,kyua



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 so

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/string

2017-05-25 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Fri May 26 01:24:19 UTC 2017

Modified Files:
src/tests/lib/libc/string: Makefile
Added Files:
src/tests/lib/libc/string: t_strcoll.c

Log Message:
Add simple expect-fail test case for strcoll(3)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/string/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/string/t_strcoll.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/string/Makefile
diff -u src/tests/lib/libc/string/Makefile:1.9 src/tests/lib/libc/string/Makefile:1.10
--- src/tests/lib/libc/string/Makefile:1.9	Mon Jun 23 10:53:20 2014
+++ src/tests/lib/libc/string/Makefile	Fri May 26 01:24:19 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.9 2014/06/23 10:53:20 shm Exp $
+# $NetBSD: Makefile,v 1.10 2017/05/26 01:24:19 perseant Exp $
 
 .include 
 
@@ -13,6 +13,7 @@ TESTS_C+=	t_popcount
 TESTS_C+=	t_strcat
 TESTS_C+=	t_strchr
 TESTS_C+=	t_strcmp
+TESTS_C+=	t_strcoll
 TESTS_C+=	t_strcpy
 TESTS_C+=	t_strcspn
 TESTS_C+=	t_strerror

Added files:

Index: src/tests/lib/libc/string/t_strcoll.c
diff -u /dev/null src/tests/lib/libc/string/t_strcoll.c:1.1
--- /dev/null	Fri May 26 01:24:19 2017
+++ src/tests/lib/libc/string/t_strcoll.c	Fri May 26 01:24:19 2017
@@ -0,0 +1,106 @@
+/* $NetBSD: t_strcoll.c,v 1.1 2017/05/26 01:24:19 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_strcoll.c,v 1.1 2017/05/26 01:24:19 perseant Exp $");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static struct test {
+	const char *locale;
+	const char * const data[5];
+} tests[] = {
+	{
+		"C",
+		{ "aardvark", "absolution", "zyzygy", NULL },
+	}, {
+		"ru_RU.KOI8-R",
+		{ "\xc5\xc4\xcf\xcb", "\xa3\xd6", "\xc5\xda\xc4\xc9\xd4\xd8", NULL },
+	}, {
+		NULL,
+		{ NULL, NULL, NULL, NULL },
+	}
+};
+
+static void
+h_ordering(const struct test *t)
+{
+	const char * const *a;
+	const char * const *b;
+	char buf_a[1024], buf_b[1024];
+
+	ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
+	printf("Trying locale %s...\n", t->locale);
+	ATF_REQUIRE(setlocale(LC_COLLATE, t->locale) != NULL);
+
+	for (a = t->data; *a != NULL; ++a) {
+		strvis(buf_a, *a, VIS_WHITE | VIS_OCTAL);
+		for (b = a + 1; *b != NULL; ++b) {
+			strvis(buf_b, *b, VIS_WHITE | VIS_OCTAL);
+			printf("Checking \"%s\" < \"%s\"\n", buf_a, buf_b);
+			ATF_REQUIRE(strcoll(*a, *b) < 0);
+			printf("...good\n");
+		}
+	}
+}
+
+ATF_TC(ordering);
+
+ATF_TC_HEAD(ordering, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+		"Checks collation ordering under diferent locales");
+}
+
+ATF_TC_BODY(ordering, tc)
+{
+	struct test *t;
+
+	atf_tc_expect_fail("%s", "LC_COLLATE not supported");
+	for (t = [0]; t->locale != NULL; ++t)
+		h_ordering(t);
+	atf_tc_expect_pass();
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+	ATF_TP_ADD_TC(tp, ordering);
+
+	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/lib/libpam/modules/pam_deny

2013-08-20 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Tue Aug 20 22:07:44 UTC 2013

Modified Files:
src/lib/libpam/modules/pam_deny: pam_deny.8 pam_deny.c

Log Message:
Add Edgar Fuss's patch to pam_deny, to allow users to be able to change their
LDAP password with passwd.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libpam/modules/pam_deny/pam_deny.8
cvs rdiff -u -r1.2 -r1.3 src/lib/libpam/modules/pam_deny/pam_deny.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/libpam/modules/pam_deny/pam_deny.8
diff -u src/lib/libpam/modules/pam_deny/pam_deny.8:1.3 src/lib/libpam/modules/pam_deny/pam_deny.8:1.4
--- src/lib/libpam/modules/pam_deny/pam_deny.8:1.3	Sat Feb 26 14:54:25 2005
+++ src/lib/libpam/modules/pam_deny/pam_deny.8	Tue Aug 20 22:07:44 2013
@@ -1,4 +1,4 @@
-.\ $NetBSD: pam_deny.8,v 1.3 2005/02/26 14:54:25 thorpej Exp $
+.\ $NetBSD: pam_deny.8,v 1.4 2013/08/20 22:07:44 perseant Exp $
 .\ Copyright (c) 2001 Mark R V Murray
 .\ All rights reserved.
 .\
@@ -73,6 +73,17 @@ suppress warning messages to the user.
 These messages include
 reasons why the user's
 authentication attempt was declined.
+.It Cm prelim_ignore
+for password management (
+.Dq Li password
+feature), return PAM_IGNORE
+in the preliminary phase.
+This allows the module to be used (with the
+.Dq Li required
+flag) at the end of a chain of
+.Dq Li sufficient
+modules with this service
+(where the entire chain is in fact run twice).
 .El
 .Sh SEE ALSO
 .Xr syslog 3 ,

Index: src/lib/libpam/modules/pam_deny/pam_deny.c
diff -u src/lib/libpam/modules/pam_deny/pam_deny.c:1.2 src/lib/libpam/modules/pam_deny/pam_deny.c:1.3
--- src/lib/libpam/modules/pam_deny/pam_deny.c:1.2	Sun Dec 12 08:18:44 2004
+++ src/lib/libpam/modules/pam_deny/pam_deny.c	Tue Aug 20 22:07:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pam_deny.c,v 1.2 2004/12/12 08:18:44 christos Exp $	*/
+/*	$NetBSD: pam_deny.c,v 1.3 2013/08/20 22:07:44 perseant Exp $	*/
 
 /*-
  * Copyright 2001 Mark R V Murray
@@ -30,10 +30,12 @@
 #ifdef __FreeBSD__
 __FBSDID($FreeBSD: src/lib/libpam/modules/pam_deny/pam_deny.c,v 1.9 2002/04/12 22:27:19 des Exp $);
 #else
-__RCSID($NetBSD: pam_deny.c,v 1.2 2004/12/12 08:18:44 christos Exp $);
+__RCSID($NetBSD: pam_deny.c,v 1.3 2013/08/20 22:07:44 perseant Exp $);
 #endif
 
 #include stddef.h
+#include string.h
+#include syslog.h
 
 #define PAM_SM_AUTH
 #define PAM_SM_ACCOUNT
@@ -61,7 +63,7 @@ pam_sm_setcred(pam_handle_t *pamh __unus
 int argc __unused, const char *argv[] __unused)
 {
 
-	return (PAM_AUTH_ERR);
+	return (PAM_CRED_ERR);
 }
 
 PAM_EXTERN int
@@ -73,11 +75,25 @@ pam_sm_acct_mgmt(pam_handle_t *pamh __un
 }
 
 PAM_EXTERN int
-pam_sm_chauthtok(pam_handle_t *pamh __unused, int flags __unused,
-int argc __unused, const char *argv[] __unused)
+pam_sm_chauthtok(pam_handle_t *pamh __unused, int flags,
+int argc, const char *argv[])
 {
+	int prelim_ignore = 0, debug = 0;
+	int i;
 
-	return (PAM_AUTH_ERR);
+	for (i = 0; i  argc; i++) {
+		if (strcmp(argv[i], prelim_ignore) == 0)
+			prelim_ignore = 1;
+		else if (strcmp(argv[i], debug) == 0)
+			debug = 1;
+		else
+			syslog(LOG_ERR, illegal option %s, argv[i]);
+	}
+
+	if (flags  PAM_PRELIM_CHECK  prelim_ignore)
+		return (PAM_IGNORE);
+	else
+		return (PAM_AUTHTOK_ERR);
 }
 
 PAM_EXTERN int
@@ -85,7 +101,7 @@ pam_sm_open_session(pam_handle_t *pamh _
 int argc __unused, const char *argv[] __unused)
 {
 
-	return (PAM_AUTH_ERR);
+	return (PAM_SESSION_ERR);
 }
 
 PAM_EXTERN int
@@ -93,7 +109,7 @@ pam_sm_close_session(pam_handle_t *pamh 
 int argc __unused, const char *argv[] __unused)
 {
 
-	return (PAM_AUTH_ERR);
+	return (PAM_SESSION_ERR);
 }
 
 PAM_MODULE_ENTRY(pam_deny);



CVS commit: src/sys/arch/i386/stand/lib

2012-06-13 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Wed Jun 13 18:34:20 UTC 2012

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Sanity check the values coming back from the int13 extensions of the bios,
so we can catch impossible return values.  Allows the bootloader to work
again on the Soekris net4501.

Fixes PR kern/46027.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/i386/stand/lib/biosdisk.c

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

Modified files:

Index: src/sys/arch/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.40 src/sys/arch/i386/stand/lib/biosdisk.c:1.41
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.40	Mon Jan 16 18:47:57 2012
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Wed Jun 13 18:34:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.40 2012/01/16 18:47:57 christos Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.41 2012/06/13 18:34:20 perseant Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -316,7 +316,9 @@ read_gpt(struct biosdisk *d)
 	gptsector[0] = GPT_HDR_BLKNO;
 	if (set_geometry(d-ll, ed) == 0  d-ll.flags  BIOSDISK_INT13EXT) {
 		gptsector[1] = ed.totsec - 1;
-		d-ll.secsize = ed.sbytes;
+		/* Sanity check values returned from BIOS */
+		if (ed.sbytes = 512  (ed.sbytes  (ed.sbytes - 1)) == 0)
+			d-ll.secsize = ed.sbytes;
 	} else {
 #ifdef DISK_DEBUG
 		printf(Unable to determine extended disk geometry - 



CVS commit: src

2012-02-15 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Thu Feb 16 02:47:56 UTC 2012

Modified Files:
src/sbin/newfs_lfs: make_lfs.c
src/sys/ufs/lfs: lfs.h lfs_alloc.c lfs_bio.c lfs_segment.c lfs_vfsops.c
lfs_vnops.c
src/tests/fs/vfs: t_renamerace.c t_rmdirrace.c

Log Message:
Pass t_renamerace and t_rmdirrace tests.

Adapt dholland@'s fix to ufs_rename to fix PR kern/43582.  Address several
other MP locking issues discovered during the course of investigating the
same problem.

Removed extraneous vn_lock() calls on the Ifile, since the Ifile writes
are controlled by the segment lock.

Fix PR kern/45982 by deemphasizing the estimate of how much metadata
will fill the empty space on disk when the disk is nearly empty
(t_renamerace crates a lot of inode blocks on a tiny empty disk).


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/newfs_lfs/make_lfs.c
cvs rdiff -u -r1.135 -r1.136 src/sys/ufs/lfs/lfs.h
cvs rdiff -u -r1.111 -r1.112 src/sys/ufs/lfs/lfs_alloc.c
cvs rdiff -u -r1.121 -r1.122 src/sys/ufs/lfs/lfs_bio.c
cvs rdiff -u -r1.223 -r1.224 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.293 -r1.294 src/sys/ufs/lfs/lfs_vfsops.c
cvs rdiff -u -r1.239 -r1.240 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.24 -r1.25 src/tests/fs/vfs/t_renamerace.c
cvs rdiff -u -r1.8 -r1.9 src/tests/fs/vfs/t_rmdirrace.c

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

Modified files:

Index: src/sbin/newfs_lfs/make_lfs.c
diff -u src/sbin/newfs_lfs/make_lfs.c:1.18 src/sbin/newfs_lfs/make_lfs.c:1.19
--- src/sbin/newfs_lfs/make_lfs.c:1.18	Thu Feb  2 03:50:32 2012
+++ src/sbin/newfs_lfs/make_lfs.c	Thu Feb 16 02:47:54 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: make_lfs.c,v 1.18 2012/02/02 03:50:32 perseant Exp $	*/
+/*	$NetBSD: make_lfs.c,v 1.19 2012/02/16 02:47:54 perseant Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 #if 0
 static char sccsid[] = @(#)lfs.c	8.5 (Berkeley) 5/24/95;
 #else
-__RCSID($NetBSD: make_lfs.c,v 1.18 2012/02/02 03:50:32 perseant Exp $);
+__RCSID($NetBSD: make_lfs.c,v 1.19 2012/02/16 02:47:54 perseant Exp $);
 #endif
 #endif /* not lint */
 
@@ -496,7 +496,7 @@ make_lfs(int devfd, uint secsize, struct
 	if (fs-lfs_resvseg  MIN_RESV_SEGS)
 		fs-lfs_resvseg = MIN_RESV_SEGS;
 
-	if(fs-lfs_nseg  (3 * CM_MAG_NUM * fs-lfs_minfreeseg) / CM_MAG_DEN + 1
+	if(fs-lfs_nseg  (4 * fs-lfs_minfreeseg)
 	   || fs-lfs_nseg  LFS_MIN_SBINTERVAL + 1)
 	{
 		if(seg_size == 0  ssize  (bsize1)) {

Index: src/sys/ufs/lfs/lfs.h
diff -u src/sys/ufs/lfs/lfs.h:1.135 src/sys/ufs/lfs/lfs.h:1.136
--- src/sys/ufs/lfs/lfs.h:1.135	Mon Jan  2 22:10:44 2012
+++ src/sys/ufs/lfs/lfs.h	Thu Feb 16 02:47:55 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.135 2012/01/02 22:10:44 perseant Exp $	*/
+/*	$NetBSD: lfs.h,v 1.136 2012/02/16 02:47:55 perseant Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -1027,13 +1027,23 @@ struct lfs_inode_ext {
 /*
  * Estimate number of clean blocks not available for writing because
  * they will contain metadata or overhead.  This is calculated as
- * (dmeta / # dirty segments) * (# clean segments).
+ *
+ *		E = ((C * M / D) * D + (0) * (T - D)) / T
+ * or more simply
+ *		E = (C * M) / T
+ *
+ * where
+ * C is the clean space,
+ * D is the dirty space,
+ * M is the dirty metadata, and
+ * T = C + D is the total space on disk.
+ *
+ * This approximates the old formula of E = C * M / D when D is close to T,
+ * but avoids falsely reporting disk full when the sample size (D) is small.
  */
-#define CM_MAG_NUM 3
-#define CM_MAG_DEN 2
 #define LFS_EST_CMETA(F) (int32_t)((	\
-(CM_MAG_NUM * ((F)-lfs_dmeta * (int64_t)(F)-lfs_nclean)) / \
-(CM_MAG_DEN * ((F)-lfs_nseg - (F)-lfs_nclean
+	((F)-lfs_dmeta * (int64_t)(F)-lfs_nclean) / 			\
+	((F)-lfs_nseg)))
 
 /* Estimate total size of the disk not including metadata */
 #define LFS_EST_NONMETA(F) ((F)-lfs_dsize - (F)-lfs_dmeta - LFS_EST_CMETA(F))

Index: src/sys/ufs/lfs/lfs_alloc.c
diff -u src/sys/ufs/lfs/lfs_alloc.c:1.111 src/sys/ufs/lfs/lfs_alloc.c:1.112
--- src/sys/ufs/lfs/lfs_alloc.c:1.111	Sun Jun 12 03:36:01 2011
+++ src/sys/ufs/lfs/lfs_alloc.c	Thu Feb 16 02:47:55 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_alloc.c,v 1.111 2011/06/12 03:36:01 rmind Exp $	*/
+/*	$NetBSD: lfs_alloc.c,v 1.112 2012/02/16 02:47:55 perseant Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: lfs_alloc.c,v 1.111 2011/06/12 03:36:01 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: lfs_alloc.c,v 1.112 2012/02/16 02:47:55 perseant Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_quota.h
@@ -207,7 +207,6 @@ lfs_valloc(struct vnode *pvp, int mode, 
 	ASSERT_NO_SEGLOCK(fs);
 
 	lfs_seglock(fs, SEGM_PROT);
-	vn_lock(fs-lfs_ivnode, LK_EXCLUSIVE);
 
 	/* Get the head of the freelist. */

CVS commit: src/libexec/lfs_cleanerd

2012-02-01 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Thu Feb  2 03:47:11 UTC 2012

Modified Files:
src/libexec/lfs_cleanerd: lfs_cleanerd.c

Log Message:
Shut down the cleaner earlier if the filesystem is unmounted.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/libexec/lfs_cleanerd/lfs_cleanerd.c

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

Modified files:

Index: src/libexec/lfs_cleanerd/lfs_cleanerd.c
diff -u src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.28 src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.29
--- src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.28	Mon Jan  2 21:35:18 2012
+++ src/libexec/lfs_cleanerd/lfs_cleanerd.c	Thu Feb  2 03:47:11 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.28 2012/01/02 21:35:18 perseant Exp $	 */
+/* $NetBSD: lfs_cleanerd.c,v 1.29 2012/02/02 03:47:11 perseant Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -1158,6 +1158,12 @@ clean_fs(struct clfs *fs, CLEANERINFO *c
 fd_release_all(fs-clfs_devvp);
 return r;
 			}
+			if (oerrno == ESHUTDOWN) {
+syslog(LOG_NOTICE, %s: filesystem unmounted,
+   fs-lfs_fsmnt);
+fd_release_all(fs-clfs_devvp);
+return r;
+			}
 		}
 	}
 



CVS commit: src/sbin/newfs_lfs

2012-02-01 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Thu Feb  2 03:49:22 UTC 2012

Modified Files:
src/sbin/newfs_lfs: newfs.c

Log Message:
If invoked with -D and creating an image file, ensure that the image
file is filled to the given size.  This prevents false failures
with lfs: ifile read: 22 in ATF tests.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sbin/newfs_lfs/newfs.c

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

Modified files:

Index: src/sbin/newfs_lfs/newfs.c
diff -u src/sbin/newfs_lfs/newfs.c:1.25 src/sbin/newfs_lfs/newfs.c:1.26
--- src/sbin/newfs_lfs/newfs.c:1.25	Tue Feb 16 23:20:30 2010
+++ src/sbin/newfs_lfs/newfs.c	Thu Feb  2 03:49:22 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.25 2010/02/16 23:20:30 mlelstv Exp $	*/
+/*	$NetBSD: newfs.c,v 1.26 2012/02/02 03:49:22 perseant Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)newfs.c	8.5 (Berkeley) 5/24/95;
 #else
-__RCSID($NetBSD: newfs.c,v 1.25 2010/02/16 23:20:30 mlelstv Exp $);
+__RCSID($NetBSD: newfs.c,v 1.26 2012/02/02 03:49:22 perseant Exp $);
 #endif
 #endif /* not lint */
 
@@ -275,8 +275,18 @@ main(int argc, char **argv)
 		special = device;
 	}
 	if (!Nflag) {
-		fso = open(special,
-		(debug ? O_CREAT : 0) | O_RDWR, DEFFILEMODE);
+		fso = open(special, O_RDWR, DEFFILEMODE);
+		if (debug  fso  0) {
+			/* Create a file of the requested size. */
+			fso = open(special, O_CREAT | O_RDWR, DEFFILEMODE);
+			if (fso = 0) {
+char buf[512];
+int i;
+for (i = 0; i  fssize; i++)
+	write(fso, buf, sizeof(buf));
+lseek(fso, 0, SEEK_SET);
+			}
+		}
 		if (fso  0)
 			fatal(%s: %s, special, strerror(errno));
 	} else



CVS commit: src/sbin/newfs_lfs

2012-02-01 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Thu Feb  2 03:50:32 UTC 2012

Modified Files:
src/sbin/newfs_lfs: config.h make_lfs.c

Log Message:
When creating a very small filesystem, use well-known small segment,
block and fragment sizes by default instead of the ordinary 1M/8k/1k
default for larger filesystems.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sbin/newfs_lfs/config.h
cvs rdiff -u -r1.17 -r1.18 src/sbin/newfs_lfs/make_lfs.c

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

Modified files:

Index: src/sbin/newfs_lfs/config.h
diff -u src/sbin/newfs_lfs/config.h:1.8 src/sbin/newfs_lfs/config.h:1.9
--- src/sbin/newfs_lfs/config.h:1.8	Wed Dec 17 05:08:43 2003
+++ src/sbin/newfs_lfs/config.h	Thu Feb  2 03:50:32 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.h,v 1.8 2003/12/17 05:08:43 yamt Exp $	*/
+/*	$NetBSD: config.h,v 1.9 2012/02/02 03:50:32 perseant Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -40,7 +40,7 @@
  * 1/DFL_MIN_FREE_SEGS gives the fraction of segments to be reserved for
  * the cleaner.
  */
-#define DFL_MIN_FREE_SEGS 20
+#define DFL_MIN_FREE_SEGS 10
 
 /*
  * MINFREE gives the minimum acceptable percentage of file system
@@ -69,3 +69,8 @@
 #define DFL_LFS_FFSHIFT		10
 #define DFL_LFS_FBMASK		0x7
 #define DFL_LFS_FBSHIFT		3
+
+#define SMALL_FSSIZE		65536 /* sectors */
+#define SMALL_LFSSEG		32768
+#define SMALL_LFSBLOCK		1024
+#define SMALL_LFSFRAG		512

Index: src/sbin/newfs_lfs/make_lfs.c
diff -u src/sbin/newfs_lfs/make_lfs.c:1.17 src/sbin/newfs_lfs/make_lfs.c:1.18
--- src/sbin/newfs_lfs/make_lfs.c:1.17	Tue Jan 17 16:27:19 2012
+++ src/sbin/newfs_lfs/make_lfs.c	Thu Feb  2 03:50:32 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: make_lfs.c,v 1.17 2012/01/17 16:27:19 perseant Exp $	*/
+/*	$NetBSD: make_lfs.c,v 1.18 2012/02/02 03:50:32 perseant Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 #if 0
 static char sccsid[] = @(#)lfs.c	8.5 (Berkeley) 5/24/95;
 #else
-__RCSID($NetBSD: make_lfs.c,v 1.17 2012/01/17 16:27:19 perseant Exp $);
+__RCSID($NetBSD: make_lfs.c,v 1.18 2012/02/02 03:50:32 perseant Exp $);
 #endif
 #endif /* not lint */
 
@@ -355,12 +355,20 @@ make_lfs(int devfd, uint secsize, struct
 		expected \%s\, dkw-dkw_ptype, DKW_PTYPE_LFS);
 	}
 
-	if (!(bsize = block_size))
+	if (!(bsize = block_size)) {
 		bsize = DFL_LFSBLOCK;
-	if (!(fsize = frag_size))
+		if (dkw-dkw_size = SMALL_FSSIZE)
+			bsize = SMALL_LFSBLOCK;
+	}
+	if (!(fsize = frag_size)) {
 		fsize = DFL_LFSFRAG;
+		if (dkw-dkw_size = SMALL_FSSIZE)
+			fsize = SMALL_LFSFRAG;
+	}
 	if (!(ssize = seg_size)) {
 		ssize = DFL_LFSSEG;
+		if (dkw-dkw_size = SMALL_FSSIZE)
+			ssize = SMALL_LFSSEG;
 	}
 	if (version  1) {
 		if (ibsize == 0)
@@ -511,7 +519,7 @@ make_lfs(int devfd, uint secsize, struct
 			segment size.\n, ssize, fs-lfs_bsize);
 	}
 	if(warned_segtoobig)
-		fprintf(stderr,Using segment size %d.\n, ssize);
+		fprintf(stderr,Using segment size %d, block size %d, frag size %d.\n, ssize, bsize, fsize);
 
 	/*
 	 * Now that we've determined what we're going to do, announce it



CVS commit: src/sbin/newfs_lfs

2012-01-17 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Tue Jan 17 16:27:19 UTC 2012

Modified Files:
src/sbin/newfs_lfs: make_lfs.c

Log Message:
Use an even smaller segment size when creating a very small filesystem.
This allows the lfs_renamerace_dirs case of the t_renamerace test to
fail correctly, rather than with a bogus file system full error as it
has since rev 1.135 of sys/ufs/lfs/lfs.h.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sbin/newfs_lfs/make_lfs.c

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

Modified files:

Index: src/sbin/newfs_lfs/make_lfs.c
diff -u src/sbin/newfs_lfs/make_lfs.c:1.16 src/sbin/newfs_lfs/make_lfs.c:1.17
--- src/sbin/newfs_lfs/make_lfs.c:1.16	Tue Feb 16 23:20:30 2010
+++ src/sbin/newfs_lfs/make_lfs.c	Tue Jan 17 16:27:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: make_lfs.c,v 1.16 2010/02/16 23:20:30 mlelstv Exp $	*/
+/*	$NetBSD: make_lfs.c,v 1.17 2012/01/17 16:27:19 perseant Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 #if 0
 static char sccsid[] = @(#)lfs.c	8.5 (Berkeley) 5/24/95;
 #else
-__RCSID($NetBSD: make_lfs.c,v 1.16 2010/02/16 23:20:30 mlelstv Exp $);
+__RCSID($NetBSD: make_lfs.c,v 1.17 2012/01/17 16:27:19 perseant Exp $);
 #endif
 #endif /* not lint */
 
@@ -488,7 +488,7 @@ make_lfs(int devfd, uint secsize, struct
 	if (fs-lfs_resvseg  MIN_RESV_SEGS)
 		fs-lfs_resvseg = MIN_RESV_SEGS;
 
-	if(fs-lfs_nseg  fs-lfs_minfreeseg + 1
+	if(fs-lfs_nseg  (3 * CM_MAG_NUM * fs-lfs_minfreeseg) / CM_MAG_DEN + 1
 	   || fs-lfs_nseg  LFS_MIN_SBINTERVAL + 1)
 	{
 		if(seg_size == 0  ssize  (bsize1)) {
@@ -510,6 +510,8 @@ make_lfs(int devfd, uint secsize, struct
 			size %d and block size %d;\nplease decrease the 
 			segment size.\n, ssize, fs-lfs_bsize);
 	}
+	if(warned_segtoobig)
+		fprintf(stderr,Using segment size %d.\n, ssize);
 
 	/*
 	 * Now that we've determined what we're going to do, announce it



CVS commit: src/sys/ufs/lfs

2012-01-14 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Sun Jan 15 04:42:04 UTC 2012

Modified Files:
src/sys/ufs/lfs: lfs_syscalls.c

Log Message:
Corrections to part of rev 1.140. lfs_bmapv, not lfs_markv, marks vnodes
LFSI_BMAP and recycles them.  This greatly reduces the writing leakage
occurring when the filesystem has no space available for non-cleaning
writes.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/ufs/lfs/lfs_syscalls.c

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

Modified files:

Index: src/sys/ufs/lfs/lfs_syscalls.c
diff -u src/sys/ufs/lfs/lfs_syscalls.c:1.140 src/sys/ufs/lfs/lfs_syscalls.c:1.141
--- src/sys/ufs/lfs/lfs_syscalls.c:1.140	Mon Jan  2 22:10:45 2012
+++ src/sys/ufs/lfs/lfs_syscalls.c	Sun Jan 15 04:42:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_syscalls.c,v 1.140 2012/01/02 22:10:45 perseant Exp $	*/
+/*	$NetBSD: lfs_syscalls.c,v 1.141 2012/01/15 04:42:04 perseant Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008
@@ -61,7 +61,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: lfs_syscalls.c,v 1.140 2012/01/02 22:10:45 perseant Exp $);
+__KERNEL_RCSID(0, $NetBSD: lfs_syscalls.c,v 1.141 2012/01/15 04:42:04 perseant Exp $);
 
 #ifndef LFS
 # define LFS		/* for prototypes in syscallargs.h */
@@ -291,17 +291,6 @@ lfs_markv(struct proc *p, fsid_t *fsidp,
 			 */
 			if (v_daddr != LFS_UNUSED_DADDR) {
 lfs_vunref(vp);
-/*
- * If the vnode has LFSI_BMAP, it was
- * not found in the cache.  Dump it so
- * we can reuse the vnode.
- * XXX If we knew what segment we were
- * XXX supposed to be looking for, we
- * XXX would be able to be more selective
- * XXX here.
- */
-if (ip-i_lfs_iflags  LFSI_BMAP)
-	vrecycle(vp, NULL, NULL);
 numrefed--;
 			}
 
@@ -719,6 +708,8 @@ lfs_bmapv(struct proc *p, fsid_t *fsidp,
 			 */
 			if (v_daddr != LFS_UNUSED_DADDR) {
 lfs_vunref(vp);
+if (VTOI(vp)-i_lfs_iflags  LFSI_BMAP)
+	vrecycle(vp, NULL, NULL);
 numrefed--;
 			}
 
@@ -1139,6 +1130,11 @@ lfs_fastvget(struct mount *mp, ino_t ino
 	ufs_ihashins(ip);
 	mutex_exit(ufs_hashlock);
 
+#ifdef notyet
+	/* Not found in the cache = this vnode was loaded only for cleaning. */
+	ip-i_lfs_iflags |= LFSI_BMAP;
+#endif
+
 	/*
 	 * XXX
 	 * This may not need to be here, logically it should go down with



CVS commit: src/sbin/fsck_lfs

2012-01-05 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Thu Jan  5 16:18:01 UTC 2012

Modified Files:
src/sbin/fsck_lfs: pass6.c

Log Message:
Correct fragment extension calculation in pass6, to avoid putting
negative block counts on inodes during roll-forward.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sbin/fsck_lfs/pass6.c

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

Modified files:

Index: src/sbin/fsck_lfs/pass6.c
diff -u src/sbin/fsck_lfs/pass6.c:1.23 src/sbin/fsck_lfs/pass6.c:1.24
--- src/sbin/fsck_lfs/pass6.c:1.23	Tue Feb 16 23:20:30 2010
+++ src/sbin/fsck_lfs/pass6.c	Thu Jan  5 16:18:00 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: pass6.c,v 1.23 2010/02/16 23:20:30 mlelstv Exp $	 */
+/* $NetBSD: pass6.c,v 1.24 2012/01/05 16:18:00 perseant Exp $	 */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -108,7 +108,7 @@ rfw_update_single(struct uvnode *vp, dad
 			ip-i_ffs1_blocks += frags;
 		else {
 			/* possible fragment truncation or extension */
-			ofrags = ip-i_lfs_fragsize[lbn];
+			ofrags = numfrags(fs, ip-i_lfs_fragsize[lbn]);
 			ip-i_ffs1_blocks += (frags - ofrags);
 		}
 		ip-i_ffs1_db[lbn] = ndaddr;



CVS commit: src/sys/ufs/lfs

2012-01-03 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Wed Jan  4 02:48:58 UTC 2012

Modified Files:
src/sys/ufs/lfs: lfs_vfsops.c

Log Message:
lfs_writerd thread exits when no more LFSs are mounted.


To generate a diff of this commit:
cvs rdiff -u -r1.292 -r1.293 src/sys/ufs/lfs/lfs_vfsops.c

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

Modified files:

Index: src/sys/ufs/lfs/lfs_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.292 src/sys/ufs/lfs/lfs_vfsops.c:1.293
--- src/sys/ufs/lfs/lfs_vfsops.c:1.292	Mon Jan  2 22:10:45 2012
+++ src/sys/ufs/lfs/lfs_vfsops.c	Wed Jan  4 02:48:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs_vfsops.c,v 1.292 2012/01/02 22:10:45 perseant Exp $	*/
+/*	$NetBSD: lfs_vfsops.c,v 1.293 2012/01/04 02:48:58 perseant Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: lfs_vfsops.c,v 1.292 2012/01/02 22:10:45 perseant Exp $);
+__KERNEL_RCSID(0, $NetBSD: lfs_vfsops.c,v 1.293 2012/01/04 02:48:58 perseant Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_lfs.h
@@ -524,14 +524,12 @@ lfs_writerd(void *arg)
  			vfs_unbusy(mp, false, nmp);
  		}
 		if (lfsc + skipc == 0) {
-#ifdef notyet
 			mutex_enter(lfs_lock);
 			lfs_writer_daemon = 0;
 			lfs_writer_lid = 0;
 			mutex_exit(lfs_lock);
 			mutex_exit(mountlist_lock);
 			break;
-#endif
 		}
  		mutex_exit(mountlist_lock);
  
@@ -545,6 +543,9 @@ lfs_writerd(void *arg)
 	if (vfs != NULL)
 		vfs-vfs_refcount--;
 	mutex_exit(vfs_list_lock);
+
+	/* Done! */
+	kthread_exit(0);
 }
 
 /*



CVS commit: src/sys/ufs

2012-01-02 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Jan  2 22:10:45 UTC 2012

Modified Files:
src/sys/ufs/lfs: lfs.h lfs_bio.c lfs_extern.h lfs_segment.c lfs_subr.c
lfs_syscalls.c lfs_vfsops.c lfs_vnops.c
src/sys/ufs/ufs: inode.h ufs_readwrite.c

Log Message:
* Remove PGO_RECLAIM during lfs_putpages()' call to genfs_putpages(),
  to avoid a live lock in the latter when reclaiming a vnode with
  dirty pages.

* Add a new segment flag, SEGM_RECLAIM, to note when a segment is
  being written for vnode reclamation, and record which inode is being
  reclaimed, to aid in forensic debugging.

* Add a new segment flag, SEGM_SINGLE, so that opportunistic writes
  can write a single segment's worth of blocks and then stop, rather
  than writing all the way up to the cleaner's reserved number of
  segments.

* Add assert statements to check mutex ownership is the way it ought
  to be, mostly in lfs_putpages; fix problems uncovered by this.

* Don't clear VU_DIROP until the inode actually makes its way to disk,
  avoiding a problem where dirop inodes could become separated
  (uncovered by a modified version of the ckckp forensic regression
  test).

* Move the vfs_getopsbyname() call into lfs_writerd.  Prepare code to
  make lfs_writerd notice when there are no more LFSs, and exit losing
  the reference, so that, in theory, the module can be unloaded.  This
  code is not enabled, since it causes a crash on exit.

* Set IN_MODIFIED on inodes flushed by lfs_flush_dirops.  Really we
  only need to set IN_MODIFIED if we are going to write them again
  (e.g., to write pages); need to think about this more.

Finally, several changes to help avoid no clean segments panics:

* In lfs_bmapv, note when a vnode is loaded only to discover whether
  its blocks are live, so it can immediately be recycled.  Since the
  cleaner will try to choose ~empty segments over full ones, this
  prevents the cleaner from (1) filling the vnode cache with junk, and
  (2) squeezing any unwritten writes to disk and running the fs out of
  segments.

* Overestimate by half the amount of metadata that will be required
  to fill the clean segments.  This will make the disk appear smaller,
  but should help avoid a no clean segments panic.

* Rearrange lfs_writerd.  In particular, lfs_writerd now pays
  attention to the number of clean segments available, and holds off
  writing until there is room.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/ufs/lfs/lfs.h
cvs rdiff -u -r1.120 -r1.121 src/sys/ufs/lfs/lfs_bio.c
cvs rdiff -u -r1.96 -r1.97 src/sys/ufs/lfs/lfs_extern.h
cvs rdiff -u -r1.222 -r1.223 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.76 -r1.77 src/sys/ufs/lfs/lfs_subr.c
cvs rdiff -u -r1.139 -r1.140 src/sys/ufs/lfs/lfs_syscalls.c
cvs rdiff -u -r1.291 -r1.292 src/sys/ufs/lfs/lfs_vfsops.c
cvs rdiff -u -r1.238 -r1.239 src/sys/ufs/lfs/lfs_vnops.c
cvs rdiff -u -r1.58 -r1.59 src/sys/ufs/ufs/inode.h
cvs rdiff -u -r1.100 -r1.101 src/sys/ufs/ufs/ufs_readwrite.c

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

Modified files:

Index: src/sys/ufs/lfs/lfs.h
diff -u src/sys/ufs/lfs/lfs.h:1.134 src/sys/ufs/lfs/lfs.h:1.135
--- src/sys/ufs/lfs/lfs.h:1.134	Mon Jul 11 08:27:40 2011
+++ src/sys/ufs/lfs/lfs.h	Mon Jan  2 22:10:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.134 2011/07/11 08:27:40 hannken Exp $	*/
+/*	$NetBSD: lfs.h,v 1.135 2012/01/02 22:10:44 perseant Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -592,6 +592,7 @@ struct segsum_v1 {
 #define	SS_CONT		0x02		/* more partials to finish this write*/
 #define	SS_CLEAN	0x04		/* written by the cleaner */
 #define	SS_RFW		0x08		/* written by the roll-forward agent */
+#define	SS_RECLAIM	0x10		/* written by the roll-forward agent */
 	u_int16_t ss_flags;		/* 24: used for directory operations */
 	u_int16_t ss_pad;		/* 26: extra space */
 	/* FINFO's and inode daddr's... */
@@ -608,7 +609,8 @@ struct segsum {
 	u_int16_t ss_nfinfo;		/* 20: number of file info structures */
 	u_int16_t ss_ninos;		/* 22: number of inodes in summary */
 	u_int16_t ss_flags;		/* 24: used for directory operations */
-	u_int8_t  ss_pad[6];		/* 26: extra space */
+	u_int8_t  ss_pad[2];		/* 26: extra space */
+	u_int32_t ss_reclino;   /* 28: inode being reclaimed */
 	u_int64_t ss_serial;		/* 32: serial number */
 	u_int64_t ss_create;		/* 40: time stamp */
 	/* FINFO's and inode daddr's... */
@@ -840,6 +842,8 @@ struct lfs {
 	int lfs_nowrap;			/* Suspend log wrap */
 	int lfs_wrappass;		/* Allow first log wrap requester to pass */
 	int lfs_wrapstatus;		/* Wrap status */
+	int lfs_reclino;		/* Inode being reclaimed */
+	int lfs_startseg;   /* Segment we started writing at */
 	LIST_HEAD(, segdelta) lfs_segdhd;	/* List of pending trunc accounting events */
 };
 
@@ -945,13 +949,15 @@ struct segment {
 	u_int32_t seg_number;		/* number