Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Apr 2014 10:36:12 +0000 (UTC)
From:      Tijl Coosemans <tijl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r263986 - in head/lib: libc/iconv libiconv_modules/BIG5 libiconv_modules/DECHanyu libiconv_modules/EUCTW libiconv_modules/ISO2022 libiconv_modules/UES libiconv_modules/VIQR libiconv_mod...
Message-ID:  <201404011036.s31AaCIZ020166@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tijl
Date: Tue Apr  1 10:36:11 2014
New Revision: 263986
URL: http://svnweb.freebsd.org/changeset/base/263986

Log:
  - In the libiconv module for ISO 2022 restore the original order of the
    fields of a private struct such that variables of this type are
    initialised correctly.  Fixes conversion from ISO 2022.
    Also do this in the BIG5 module to prevent similar errors in the future.
  - In the libiconv module for EUC-TW replace 2^cs with 1<<cs.  Fixes
    conversion from EUC-TW.
  - Synchronise iconv code with NetBSD.  In most cases this only updates
    the RCS id because the changes are already there or are NetBSD specific.
    + libc/iconv/citrus_csmapper.c: Add a comment.
    + libc/iconv/citrus_db_factory.c: Remove put16().
    + libc/iconv/citrus_iconv.c: Return EINVAL on error.
    + libc/iconv/citrus_mapper.c: Return EINVAL on error.
    + libc/iconv/citrus_memstream.c: Fix type of a variable.
    + libc/iconv/citrus_prop.h: Sync definition of _CITRUS_PROP_HINT_END.
    + libc/iconv/citrus_stdenc.c: Return EINVAL on error.
    + libiconv_modules/mapper_std/citrus_mapper_std.c: Plug memory leak.
  
  Obtained from:	NetBSD
  MFC after:	2 weeks

Modified:
  head/lib/libc/iconv/citrus_bcs_strtol.c
  head/lib/libc/iconv/citrus_bcs_strtoul.c
  head/lib/libc/iconv/citrus_csmapper.c
  head/lib/libc/iconv/citrus_csmapper.h
  head/lib/libc/iconv/citrus_db_factory.c
  head/lib/libc/iconv/citrus_iconv.c
  head/lib/libc/iconv/citrus_lookup.c
  head/lib/libc/iconv/citrus_mapper.c
  head/lib/libc/iconv/citrus_memstream.c
  head/lib/libc/iconv/citrus_mmap.c
  head/lib/libc/iconv/citrus_prop.c
  head/lib/libc/iconv/citrus_prop.h
  head/lib/libc/iconv/citrus_stdenc.c
  head/lib/libiconv_modules/BIG5/citrus_big5.c
  head/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c
  head/lib/libiconv_modules/EUCTW/citrus_euctw.c
  head/lib/libiconv_modules/ISO2022/citrus_iso2022.c
  head/lib/libiconv_modules/UES/citrus_ues.c
  head/lib/libiconv_modules/VIQR/citrus_viqr.c
  head/lib/libiconv_modules/iconv_none/citrus_iconv_none.c
  head/lib/libiconv_modules/iconv_std/citrus_iconv_std.c
  head/lib/libiconv_modules/mapper_std/citrus_mapper_std.c

Modified: head/lib/libc/iconv/citrus_bcs_strtol.c
==============================================================================
--- head/lib/libc/iconv/citrus_bcs_strtol.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_bcs_strtol.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_bcs_strtol.c,v 1.2 2009/01/11 02:46:24 christos Exp $ */
+/* $NetBSD: citrus_bcs_strtol.c,v 1.4 2013/04/26 21:20:47 joerg Exp $ */
 
 /*-
  * Copyright (c) 2005 The DragonFly Project.  All rights reserved.

Modified: head/lib/libc/iconv/citrus_bcs_strtoul.c
==============================================================================
--- head/lib/libc/iconv/citrus_bcs_strtoul.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_bcs_strtoul.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_bcs_strtoul.c,v 1.3 2009/01/11 02:46:24 christos Exp $ */
+/* $NetBSD: citrus_bcs_strtoul.c,v 1.5 2013/04/26 21:20:48 joerg Exp $ */
 
 /*-
  * Copyright (c) 2005 The DragonFly Project.  All rights reserved.

Modified: head/lib/libc/iconv/citrus_csmapper.c
==============================================================================
--- head/lib/libc/iconv/citrus_csmapper.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_csmapper.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_csmapper.c,v 1.10 2009/01/11 02:46:24 christos Exp $ */
+/*	$NetBSD: citrus_csmapper.c,v 1.11 2011/11/20 07:43:52 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -140,6 +140,7 @@ find_best_pivot_pvdb(const char *src, co
 		if (ret)
 			goto quit3;
 		if (_db_lookup_by_s(db3, dst, &r2, NULL) != 0)
+			/* don't break the loop, test all src/dst pairs. */
 			goto quit4;
 		/* r2: norm among pivot and dst */
 		ret = get32(&r2, &val32);

