Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Oct 2009 12:57:44 GMT
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 169422 for review
Message-ID:  <200910121257.n9CCvi9r020814@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=169422

Change 169422 by gabor@gabor_aspire on 2009/10/12 12:57:32

	MFHg:
		GENERAL
		============================================================
		- Add a top-level Makefile to make the upgrade easier.  For
		  first-time installation it is still required to follow
		  TESTING-HOWTO to resolve the dependencies between the
		  various components. [1]
	
		LIBRARY
		============================================================
		- Hook up mapper_parallel to the build, which was forgotten
		- Fix a typo in _iconv.c
		- Add GNU-specific iconvctl(). Currently, the following
		  iconvctl() operations are supported:
			- ICONV_GET_TRIVIALP
			- ICONV_GET_TRANSLITERATION
			- ICONV_SET_TRANSLITERATION
			- ICONV_GET_DISCARD_ILSEQ
			- ICONV_SET_DISCARD_ILSEQ
		- Along with ICONV_*_DISCARD_ILSEQ, add support for //IGNORE
		  prefix of the destination encoding in iconv_open()
		- Implement GNU's _iconv_canonalize()
		- Make iconvctl() return -1 and set errno to EBADF if
		  conversion descriptor is invalid
		- Speed up build of modules by linking them to the library
		- Implement GNU-specific iconvlist()
		- Some style changes [1]
		- Define historical GNU function names: libiconv_open(),
		  libiconv(), libiconv_close() [1]
		- Add support for listing canonical - alias conversion
		  name pairs [1]
		- Fix installation of iconv.3 [1]
	
		BIN
		============================================================
		- Add -ll for iconv(1) to list supported encodings as
		  canonical - alias name pairs [1]
		- C99-ify iconv(1) a bit
	
		REGRESSION-TEST
		=============================================================
		- Turn on some more test cases in the conversion table
		  comparing tests
		- Add a target to generate reference data from GNU iconv
		- Add -l to tablegen so that we can make longer
		  (but more time-consuming) tests
		- Add a simple POSIX test for some basic cases
		- Add a simple GNU compatibility test for some implemented
		  GNU-specific features
	
		DOCS
		=============================================================
		- Add a sketchy iconvctl.3 man page
	
	
	Submitted by:	edwin [1]

Affected files ...

.. //depot/projects/soc2009/gabor_iconv/extracted/include/iconv.h#2 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/Makefile#7 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/_iconv.c#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_esdb.c#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_esdb.h#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_iconv.c#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_iconv.h#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_iconv_local.h#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_module.h#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_prop.c#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/GBK2K/citrus_gbk2k.c#7 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/MSKanji/citrus_mskanji.c#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/Makefile#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/Makefile.inc#4 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/UES/citrus_ues.c#7 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/UTF1632/citrus_utf1632.c#8 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/iconv_none/citrus_iconv_none.c#7 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/iconv_std/citrus_iconv_std.c#7 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/share/i18n/Makefile#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/share/i18n/iconv/Makefile#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/tools/test/iconv/Makefile#5 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/tools/test/iconv/tablegen/tablegen.c#3 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/usr.bin/Makefile#5 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/usr.bin/iconv/Makefile#7 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/usr.bin/iconv/iconv.1#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/usr.bin/iconv/iconv.c#6 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/usr.bin/mkcsmapper/Makefile#8 edit
.. //depot/projects/soc2009/gabor_iconv/extracted/usr.bin/mkesdb/Makefile#8 edit

Differences ...

==== //depot/projects/soc2009/gabor_iconv/extracted/include/iconv.h#2 (text+ko) ====

@@ -30,6 +30,9 @@
 #ifndef _ICONV_H_
 #define _ICONV_H_
 
+#include <stdbool.h>
+#include <wchar.h>
+
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
@@ -50,11 +53,48 @@
 /*
  * non-portable interfaces for iconv
  */
-int	__iconv_get_list(char ***, size_t *);
+int	__iconv_get_list(char ***, size_t *, bool);
 void	__iconv_free_list(char **, size_t);
 size_t	__iconv(iconv_t, const char **, size_t *, char **,
 		     size_t *, __uint32_t, size_t *);
 #define __ICONV_F_HIDE_INVALID	0x0001