Modified: head/lib/libc/iconv/citrus_csmapper.h
==============================================================================
--- head/lib/libc/iconv/citrus_csmapper.h	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_csmapper.h	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_csmapper.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */
+/*	$NetBSD: citrus_csmapper.h,v 1.3 2013/06/24 17:28:35 joerg Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,

Modified: head/lib/libc/iconv/citrus_db_factory.c
==============================================================================
--- head/lib/libc/iconv/citrus_db_factory.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_db_factory.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_db_factory.c,v 1.9 2008/02/09 14:56:20 junyoung Exp $ */
+/*	$NetBSD: citrus_db_factory.c,v 1.10 2013/09/14 13:05:51 joerg Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -228,15 +228,6 @@ put8(struct _region *r, size_t *rofs, ui
 }
 
 static __inline void
-put16(struct _region *r, size_t *rofs, uint16_t val)
-{
-
-	val = htons(val);
-	memcpy(_region_offset(r, *rofs), &val, 2);
-	*rofs += 2;
-}
-
-static __inline void
 put32(struct _region *r, size_t *rofs, uint32_t val)
 {
 

Modified: head/lib/libc/iconv/citrus_iconv.c
==============================================================================
--- head/lib/libc/iconv/citrus_iconv.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_iconv.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_iconv.c,v 1.7 2008/07/25 14:05:25 christos Exp $ */
+/*	$NetBSD: citrus_iconv.c,v 1.10 2011/11/19 18:34:21 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -169,8 +169,10 @@ open_shared(struct _citrus_iconv_shared 
 	    ci->ci_ops->io_uninit_shared == NULL ||
 	    ci->ci_ops->io_init_context == NULL ||
 	    ci->ci_ops->io_uninit_context == NULL ||
-	    ci->ci_ops->io_convert == NULL)
+	    ci->ci_ops->io_convert == NULL) {
+		ret = EINVAL;
 		goto err;
+	}
 
 	/* initialize the converter */
 	ret = (*ci->ci_ops->io_init_shared)(ci, src, dst);

Modified: head/lib/libc/iconv/citrus_lookup.c
==============================================================================
--- head/lib/libc/iconv/citrus_lookup.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_lookup.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_lookup.c,v 1.6 2009/02/03 04:58:38 lukem Exp $ */
+/*	$NetBSD: citrus_lookup.c,v 1.7 2012/05/04 16:45:05 joerg Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,

Modified: head/lib/libc/iconv/citrus_mapper.c
==============================================================================
--- head/lib/libc/iconv/citrus_mapper.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_mapper.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_mapper.c,v 1.7 2008/07/25 14:05:25 christos Exp $ */
+/*	$NetBSD: citrus_mapper.c,v 1.10 2012/06/08 07:49:42 martin Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -244,8 +244,10 @@ mapper_open(struct _citrus_mapper_area *
 	if (!cm->cm_ops->mo_init ||
 	    !cm->cm_ops->mo_uninit ||
 	    !cm->cm_ops->mo_convert ||
-	    !cm->cm_ops->mo_init_state)
+	    !cm->cm_ops->mo_init_state) {
+		ret = EINVAL;
 		goto err;
+	}
 
 	/* allocate traits structure */
 	cm->cm_traits = malloc(sizeof(*cm->cm_traits));

Modified: head/lib/libc/iconv/citrus_memstream.c
==============================================================================
--- head/lib/libc/iconv/citrus_memstream.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_memstream.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_memstream.c,v 1.4 2009/02/03 05:02:12 lukem Exp $ */
+/*	$NetBSD: citrus_memstream.c,v 1.5 2012/03/13 21:13:31 christos Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -44,8 +44,7 @@ _citrus_memory_stream_getln(struct _citr
     size_t * __restrict rlen)
 {
 	const uint8_t *h, *p;
-	size_t ret;
-	int i;
+	size_t i, ret;
 
 	if (ms->ms_pos>=_region_size(&ms->ms_region))
 		return (NULL);

Modified: head/lib/libc/iconv/citrus_mmap.c
==============================================================================
--- head/lib/libc/iconv/citrus_mmap.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_mmap.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_mmap.c,v 1.3 2005/01/19 00:52:37 mycroft Exp $ */
+/*	$NetBSD: citrus_mmap.c,v 1.4 2011/10/15 23:00:01 christos Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,

Modified: head/lib/libc/iconv/citrus_prop.c
==============================================================================
--- head/lib/libc/iconv/citrus_prop.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_prop.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_prop.c,v 1.3 2006/11/22 23:47:21 tnozaki Exp $ */
+/* $NetBSD: citrus_prop.c,v 1.4 2011/03/30 08:22:01 jruoho Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,

Modified: head/lib/libc/iconv/citrus_prop.h
==============================================================================
--- head/lib/libc/iconv/citrus_prop.h	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_prop.h	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_prop.h,v 1.3 2006/11/23 13:59:03 tnozaki Exp $ */
+/* $NetBSD: citrus_prop.h,v 1.5 2011/05/23 14:52:32 joerg Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,
@@ -82,7 +82,7 @@ struct _citrus_prop_hint_t {
 #define _CITRUS_PROP_HINT_NUM(name, cb) \
     { name, _CITRUS_PROP_NUM, { .num = { cb } } }
 #define _CITRUS_PROP_HINT_END \
-    { NULL, _CITRUS_PROP_NUM, { .num = { 0 } } }
+    { .name = NULL }
 
 __BEGIN_DECLS
 int	 _citrus_prop_parse_variable(const _citrus_prop_hint_t * __restrict,

Modified: head/lib/libc/iconv/citrus_stdenc.c
==============================================================================
--- head/lib/libc/iconv/citrus_stdenc.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libc/iconv/citrus_stdenc.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_stdenc.c,v 1.3 2005/10/29 18:02:04 tshiozak Exp $ */
+/*	$NetBSD: citrus_stdenc.c,v 1.4 2011/11/19 18:39:58 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -102,8 +102,10 @@ _citrus_stdenc_open(struct _citrus_stden
 	    ce->ce_ops->eo_cstomb == NULL ||
 	    ce->ce_ops->eo_mbtowc == NULL ||
 	    ce->ce_ops->eo_wctomb == NULL ||
-	    ce->ce_ops->eo_get_state_desc == NULL)
+	    ce->ce_ops->eo_get_state_desc == NULL) {
+		ret = EINVAL;
 		goto bad;
+	}
 
 	/* allocate traits */
 	ce->ce_traits = malloc(sizeof(*ce->ce_traits));

Modified: head/lib/libiconv_modules/BIG5/citrus_big5.c
==============================================================================
--- head/lib/libiconv_modules/BIG5/citrus_big5.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libiconv_modules/BIG5/citrus_big5.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/*	$NetBSD: citrus_big5.c,v 1.12 2008/06/14 16:01:07 tnozaki Exp $	*/
+/*	$NetBSD: citrus_big5.c,v 1.13 2011/05/23 14:53:46 joerg Exp $	*/
 
 /*-
  * Copyright (c)2002, 2006 Citrus Project,
@@ -92,8 +92,8 @@ typedef struct {
 
 typedef struct _BIG5Exclude {
 	TAILQ_ENTRY(_BIG5Exclude)	 entry;
-	wint_t				 end;
 	wint_t				 start;
+	wint_t				 end;
 } _BIG5Exclude;
 
 typedef TAILQ_HEAD(_BIG5ExcludeList, _BIG5Exclude) _BIG5ExcludeList;
@@ -358,7 +358,7 @@ _citrus_BIG5_wcrtomb_priv(_BIG5EncodingI
     size_t n, wchar_t wc, _BIG5State * __restrict psenc __unused,
     size_t * __restrict nresult)
 {
-	unsigned char l;
+	size_t l;
 	int ret;
 
 	/* check invalid sequence */

Modified: head/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c
==============================================================================
--- head/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_dechanyu.c,v 1.3 2008/06/14 16:01:07 tnozaki Exp $ */
+/* $NetBSD: citrus_dechanyu.c,v 1.4 2011/11/19 18:20:13 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2007 Citrus Project,

Modified: head/lib/libiconv_modules/EUCTW/citrus_euctw.c
==============================================================================
--- head/lib/libiconv_modules/EUCTW/citrus_euctw.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libiconv_modules/EUCTW/citrus_euctw.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -119,7 +119,7 @@ _citrus_EUCTW_count(int cs)
 	case 1:
 		/*FALLTHROUGH*/
 	case 2:
-		return (2^cs);
+		return (1 << cs);
 	case 3:
 		abort();
 		/*NOTREACHED*/

Modified: head/lib/libiconv_modules/ISO2022/citrus_iso2022.c
==============================================================================
--- head/lib/libiconv_modules/ISO2022/citrus_iso2022.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libiconv_modules/ISO2022/citrus_iso2022.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/*	$NetBSD: citrus_iso2022.c,v 1.19 2008/06/14 16:01:07 tnozaki Exp $	*/
+/*	$NetBSD: citrus_iso2022.c,v 1.20 2010/12/07 22:01:45 joerg Exp $	*/
 
 /*-
  * Copyright (c)1999, 2002 Citrus Project,
@@ -78,9 +78,9 @@
 #define CS96MULTI	(3U)
 
 typedef struct {
-	unsigned char	 interm;
-	unsigned char	 final;
 	unsigned char	 type;
+	unsigned char	 final;
+	unsigned char	 interm;
 	unsigned char	 vers;
 } _ISO2022Charset;
 

Modified: head/lib/libiconv_modules/UES/citrus_ues.c
==============================================================================
--- head/lib/libiconv_modules/UES/citrus_ues.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libiconv_modules/UES/citrus_ues.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_ues.c,v 1.1 2006/11/13 15:16:31 tnozaki Exp $ */
+/* $NetBSD: citrus_ues.c,v 1.3 2012/02/12 13:51:29 wiz Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,

Modified: head/lib/libiconv_modules/VIQR/citrus_viqr.c
==============================================================================
--- head/lib/libiconv_modules/VIQR/citrus_viqr.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libiconv_modules/VIQR/citrus_viqr.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/* $NetBSD: citrus_viqr.c,v 1.4 2008/06/14 16:01:08 tnozaki Exp $ */
+/* $NetBSD: citrus_viqr.c,v 1.5 2011/11/19 18:20:13 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,

Modified: head/lib/libiconv_modules/iconv_none/citrus_iconv_none.c
==============================================================================
--- head/lib/libiconv_modules/iconv_none/citrus_iconv_none.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libiconv_modules/iconv_none/citrus_iconv_none.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/*	$NetBSD: citrus_iconv_none.c,v 1.2 2003/07/01 09:42:16 tshiozak Exp $	*/
+/*	$NetBSD: citrus_iconv_none.c,v 1.3 2011/05/23 14:45:44 joerg Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,

Modified: head/lib/libiconv_modules/iconv_std/citrus_iconv_std.c
==============================================================================
--- head/lib/libiconv_modules/iconv_std/citrus_iconv_std.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libiconv_modules/iconv_std/citrus_iconv_std.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/*	$NetBSD: citrus_iconv_std.c,v 1.15 2006/11/13 19:08:19 tnozaki Exp $	*/
+/*	$NetBSD: citrus_iconv_std.c,v 1.16 2012/02/12 13:51:29 wiz Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,

Modified: head/lib/libiconv_modules/mapper_std/citrus_mapper_std.c
==============================================================================
--- head/lib/libiconv_modules/mapper_std/citrus_mapper_std.c	Tue Apr  1 10:34:39 2014	(r263985)
+++ head/lib/libiconv_modules/mapper_std/citrus_mapper_std.c	Tue Apr  1 10:36:11 2014	(r263986)
@@ -1,5 +1,5 @@
 /* $FreeBSD$ */
-/*	$NetBSD: citrus_mapper_std.c,v 1.8 2006/09/11 13:06:33 tnozaki Exp $	*/
+/*	$NetBSD: citrus_mapper_std.c,v 1.10 2011/11/19 18:48:39 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)2003, 2006 Citrus Project,
@@ -174,8 +174,11 @@ rowcol_parse_variable_compat(struct _cit
 	n = be32toh(rcx->rcx_src_row_end);
 	if (m + n > 0) {
 		ret = set_linear_zone(lz, m, n);
-		if (ret != 0)
+		if (ret != 0) {
+			free(rc->rc_src_rowcol);
+			rc->rc_src_rowcol = NULL;
 			return (ret);
+		}
 		++rc->rc_src_rowcol_len, ++lz;
 	}
 	m = be32toh(rcx->rcx_src_col_begin);



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