+
+/*
+ * GNU interfaces for iconv
+ */
+
+/* Historical versions */
+#define	libiconv_open	iconv_open
+#define libiconv_close	iconv_close
+#define libiconv	iconv
+
+/* We have iconvctl() */
+#define _LIBICONV_VERSION	0x0108
+
+/*
+ * iconvctl() request macros
+ */
+#define ICONV_TRIVIALP		0
+#define	ICONV_GET_TRANSLITERATE	1
+#define	ICONV_SET_TRANSLITERATE	2
+#define ICONV_GET_DISCARD_ILSEQ	3
+#define ICONV_SET_DISCARD_ILSEQ	4
+#define ICONV_SET_HOOKS		5
+#define ICONV_SET_FALLBACKS	6
+
+typedef void (*iconv_unicode_char_hook) (unsigned int mbr, void *data);
+typedef void (*iconv_wide_char_hook) (wchar_t wc, void *data);
+
+struct iconv_hooks {
+	iconv_unicode_char_hook		 uc_hook;
+	iconv_wide_char_hook		 wc_hook;
+	void				*data;
+};
+
+void		 iconvlist(int (*do_one) (unsigned int, const char * const *,
+		    void *), void *);
+const char	*_iconv_canonalize(const char *);
+int		 iconvctl(iconv_t, int, void *);
 __END_DECLS
 
 #endif /* !_ICONV_H_ */

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/Makefile#7 (text+ko) ====

@@ -2,6 +2,8 @@
 
 LIB=		iconv
 SHLIB_MAJOR=	4
+MAN=		iconv.3 \
+		iconvctl.3
 SRCS=		_iconv.c \
 		citrus_bcs.c \
 		citrus_bcs_strtol.c \
@@ -26,7 +28,7 @@
 		citrus_prop.c \
 		citrus_stdenc.c
 
-CFLAGS+=	--param max-inline-insns-single=128
+CFLAGS+=	--param max-inline-insns-single=128 -I ${.CURDIR}/../../include
 WARNS?=		3
 
 .include <bsd.lib.mk>

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/_iconv.c#6 (text+ko) ====

@@ -30,10 +30,11 @@
 
 #include <assert.h>
 #include <errno.h>
+#include <iconv.h>
 #include <paths.h>
+#include <stdbool.h>
 #include <sys/queue.h>
 
-#include "iconv.h"
 #include "netbsdism.h"
 
 #ifdef __weak_alias
@@ -64,7 +65,7 @@
 	/*
 	 * Remove anything following a //, as these are options (like
 	 * //ignore, //translate, etc) and we just don't handle them.
-	 * This is for compatibilty wiht software that uses thees
+	 * This is for compatibilty with software that uses thees
 	 * blindly.
 	 */
 	out_truncated = strdup(out);
@@ -85,10 +86,15 @@
 	ret = _citrus_iconv_open(&handle, _PATH_ICONV, in, out_truncated);
 	free(out_truncated);
 	if (ret) {
-		errno = ret == ENOENT? EINVAL : ret;
+		errno = ret == ENOENT ? EINVAL : ret;
 		return ((iconv_t)-1);
 	}
 
+	if (strcasestr(out, "//IGNORE"))
+		handle->cv_shared->ci_discard_ilseq = true;
+	else
+		handle->cv_shared->ci_discard_ilseq = false;
+
 	return ((iconv_t)(void *)handle);
 }
 
@@ -153,11 +159,11 @@
 }
 
 int
-__iconv_get_list(char ***rlist, size_t *rsz)
+__iconv_get_list(char ***rlist, size_t *rsz, bool l)
 {
 	int ret;
 
-	ret = _citrus_esdb_get_list(rlist, rsz);
+	ret = _citrus_esdb_get_list(rlist, rsz, l);
 	if (ret) {
 		errno = ret;
 		return -1;
@@ -171,3 +177,80 @@
 {
 	_citrus_esdb_free_list(list, sz);
 }
+
+/*
+ * GNU-compatibile non-standard interfaces.
+ */
+void
+iconvlist(int (*do_one) (unsigned int, const char * const *,
+    void *), void *data)
+{
+	char		**list;
+	size_t		 sz;
+
+	if (__iconv_get_list(&list, &sz, true))
+		list = NULL;
+
+	const char * const *	names = (const char * const *)list;
+	unsigned int		i = sz;
+	do_one(i, names, data);
+
+	__iconv_free_list(list, sz);
+}
+
+__inline const char
+*_iconv_canonalize(const char *name)
+{
+	return (_citrus_iconv_canonalize(name));
+}
+
+int
+iconvctl(iconv_t cd, int request, void *argument)
+{
+	int			*i = (int *)argument;
+	struct iconv_hooks	*hooks = (struct iconv_hooks *)argument;
+	struct _citrus_iconv	*cv = (struct _citrus_iconv *)(void *)cd;
+	const char		*convname;
+	char			*src, *dst;
+
+	if (ISBADF(cd)) {
+		errno = EBADF;
+		return (-1);
+	}
+
+	switch (request) {
+	case ICONV_TRIVIALP:
+		convname = cv->cv_shared->ci_convname;
+		dst = strchr(convname, '/');
+
+		strlcpy(src, convname, dst - convname + 1);
+		dst++;
+		if ((convname == NULL) || (src == NULL) || (dst == NULL))
+			return (-1);
+		*i = strcmp(src, dst) == 0 ? 1 : 0;
+		return (0);
+	case ICONV_GET_TRANSLITERATE:
+		*i = 1;
+		return (0);
+	case ICONV_SET_TRANSLITERATE:
+		return  ((*i == 1) ? 0 : -1);
+	case ICONV_GET_DISCARD_ILSEQ:
+		*i = cv->cv_shared->ci_discard_ilseq ? 1 : 0;
+		return (0);
+	case ICONV_SET_DISCARD_ILSEQ:
+		cv->cv_shared->ci_discard_ilseq = *i;
+		return (0);
+	case ICONV_SET_HOOKS:
+		if (hooks != NULL)
+			cv->cv_shared->ci_hooks = *hooks;
+		else {
+			cv->cv_shared->ci_hooks.uc_hook = NULL;
+			cv->cv_shared->ci_hooks.wc_hook = NULL;
+			cv->cv_shared->ci_hooks.data = NULL;
+		}
+		return (0);
+	default:
+		errno = EINVAL;
+		return (-1);
+	}
+}

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_esdb.c#6 (text+ko) ====

@@ -29,6 +29,7 @@
 #include <sys/cdefs.h>
 
 #include <assert.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -254,10 +255,10 @@
  *	get esdb entries.
  */
 int
-_citrus_esdb_get_list(char ***rlist, size_t *rnum)
+_citrus_esdb_get_list(char ***rlist, size_t *rnum, bool l)
 {
 	int ret;
-	struct _region key;
+	struct _region key, data;
 	size_t num;
 	struct _citrus_lookup *cla, *cld;
 	char **list, **q;
@@ -290,10 +291,17 @@
 	}
 
 	/* get alias entries */
-	while ((ret = _lookup_seq_next(cla, &key, NULL)) == 0) {
-		snprintf(buf, sizeof(buf), "%.*s",
-			 (int)_region_size(&key),
-			 (const char *)_region_head(&key));
+	while ((ret = _lookup_seq_next(cla, &key, &data)) == 0) {
+		if (!l)
+			snprintf(buf, sizeof(buf), "%.*s",
+				 (int)_region_size(&key),
+				 (const char *)_region_head(&key));
+		else
+			snprintf(buf, sizeof(buf), "%.*s/%.*s",
+				 (int)_region_size(&data),
+				 (const char *)_region_head(&data),
+				 (int)_region_size(&key),
+				 (const char *)_region_head(&key));
 		_bcs_convert_to_lower(buf);
 		list[num] = strdup(buf);
 		if (list[num] == NULL) {
@@ -305,11 +313,28 @@
 	if (ret != ENOENT)
 		goto quit3;
 	/* get dir entries */
-	while ((ret = _lookup_seq_next(cld, &key, NULL)) == 0) {
+	while ((ret = _lookup_seq_next(cld, &key, &data)) == 0) {
 		/* check duplicated entry */
-		snprintf(buf, sizeof(buf), "%.*s",
-			 (int)_region_size(&key),
-			 (const char *)_region_head(&key));
+		if (!l)
+			snprintf(buf, sizeof(buf), "%.*s",
+				 (int)_region_size(&key),
+				 (const char *)_region_head(&key));
+		else {
+			char buf1[PATH_MAX];
+			char *p;
+
+			snprintf(buf1, sizeof(buf1), "%.*s",
+				 (int)_region_size(&data),
+				 (const char *)_region_head(&data));
+			if ((p = strchr(buf1, '/')) != NULL)
+				memcpy(buf1, p + 1, strlen(p) - 1);
+			if ((p = strstr(buf1, ".esdb")) != NULL)
+				*p = '\0';
+			snprintf(buf, sizeof(buf), "%s/%.*s",
+				 buf1,
+				 (int)_region_size(&key),
+				 (const char *)_region_head(&key));
+		}
 		_bcs_convert_to_lower(buf);
 		ret = _lookup_seq_lookup(cla, buf, NULL);
 		if (ret) {

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_esdb.h#6 (text+ko) ====

@@ -49,7 +49,7 @@
 int		_citrus_esdb_open(struct _citrus_esdb *, const char *);
 void		_citrus_esdb_close(struct _citrus_esdb *);
 void		_citrus_esdb_free_list(char **, size_t);
-int		_citrus_esdb_get_list(char ***, size_t *);
+int		_citrus_esdb_get_list(char ***, size_t *, bool);
 __END_DECLS
 
 #endif

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_iconv.c#6 (text+ko) ====

@@ -30,10 +30,12 @@
 
 #include <assert.h>
 #include <pthread.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <iconv.h>
 #include <limits.h>
 #include <unistd.h>
 #include <paths.h>
@@ -378,3 +380,14 @@
 		free(cv);
 	}
 }
+
+const char
+*_citrus_iconv_canonalize(const char *name)
+{
+	char buf[PATH_MAX], path[PATH_MAX];
+ 
+	snprintf(path, sizeof(path), "%s/%s", _PATH_ICONV, _CITRUS_ICONV_ALIAS);
+	return (_citrus_lookup_simple(path, name, buf, (size_t)PATH_MAX,
+	    _LOOKUP_CASE_IGNORE));
+}
+

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_iconv.h#6 (text+ko) ====

@@ -34,10 +34,11 @@
 struct _citrus_iconv;
 
 __BEGIN_DECLS
-int	_citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict,
+int		 _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict,
 			   const char * __restrict,
 			   const char * __restrict, const char * __restrict);
-void	_citrus_iconv_close(struct _citrus_iconv *);
+void		 _citrus_iconv_close(struct _citrus_iconv *);
+const char	*_citrus_iconv_canonalize(const char *);
 __END_DECLS
 
 

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_iconv_local.h#6 (text+ko) ====

@@ -29,6 +29,8 @@
 #ifndef _CITRUS_ICONV_LOCAL_H_
 #define _CITRUS_ICONV_LOCAL_H_
 
+#include <iconv.h>
+
 #define _CITRUS_ICONV_GETOPS_FUNC_BASE(_n_)				\
 int _n_(struct _citrus_iconv_ops *, size_t, uint32_t)
 #define _CITRUS_ICONV_GETOPS_FUNC(_n_)					\
@@ -97,6 +99,8 @@
 	_citrus_module_t				ci_module;
 	unsigned int					ci_used_count;
 	char						*ci_convname;
+	bool						ci_discard_ilseq;
+	struct iconv_hooks				ci_hooks;
 };
 
 struct _citrus_iconv {

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_module.h#6 (text+ko) ====

@@ -30,6 +30,16 @@
 #ifndef _CITRUS_MODULE_H_
 #define _CITRUS_MODULE_H_
 
+#define MATCH(x, act)						\
+do {								\
+	if (lenvar >= (sizeof(#x)-1) &&				\
+	    _bcs_strncasecmp(p, #x, sizeof(#x)-1) == 0) {	\
+		act;						\
+		lenvar -= sizeof(#x)-1;				\
+		p += sizeof(#x)-1;				\
+	}							\
+} while (/*CONSTCOND*/0)
+
 typedef struct _citrus_module_rec *_citrus_module_t;
 
 __BEGIN_DECLS

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv/citrus_prop.c#6 (text+ko) ====

@@ -160,11 +160,11 @@
 		case 'r': *result = '\r'; break;
 		case 't': *result = '\t'; break;
 		case 'v': *result = '\v'; break;
-		/*FALLTHROUGH*/
 		case '0': case '1': case '2': case '3':
 		case '4': case '5': case '6': case '7':
 			_memstream_ungetc(ms, ch);
 			base -= 8;
+			/*FALLTHROUGH*/
 		case 'x':
 			return _citrus_prop_read_chr_common(ms, result, base);
 			
@@ -247,7 +247,7 @@
 	case '\\':
 		_memstream_ungetc(ms, quot);
 		quot = EOF;
-	/*FALLTHROUGH*/
+		/*FALLTHROUGH*/
 	case '\"': case '\'':
 		break;
 	default:

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/GBK2K/citrus_gbk2k.c#7 (text+ko) ====

@@ -405,15 +405,6 @@
 	const char *p;
 
 	p = var;
-#define MATCH(x, act)                                           \
-do {                                                            \
-        if (lenvar >= (sizeof(#x)-1) &&                         \
-            _bcs_strncasecmp(p, #x, sizeof(#x)-1) == 0) {       \
-                act;                                            \
-                lenvar -= sizeof(#x)-1;                         \
-                p += sizeof(#x)-1;                              \
-        }                                                       \
-} while (/*CONSTCOND*/0)
 	memset((void *)ei, 0, sizeof(*ei));
 	ei->mb_cur_max = 4;
 	while (lenvar>0) {

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/MSKanji/citrus_mskanji.c#6 (text+ko) ====

@@ -479,15 +479,6 @@
 	const char *p;
 
 	p = var;
-#define MATCH(x, act)						\
-do {								\
-	if (lenvar >= (sizeof(#x)-1) &&				\
-	    _bcs_strncasecmp(p, #x, sizeof(#x)-1) == 0) {	\
-		act;						\
-		lenvar -= sizeof(#x)-1;				\
-		p += sizeof(#x)-1;				\
-	}							\
-} while (/*CONSTCOND*/0)
 	memset((void *)ei, 0, sizeof(*ei));
 	while (lenvar > 0) {
 		switch (_bcs_toupper(*p)) {

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/Makefile#6 (text+ko) ====

@@ -21,6 +21,7 @@
 	iconv_std \
 	mapper_646 \
 	mapper_none \
+	mapper_parallel \
 	mapper_serial \
 	mapper_std \
 	mapper_zone

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/Makefile.inc#4 (text+ko) ====

@@ -3,28 +3,9 @@
 .PATH: ${.CURDIR}/../../libiconv
 
 SHLIB_MAJOR=	4
-CFLAGS+=	-I${.CURDIR}/../../libiconv
+CFLAGS+=	-I${.CURDIR}/../../libiconv -I/usr/include -L/usr/lib
 DEBUG_FLAGS=	-g -ggdb
 LIBDIR=		/usr/lib/i18n
-SRCS+=		_iconv.c \
-		citrus_bcs.c \
-		citrus_bcs_strtol.c \
-		citrus_bcs_strtoul.c \
-		citrus_csmapper.c \
-		citrus_ctype.c \
-		citrus_ctype_fallback.c \
-		citrus_db.c \
-		citrus_db_hash.c \
-		citrus_esdb.c \
-		citrus_hash.c \
-		citrus_iconv.c \
-		citrus_lookup.c \
-		citrus_mapper.c \
-		citrus_memstream.c \
-		citrus_mmap.c \
-		citrus_module.c \
-		citrus_none.c \
-		citrus_prop.c \
-		citrus_stdenc.c
-
+LDADD+=		-liconv
+DPADD+=		/usr/lib/libiconv.a
 NO_PROFILE=

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/UES/citrus_ues.c#7 (text+ko) ====

@@ -400,15 +400,6 @@
 	const char *p;
 
 	p = var;
-#define MATCH(x, act)						\
-do {								\
-        if (lenvar >= (sizeof(#x)-1) &&				\
-            _bcs_strncasecmp(p, #x, sizeof(#x)-1) == 0) {	\
-                act;						\
-                lenvar -= sizeof(#x)-1;				\
-                p += sizeof(#x)-1;				\
-        }							\
-} while (/*CONSTCOND*/0)
 	memset((void *)ei, 0, sizeof(*ei));
 	while (lenvar > 0) {
 		switch (_bcs_toupper(*p)) {

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/UTF1632/citrus_utf1632.c#8 (text+ko) ====

@@ -346,15 +346,6 @@
 parse_variable(_UTF1632EncodingInfo * __restrict ei,
 	       const void * __restrict var, size_t lenvar)
 {
-#define MATCH(x, act)						\
-do {								\
-	if (lenvar >= (sizeof(#x)-1) &&				\
-	    _bcs_strncasecmp(p, #x, sizeof(#x)-1) == 0) {	\
-		act;						\
-		lenvar -= sizeof(#x)-1;				\
-		p += sizeof(#x)-1;				\
-	}							\
-} while (/*CONSTCOND*/0)
 	const char *p;
 	p = var;
 	while (lenvar>0) {

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/iconv_none/citrus_iconv_none.c#7 (text+ko) ====

@@ -30,6 +30,7 @@
 
 #include <assert.h>
 #include <errno.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/queue.h>

==== //depot/projects/soc2009/gabor_iconv/extracted/lib/libiconv_modules/iconv_std/citrus_iconv_std.c#7 (text+ko) ====

@@ -31,6 +31,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <limits.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -300,7 +301,8 @@
 static int
 /*ARGSUSED*/
 do_conv(const struct _citrus_iconv_std_shared *is,
-	struct _citrus_iconv_std_context *sc, _csid_t *csid, _index_t *idx)
+	struct _citrus_iconv_std_context *sc, _csid_t *csid, _index_t *idx,
+	bool discard_ilseq)
 {
 	_index_t tmpidx;
 	int ret;
@@ -322,11 +324,12 @@
 				case _MAPPER_CONVERT_SRC_MORE:
 					/*FALLTHROUGH*/
 				case _MAPPER_CONVERT_DST_MORE:
-					/*FALLTHROUGH*/
+					if (discard_ilseq)
+						continue;
+				case _MAPPER_CONVERT_ILSEQ:
+					return EILSEQ;
 				case _MAPPER_CONVERT_FATAL:
 					return EINVAL;
-				case _MAPPER_CONVERT_ILSEQ:
-					return EILSEQ;
 				}
 			}
 			break;
@@ -537,7 +540,7 @@
 			goto err;
 		}
 		/* convert the character */
-		ret = do_conv(is, sc, &csid, &idx);
+		ret = do_conv(is, sc, &csid, &idx, cv->cv_shared->ci_discard_ilseq);
 		if (ret) {
 			if (ret == E_NO_CORRESPONDING_CHAR) {
 				inval++;

==== //depot/projects/soc2009/gabor_iconv/extracted/share/i18n/Makefile#6 (text+ko) ====

@@ -1,5 +1,7 @@
 # $NetBSD: Makefile,v 1.1 2003/06/27 08:39:59 tshiozak Exp $
 
+.include <bsd.own.mk>
+
 SUBDIR=	csmapper \
 	esdb \
 	iconv

==== //depot/projects/soc2009/gabor_iconv/extracted/share/i18n/iconv/Makefile#6 (text+ko) ====

@@ -3,4 +3,9 @@
 FILESDIR=	/usr/share/i18n/iconv
 FILES+=		iconv.dir
 
+.if !target(beforeinstall)
+beforeinstall:
+	mkdir -p ${FILESDIR}
+.endif
+
 .include <bsd.prog.mk>

==== //depot/projects/soc2009/gabor_iconv/extracted/tools/test/iconv/Makefile#5 (text+ko) ====

@@ -1,6 +1,9 @@
 # FreeBSD
 
 SUBDIR=		tablegen
+SUBDIR+=	refgen
+SUBDIR+=	posix
+SUBDIR+=	gnu
 
 ENCODING=	ASCII
 
@@ -34,33 +37,65 @@
 ENCODING+=	CP1251
 ENCODING+=	CP866
 #ENCODING+=	CP949
-#ENCODING+=	GB18030
+ENCODING+=	GB18030
 ENCODING+=	GB2312
-#ENCODING+=	GBK
+ENCODING+=	GBK
 ENCODING+=	VISCII
-#ENCODING+=	KOI8-R
-#ENCODING+=	KOI8-U
+ENCODING+=	KOI8-R
+ENCODING+=	KOI8-U
 ENCODING+=	PT154
 ENCODING+=	SHIFT_JIS
 ENCODING+=	EUC-CN
-#ENCODING+=	EUC-JP
+ENCODING+=	EUC-JP
 #ENCODING+=	EUC-KR
 
 GEN_FWD?=	${.CURDIR}/tablegen/tablegen
 GEN_REV?=	${.CURDIR}/tablegen/tablegen -r
+REF_FWD?=	${.CURDIR}/refgen/refgen
+REF_REV?=	${.CURDIR}/refgen/refgen -r
 CMP?=		${.CURDIR}/tablegen/cmp.sh
 
-check: ${SUBDIR}
+make-ref: refgen
+	mkdir -p ref
+.for enc in ${ENCODING}
+	@echo "Generating ${enc} --> UTF-32 ..."
+	-@${REF_FWD} ${enc} >ref/${enc}
+	@echo "Generating UTF-32 --> ${enc} ..."
+	-@${REF_REV} ${enc} >ref/${enc}-rev
+.endfor
+
+check: tablegen
 	mkdir -p output
 .for enc in ${ENCODING}
 	@echo "Checking ${enc} --> UTF-32 ..."
-	@${GEN_FWD} ${enc} >output/${enc}
+	-@${GEN_FWD} ${enc} >output/${enc}
 	@${CMP} ref/${enc} output/${enc}
 	@echo "Checking UTF-32 --> ${enc} ..."
-	@${GEN_REV} ${enc} >output/${enc}-rev
+	-@${GEN_REV} ${enc} >output/${enc}-rev
 	@${CMP} ref/${enc}-rev output/${enc}-rev
 .endfor
 
+perftest: refgen tablegen
+.for enc in ${ENCODING}
+	@echo "Checking ${enc} --> UTF-32 ..."
+	@echo "GNU runtime:"
+	@/usr/bin/time -h ${REF_FWD} ${enc} >/dev/null
+	@echo "BSD runtime:"
+	@/usr/bin/time -h ${GEN_FWD} ${enc} >/dev/null
+	@echo "Checking UTF-32 --> ${enc} ..."
+	@echo "GNU runtime:"
+	@/usr/bin/time -h ${REF_REV} ${enc} >/dev/null
+	@echo "BSD runtime:"
+	@/usr/bin/time -h ${GEN_REV} ${enc} >/dev/null
+.endfor
+
+posixtest: posix
+	@${.CURDIR}/posix/posix
+
+gnutest: gnu
+
+test-everything: check perftest posixtest gnutest
+
 CLEANDIRS+=	output
 
 .include <bsd.prog.mk>

==== //depot/projects/soc2009/gabor_iconv/extracted/tools/test/iconv/tablegen/tablegen.c#3 (text+ko) ====

@@ -24,15 +24,11 @@
  * SUCH DAMAGE.
  */
 
-#ifdef __FreeBSD__
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
 #include <sys/endian.h>
 #include <sys/types.h>
-#else
-#include <stdint.h>
-#endif
 
 #include <err.h>
 #include <errno.h>
@@ -44,7 +40,8 @@
 
 extern char	*__progname;
 
-static const char	*optstr = "r";
+static const char	*optstr = "lr";
+bool			 lflag;
 bool			 rflag;
 
 static void		 do_rev(iconv_t cd);
@@ -52,13 +49,14 @@
 
 struct option long_options[] =
 {
+	{"long",	no_argument,	NULL,	'l'},
 	{"reverse",	no_argument,	NULL,	'r'},
 	{NULL,		no_argument,	NULL,	0}
 };
  
 static void
 usage(void) {
-	fprintf(stderr, "Usage: %s [-r] ENCODING\n", __progname);
+	fprintf(stderr, "Usage: %s [-lr] ENCODING\n", __progname);
 	exit(EXIT_FAILURE);
 }
 
@@ -106,6 +104,9 @@
 
 	while (((c = getopt_long(argc, argv, optstr, long_options, NULL)) != -1)) {
 		switch (c) {
+		case 'l':
+			lflag = true;
+			break;
 		case 'r':
 			rflag = true;
 			break;
@@ -160,7 +161,7 @@
 	char		*outbuf_;
 	const char	*inbuf_;
 
-	for (inbuf = 0; inbuf < 0x10000; inbuf += 1) {
+	for (inbuf = 0; inbuf < (lflag ? 0x100000 : 0x10000); inbuf += 1) {
 		inbytesleft = outbytesleft = 4;
 		CONVERT;
 	}
@@ -184,4 +185,11 @@
 		inbytesleft = 2;
 		CONVERT;
 	}
+	if (lflag) {
+		for (inbuf = 0x10000; inbuf < 0x100000; inbuf += 1) {
+			outbytesleft = 4;
+			inbytesleft = 3;
+			CONVERT;
+		}
+	}
 }

==== //depot/projects/soc2009/gabor_iconv/extracted/usr.bin/Makefile#5 (text+ko) ====

@@ -1,3 +1,7 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
 SUBDIR=	iconv \
 	mkcsmapper \
 	mkesdb

==== //depot/projects/soc2009/gabor_iconv/extracted/usr.bin/iconv/Makefile#7 (text+ko) ====

@@ -7,6 +7,7 @@
 MAN=		iconv.1
 
 WARNS?=		6
+BINDIR?=	/usr/bin
 
 LDADD+= -lcrypt -liconv
 DPADD+= ${LIBCRYPT} /usr/lib/libiconv.a

==== //depot/projects/soc2009/gabor_iconv/extracted/usr.bin/iconv/iconv.1#6 (text+ko) ====

@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 20, 2008
+.Dd October 12, 2009
 .Dt ICONV 1
 .Os
 .Sh NAME
@@ -52,6 +52,7 @@
 .Op Ar file ...
 .Nm
 .Fl l
+.Op Fl l
 .Sh DESCRIPTION
 The
 .Nm
@@ -89,6 +90,9 @@
 and
 .Ar to_name
 are valid.
+If
+.Fl l
+is specified twice, it will print out all codesets names and aliass.
 .It Fl s
 Silent.
 By default,

==== //depot/projects/soc2009/gabor_iconv/extracted/usr.bin/iconv/iconv.c#6 (text+ko) ====

@@ -32,6 +32,7 @@
 #include <errno.h>
 #include <langinfo.h>
 #include <locale.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -41,8 +42,8 @@
 
 static void usage(void) __unused;
 static int scmp(const void *, const void *);
-static void show_codesets(void);
-static void do_conv(FILE *, const char *, const char *, int, int);
+static void show_codesets(bool);
+static void do_conv(FILE *, const char *, const char *, bool, bool);
 
 static void
 usage(void)
@@ -51,7 +52,7 @@
 	    "Usage:\t%1$s [-cs] -f <from_code> -t <to_code> [file ...]\n"
 	    "\t%1$s -f <from_code> [-cs] [-t <to_code>] [file ...]\n"
 	    "\t%1$s -t <to_code> [-cs] [-f <from_code>] [file ...]\n"
-	    "\t%1$s -l\n", getprogname());
+	    "\t%1$s -l [-l]\n", getprogname());
 	exit(1);
 }
 
@@ -68,12 +69,12 @@
 }
 
 static void
-show_codesets(void)
+show_codesets(bool l)
 {
 	char **list;
 	size_t sz, i;
 
-	if (__iconv_get_list(&list, &sz))
+	if (__iconv_get_list(&list, &sz, l))
 		err(EXIT_FAILURE, "__iconv_get_list()");
 
 	qsort(list, sz, sizeof(char *), scmp);
@@ -87,8 +88,8 @@
 #define INBUFSIZE 1024
 #define OUTBUFSIZE (INBUFSIZE * 2)
 static void
-do_conv(FILE *fp, const char *from, const char *to, int silent,
-    int hide_invalid)
+do_conv(FILE *fp, const char *from, const char *to, bool silent,
+    bool hide_invalid)
 {
 	char inbuf[INBUFSIZE], outbuf[OUTBUFSIZE], *out;
 	const char *in;
@@ -163,25 +164,25 @@
 int
 main(int argc, char **argv)
 {
-	int ch, i;
-	int opt_l = 0, opt_s = 0, opt_c = 0;
+	int ch, i, opt_l = 0;
+	bool opt_s = false, opt_c = false;

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910121257.n9CCvi9r020814>