diff --git a/distrib/sets/lists/base/shl.mi b/distrib/sets/lists/base/shl.mi index 168243b9b83e..c6b09f33299d 100644 --- a/distrib/sets/lists/base/shl.mi +++ b/distrib/sets/lists/base/shl.mi @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.324 2005/10/01 09:56:39 scw Exp $ +# $NetBSD: shl.mi,v 1.325 2005/10/29 18:02:04 tshiozak Exp $ # Note: libtermcap and libtermlib are hardlinked and share the same version. ./lib/libc.so.12.135 base-sys-shlib ./lib/libcrypt.so.0.2 base-sys-shlib @@ -13,23 +13,23 @@ ./lib/libtermlib.so.0.6 base-sys-shlib ./lib/libutil.so.7.7 base-sys-shlib ./lib/libz.so.0.4 base-sys-shlib -./usr/lib/i18n/libBIG5.so.4.3 base-i18n-shlib -./usr/lib/i18n/libEUC.so.4.3 base-i18n-shlib -./usr/lib/i18n/libEUCTW.so.4.3 base-i18n-shlib -./usr/lib/i18n/libGBK2K.so.4.3 base-i18n-shlib -./usr/lib/i18n/libISO2022.so.4.3 base-i18n-shlib -./usr/lib/i18n/libMSKanji.so.4.3 base-i18n-shlib -./usr/lib/i18n/libUTF1632.so.4.3 base-i18n-shlib -./usr/lib/i18n/libUTF7.so.4.3 base-i18n-shlib -./usr/lib/i18n/libUTF8.so.4.3 base-i18n-shlib -./usr/lib/i18n/libiconv_none.so.4.3 base-i18n-shlib -./usr/lib/i18n/libiconv_std.so.4.3 base-i18n-shlib -./usr/lib/i18n/libmapper_646.so.4.3 base-i18n-shlib -./usr/lib/i18n/libmapper_none.so.4.3 base-i18n-shlib -./usr/lib/i18n/libmapper_parallel.so.4.3 base-i18n-shlib -./usr/lib/i18n/libmapper_serial.so.4.3 base-i18n-shlib -./usr/lib/i18n/libmapper_std.so.4.3 base-i18n-shlib -./usr/lib/i18n/libmapper_zone.so.4.3 base-i18n-shlib +./usr/lib/i18n/libBIG5.so.4.4 base-i18n-shlib +./usr/lib/i18n/libEUC.so.4.4 base-i18n-shlib +./usr/lib/i18n/libEUCTW.so.4.4 base-i18n-shlib +./usr/lib/i18n/libGBK2K.so.4.4 base-i18n-shlib +./usr/lib/i18n/libISO2022.so.4.4 base-i18n-shlib +./usr/lib/i18n/libMSKanji.so.4.4 base-i18n-shlib +./usr/lib/i18n/libUTF1632.so.4.4 base-i18n-shlib +./usr/lib/i18n/libUTF7.so.4.4 base-i18n-shlib +./usr/lib/i18n/libUTF8.so.4.4 base-i18n-shlib +./usr/lib/i18n/libiconv_none.so.4.4 base-i18n-shlib +./usr/lib/i18n/libiconv_std.so.4.4 base-i18n-shlib +./usr/lib/i18n/libmapper_646.so.4.4 base-i18n-shlib +./usr/lib/i18n/libmapper_none.so.4.4 base-i18n-shlib +./usr/lib/i18n/libmapper_parallel.so.4.4 base-i18n-shlib +./usr/lib/i18n/libmapper_serial.so.4.4 base-i18n-shlib +./usr/lib/i18n/libmapper_std.so.4.4 base-i18n-shlib +./usr/lib/i18n/libmapper_zone.so.4.4 base-i18n-shlib ./usr/lib/libamu.so.2.1 base-amd-shlib ./usr/lib/libasn1.so.6.1 base-krb5-shlib kerberos ./usr/lib/libbsdmalloc.so.0.0 base-sys-shlib diff --git a/lib/i18n_module/shlib_version b/lib/i18n_module/shlib_version index 3f1d6817327c..a206db342ff8 100644 --- a/lib/i18n_module/shlib_version +++ b/lib/i18n_module/shlib_version @@ -1,5 +1,5 @@ -# $NetBSD: shlib_version,v 1.4 2003/07/01 09:42:17 tshiozak Exp $ +# $NetBSD: shlib_version,v 1.5 2005/10/29 18:02:04 tshiozak Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # major=4 -minor=3 +minor=4 diff --git a/lib/libc/citrus/citrus_namespace.h b/lib/libc/citrus/citrus_namespace.h index 549de90dcd91..7686791f8ea3 100644 --- a/lib/libc/citrus/citrus_namespace.h +++ b/lib/libc/citrus/citrus_namespace.h @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_namespace.h,v 1.5 2005/05/14 17:55:42 tshiozak Exp $ */ +/* $NetBSD: citrus_namespace.h,v 1.6 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -206,6 +206,7 @@ #define _stdenc _citrus_stdenc #define _stdenc_ops _citrus_stdenc_ops #define _stdenc_traits _citrus_stdenc_traits +#define _stdenc_state_desc _citrus_stdenc_state_desc #define _stdenc_open _citrus_stdenc_open #define _stdenc_close _citrus_stdenc_close #define _stdenc_init_state _citrus_stdenc_init_state @@ -216,6 +217,13 @@ #define _stdenc_put_state_reset _citrus_stdenc_put_state_reset #define _stdenc_get_state_size _citrus_stdenc_get_state_size #define _stdenc_get_mb_cur_max _citrus_stdenc_get_mb_cur_max +#define _stdenc_get_state_desc _citrus_stdenc_get_state_desc +#define _STDENC_SDID_GENERIC _CITRUS_STDENC_SDID_GENERIC +#define _STDENC_SDGEN_UNKNOWN _CITRUS_STDENC_SDGEN_UNKNOWN +#define _STDENC_SDGEN_INITIAL _CITRUS_STDENC_SDGEN_INITIAL +#define _STDENC_SDGEN_STABLE _CITRUS_STDENC_SDGEN_STABLE +#define _STDENC_SDGEN_INCOMPLETE_CHAR _CITRUS_STDENC_SDGEN_INCOMPLETE_CHAR +#define _STDENC_SDGEN_INCOMPLETE_SHIFT _CITRUS_STDENC_SDGEN_INCOMPLETE_SHIFT #endif /* _CITRUS_STDENC_NO_NAMESPACE */ /* citrus_types.h */ diff --git a/lib/libc/citrus/citrus_none.c b/lib/libc/citrus/citrus_none.c index 8e47b9e820b0..528cbeca1eab 100644 --- a/lib/libc/citrus/citrus_none.c +++ b/lib/libc/citrus/citrus_none.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_none.c,v 1.13 2005/03/27 18:51:19 christos Exp $ */ +/* $NetBSD: citrus_none.c,v 1.14 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2002 Citrus Project, @@ -28,7 +28,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_none.c,v 1.13 2005/03/27 18:51:19 christos Exp $"); +__RCSID("$NetBSD: citrus_none.c,v 1.14 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -478,3 +478,23 @@ _citrus_NONE_stdenc_put_state_reset(struct _citrus_stdenc * __restrict ce, return (0); } + +static int +/*ARGSUSED*/ +_citrus_NONE_stdenc_get_state_desc(struct _stdenc * __restrict ce, + void * __restrict ps, + int id, + struct _stdenc_state_desc * __restrict d) +{ + int ret; + + switch (id) { + case _STDENC_SDID_GENERIC: + d->u.generic.state = _STDENC_SDGEN_INITIAL; + break; + default: + ret = EOPNOTSUPP; + } + + return ret; +} diff --git a/lib/libc/citrus/citrus_stdenc.c b/lib/libc/citrus/citrus_stdenc.c index a7c5ce4b6eb1..d7840756924f 100644 --- a/lib/libc/citrus/citrus_stdenc.c +++ b/lib/libc/citrus/citrus_stdenc.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_stdenc.c,v 1.2 2003/07/10 08:50:44 tshiozak Exp $ */ +/* $NetBSD: citrus_stdenc.c,v 1.3 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -28,7 +28,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_stdenc.c,v 1.2 2003/07/10 08:50:44 tshiozak Exp $"); +__RCSID("$NetBSD: citrus_stdenc.c,v 1.3 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -52,6 +52,16 @@ struct _citrus_stdenc _citrus_stdenc_default = { #ifdef _I18N_DYNAMIC +static int +/*ARGSUSED*/ +get_state_desc_default(struct _citrus_stdenc * __restrict ce, + void * __restrict ps, + int id, + struct _citrus_stdenc_state_desc * __restrict d) +{ + return EOPNOTSUPP; +} + int _citrus_stdenc_open(struct _citrus_stdenc * __restrict * __restrict rce, char const * __restrict encname, @@ -106,6 +116,9 @@ _citrus_stdenc_open(struct _citrus_stdenc * __restrict * __restrict rce, goto bad; /* If return ABI version is not expected, should fixup it */ + if (ce->ce_ops->eo_abi_version < 0x00000002) { + ce->ce_ops->eo_get_state_desc = &get_state_desc_default; + } /* validation check */ if (ce->ce_ops->eo_init == NULL || @@ -114,7 +127,8 @@ _citrus_stdenc_open(struct _citrus_stdenc * __restrict * __restrict rce, ce->ce_ops->eo_mbtocs == NULL || ce->ce_ops->eo_cstomb == NULL || ce->ce_ops->eo_mbtowc == NULL || - ce->ce_ops->eo_wctomb == NULL) + ce->ce_ops->eo_wctomb == NULL || + ce->ce_ops->eo_get_state_desc == NULL) goto bad; /* allocate traits */ diff --git a/lib/libc/citrus/citrus_stdenc.h b/lib/libc/citrus/citrus_stdenc.h index bb3acb457a79..ce198db681a7 100644 --- a/lib/libc/citrus/citrus_stdenc.h +++ b/lib/libc/citrus/citrus_stdenc.h @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_stdenc.h,v 1.3 2003/07/10 08:50:44 tshiozak Exp $ */ +/* $NetBSD: citrus_stdenc.h,v 1.4 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -34,6 +34,21 @@ struct _citrus_stdenc; struct _citrus_stdenc_ops; struct _citrus_stdenc_traits; +#define _CITRUS_STDENC_SDID_GENERIC 0 +struct _citrus_stdenc_state_desc +{ + union { + struct { + int state; +#define _CITRUS_STDENC_SDGEN_UNKNOWN 0 +#define _CITRUS_STDENC_SDGEN_INITIAL 1 +#define _CITRUS_STDENC_SDGEN_STABLE 2 +#define _CITRUS_STDENC_SDGEN_INCOMPLETE_CHAR 3 +#define _CITRUS_STDENC_SDGEN_INCOMPLETE_SHIFT 4 + } generic; + } u; +}; + #include "citrus_stdenc_local.h" __BEGIN_DECLS @@ -115,4 +130,16 @@ _citrus_stdenc_get_mb_cur_max(struct _citrus_stdenc *ce) return ce->ce_traits->et_mb_cur_max; } +static __inline int +_citrus_stdenc_get_state_desc(struct _citrus_stdenc * __restrict ce, + void * __restrict ps, + int id, + struct _citrus_stdenc_state_desc * __restrict d) +{ + + _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_get_state_desc); + + return (*ce->ce_ops->eo_get_state_desc)(ce, ps, id, d); +} + #endif diff --git a/lib/libc/citrus/citrus_stdenc_local.h b/lib/libc/citrus/citrus_stdenc_local.h index 05d950edf838..79e5b8be24f8 100644 --- a/lib/libc/citrus/citrus_stdenc_local.h +++ b/lib/libc/citrus/citrus_stdenc_local.h @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_stdenc_local.h,v 1.2 2003/06/26 12:09:57 tshiozak Exp $ */ +/* $NetBSD: citrus_stdenc_local.h,v 1.3 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -63,7 +63,10 @@ static int _citrus_##_e_##_stdenc_wctomb \ _citrus_wc_t, void * __restrict, size_t * __restrict); \ static int _citrus_##_e_##_stdenc_put_state_reset \ (struct _citrus_stdenc * __restrict, char * __restrict, size_t, \ - void * __restrict, size_t * __restrict) + void * __restrict, size_t * __restrict); \ +static int _citrus_##_e_##_stdenc_get_state_desc \ + (struct _citrus_stdenc * __restrict, void * __restrict, int, \ + struct _citrus_stdenc_state_desc * __restrict) #define _CITRUS_STDENC_DEF_OPS(_e_) \ struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops = { \ @@ -75,7 +78,8 @@ struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops = { \ /* eo_cstomb */ &_citrus_##_e_##_stdenc_cstomb, \ /* eo_mbtowc */ &_citrus_##_e_##_stdenc_mbtowc, \ /* eo_wctomb */ &_citrus_##_e_##_stdenc_wctomb, \ - /* eo_put_state_reset */&_citrus_##_e_##_stdenc_put_state_reset \ + /* eo_put_state_reset */&_citrus_##_e_##_stdenc_put_state_reset,\ + /* eo_get_state_desc */ &_citrus_##_e_##_stdenc_get_state_desc \ } typedef int (*_citrus_stdenc_init_t) @@ -104,13 +108,15 @@ typedef int (*_citrus_stdenc_wctomb_t) typedef int (*_citrus_stdenc_put_state_reset_t) (struct _citrus_stdenc *__restrict, char * __restrict, size_t, void * __restrict, size_t * __restrict); - +typedef int (*_citrus_stdenc_get_state_desc_t) + (struct _citrus_stdenc * __restrict, void * __restrict, int, + struct _citrus_stdenc_state_desc * __restrict); /* * ABI version change log * 0x00000001 * initial version */ -#define _CITRUS_STDENC_ABI_VERSION 0x00000001 +#define _CITRUS_STDENC_ABI_VERSION 0x00000002 struct _citrus_stdenc_ops { u_int32_t eo_abi_version; /* version 0x00000001 */ @@ -122,6 +128,8 @@ struct _citrus_stdenc_ops { _citrus_stdenc_mbtowc_t eo_mbtowc; _citrus_stdenc_wctomb_t eo_wctomb; _citrus_stdenc_put_state_reset_t eo_put_state_reset; + /* version 0x00000002 */ + _citrus_stdenc_get_state_desc_t eo_get_state_desc; }; struct _citrus_stdenc_traits { diff --git a/lib/libc/citrus/citrus_stdenc_template.h b/lib/libc/citrus/citrus_stdenc_template.h index 772842528bbd..c02549043c57 100644 --- a/lib/libc/citrus/citrus_stdenc_template.h +++ b/lib/libc/citrus/citrus_stdenc_template.h @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_stdenc_template.h,v 1.2 2003/06/26 12:09:57 tshiozak Exp $ */ +/* $NetBSD: citrus_stdenc_template.h,v 1.3 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -184,3 +184,23 @@ _FUNCNAME(stdenc_put_state_reset)(struct _citrus_stdenc * __restrict ce, return 0; #endif } + +static int +_FUNCNAME(stdenc_get_state_desc)(struct _citrus_stdenc * __restrict ce, + void * __restrict ps, + int id, + struct _citrus_stdenc_state_desc * __restrict d) +{ + int ret; + + switch (id) { + case _STDENC_SDID_GENERIC: + ret = _FUNCNAME(stdenc_get_state_desc_generic)( + _CE_TO_EI(ce), _TO_STATE(ps), &d->u.generic.state); + break; + default: + ret = EOPNOTSUPP; + } + + return ret; +} diff --git a/lib/libc/citrus/modules/citrus_big5.c b/lib/libc/citrus/modules/citrus_big5.c index 80aa526af70c..0924c33b186c 100644 --- a/lib/libc/citrus/modules/citrus_big5.c +++ b/lib/libc/citrus/modules/citrus_big5.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_big5.c,v 1.8 2003/08/07 16:42:38 agc Exp $ */ +/* $NetBSD: citrus_big5.c,v 1.9 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2002 Citrus Project, @@ -60,7 +60,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_big5.c,v 1.8 2003/08/07 16:42:38 agc Exp $"); +__RCSID("$NetBSD: citrus_big5.c,v 1.9 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -343,7 +343,7 @@ _citrus_BIG5_stdenc_wctocs(_BIG5EncodingInfo * __restrict ei, else *csid = 1; *idx = (_index_t)wc; - + return 0; } @@ -379,6 +379,21 @@ _citrus_BIG5_stdenc_cstowc(_BIG5EncodingInfo * __restrict ei, return 0; } +static __inline int +/*ARGSUSED*/ +_citrus_BIG5_stdenc_get_state_desc_generic(_BIG5EncodingInfo * __restrict ei, + _BIG5State * __restrict psenc, + int * __restrict rstate) +{ + + if (psenc->chlen == 0) + *rstate = _STDENC_SDGEN_INITIAL; + else + *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; + + return 0; +} + /* ---------------------------------------------------------------------- * public interface for ctype */ diff --git a/lib/libc/citrus/modules/citrus_euc.c b/lib/libc/citrus/modules/citrus_euc.c index ae7bef500d1d..7528ad28accf 100644 --- a/lib/libc/citrus/modules/citrus_euc.c +++ b/lib/libc/citrus/modules/citrus_euc.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_euc.c,v 1.9 2005/10/18 06:42:12 tshiozak Exp $ */ +/* $NetBSD: citrus_euc.c,v 1.10 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2002 Citrus Project, @@ -60,7 +60,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_euc.c,v 1.9 2005/10/18 06:42:12 tshiozak Exp $"); +__RCSID("$NetBSD: citrus_euc.c,v 1.10 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -382,6 +382,21 @@ _citrus_EUC_stdenc_cstowc(_EUCEncodingInfo * __restrict ei, return (0); } +static __inline int +/*ARGSUSED*/ +_citrus_EUC_stdenc_get_state_desc_generic(_EUCEncodingInfo * __restrict ei, + _EUCState * __restrict psenc, + int * __restrict rstate) +{ + + if (psenc->chlen == 0) + *rstate = _STDENC_SDGEN_INITIAL; + else + *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; + + return 0; +} + static int /*ARGSUSED*/ _citrus_EUC_encoding_module_init(_EUCEncodingInfo * __restrict ei, diff --git a/lib/libc/citrus/modules/citrus_euctw.c b/lib/libc/citrus/modules/citrus_euctw.c index 5936688c7604..e328182699ef 100644 --- a/lib/libc/citrus/modules/citrus_euctw.c +++ b/lib/libc/citrus/modules/citrus_euctw.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_euctw.c,v 1.9 2005/03/27 22:30:06 tnozaki Exp $ */ +/* $NetBSD: citrus_euctw.c,v 1.10 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2002 Citrus Project, @@ -56,7 +56,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_euctw.c,v 1.9 2005/03/27 22:30:06 tnozaki Exp $"); +__RCSID("$NetBSD: citrus_euctw.c,v 1.10 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -395,6 +395,21 @@ _citrus_EUCTW_stdenc_cstowc(_EUCTWEncodingInfo * __restrict ei, return (0); } +static __inline int +/*ARGSUSED*/ +_citrus_EUCTW_stdenc_get_state_desc_generic(_EUCTWEncodingInfo * __restrict ei, + _EUCTWState * __restrict psenc, + int * __restrict rstate) +{ + + if (psenc->chlen == 0) + *rstate = _STDENC_SDGEN_INITIAL; + else + *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; + + return 0; +} + /* ---------------------------------------------------------------------- * public interface for ctype */ diff --git a/lib/libc/citrus/modules/citrus_gbk2k.c b/lib/libc/citrus/modules/citrus_gbk2k.c index 37d2dd08eb89..10c3ea37ba0c 100644 --- a/lib/libc/citrus/modules/citrus_gbk2k.c +++ b/lib/libc/citrus/modules/citrus_gbk2k.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_gbk2k.c,v 1.4 2003/06/26 12:09:57 tshiozak Exp $ */ +/* $NetBSD: citrus_gbk2k.c,v 1.5 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -28,7 +28,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_gbk2k.c,v 1.4 2003/06/26 12:09:57 tshiozak Exp $"); +__RCSID("$NetBSD: citrus_gbk2k.c,v 1.5 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -401,6 +401,21 @@ _citrus_GBK2K_stdenc_cstowc(_GBK2KEncodingInfo * __restrict ei, return 0; } +static __inline int +/*ARGSUSED*/ +_citrus_GBK2K_stdenc_get_state_desc_generic(_GBK2KEncodingInfo * __restrict ei, + _GBK2KState * __restrict psenc, + int * __restrict rstate) +{ + + if (psenc->chlen == 0) + *rstate = _STDENC_SDGEN_INITIAL; + else + *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; + + return 0; +} + static int /*ARGSUSED*/ _citrus_GBK2K_encoding_module_init(_GBK2KEncodingInfo * __restrict ei, diff --git a/lib/libc/citrus/modules/citrus_iconv_std.c b/lib/libc/citrus/modules/citrus_iconv_std.c index e23d5c8a9e91..87f4e4847fe9 100644 --- a/lib/libc/citrus/modules/citrus_iconv_std.c +++ b/lib/libc/citrus/modules/citrus_iconv_std.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_iconv_std.c,v 1.10 2005/02/11 06:21:21 simonb Exp $ */ +/* $NetBSD: citrus_iconv_std.c,v 1.11 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -28,7 +28,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_iconv_std.c,v 1.10 2005/02/11 06:21:21 simonb Exp $"); +__RCSID("$NetBSD: citrus_iconv_std.c,v 1.11 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -134,6 +134,20 @@ put_state_resetx(struct _citrus_iconv_std_encoding *se, return _stdenc_put_state_reset(se->se_handle, s, n, se->se_ps, nresult); } +static __inline int +get_state_desc_gen(struct _citrus_iconv_std_encoding *se, int *rstate) +{ + int ret; + struct _stdenc_state_desc ssd; + + ret = _stdenc_get_state_desc(se->se_handle, se->se_ps, + _STDENC_SDID_GENERIC, &ssd); + if (!ret) + *rstate = ssd.u.generic.state; + + return ret; +} + /* * init encoding context */ @@ -454,7 +468,7 @@ _citrus_iconv_std_iconv_convert(struct _citrus_iconv * __restrict cv, struct _citrus_iconv_std_context *sc = cv->cv_closure; _index_t idx; _csid_t csid; - int ret; + int ret, state; size_t szrin, szrout; size_t inval; const char *tmpin; @@ -508,6 +522,17 @@ _citrus_iconv_std_iconv_convert(struct _citrus_iconv * __restrict cv, if (szrin == (size_t)-2) { /* incompleted character */ + ret = get_state_desc_gen(&sc->sc_src_encoding, &state); + if (ret) { + ret = EINVAL; + goto err; + } + switch (state) { + case _STDENC_SDGEN_INITIAL: + case _STDENC_SDGEN_STABLE: + /* fetch shift sequences only. */ + goto next; + } ret = EINVAL; goto err; } diff --git a/lib/libc/citrus/modules/citrus_iso2022.c b/lib/libc/citrus/modules/citrus_iso2022.c index a233d72647f3..f222d67a3b47 100644 --- a/lib/libc/citrus/modules/citrus_iso2022.c +++ b/lib/libc/citrus/modules/citrus_iso2022.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_iso2022.c,v 1.13 2005/02/10 19:03:51 tnozaki Exp $ */ +/* $NetBSD: citrus_iso2022.c,v 1.14 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)1999, 2002 Citrus Project, @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_iso2022.c,v 1.13 2005/02/10 19:03:51 tnozaki Exp $"); +__RCSID("$NetBSD: citrus_iso2022.c,v 1.14 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -561,9 +561,9 @@ terminate: static wchar_t _ISO2022_sgetwchar(_ISO2022EncodingInfo * __restrict ei, - const char * __restrict string, size_t n, - const char ** __restrict result, - _ISO2022State * __restrict psenc) + const char * __restrict string, size_t n, + const char ** __restrict result, + _ISO2022State * __restrict psenc) { wchar_t wchar = 0; int cur; @@ -879,8 +879,8 @@ _citrus_ISO2022_mbrtowc_priv(_ISO2022EncodingInfo * __restrict ei, wchar = _ISO2022_sgetwchar(ei, p, psenc->chlen - (p-psenc->ch), &result, psenc); + c += result - p; if (wchar != _ISO2022INVALID) { - c += result - p; if (psenc->chlen > c) memmove(psenc->ch, result, psenc->chlen - c); if (psenc->chlen < c) @@ -890,11 +890,14 @@ _citrus_ISO2022_mbrtowc_priv(_ISO2022EncodingInfo * __restrict ei, goto output; } - c += result - p; - p = result; - - if (n == 0) + if (n == 0) { + if ((result - p) == psenc->chlen) + /* complete shift sequence. */ + psenc->chlen = 0; goto restart; + } + + p = result; } /* escape sequence too long? */ @@ -908,11 +911,14 @@ emptybuf: s0 = result; goto output; } - if (result > s0 && n > result - s0) { + if (result > s0) { c += (result - s0); n -= (result - s0); s0 = result; - goto emptybuf; + if (n>0) + goto emptybuf; + /* complete shift sequence. */ + goto restart; } n += c; if (n < sizeof(psenc->ch)) { @@ -1284,6 +1290,26 @@ _citrus_ISO2022_stdenc_cstowc(_ISO2022EncodingInfo * __restrict ei, return (0); } +static __inline int +/*ARGSUSED*/ +_citrus_ISO2022_stdenc_get_state_desc_generic(_ISO2022EncodingInfo * __restrict ei, + _ISO2022State * __restrict psenc, + int * __restrict rstate) +{ + + if (psenc->chlen == 0) { + /* XXX: it should distinguish initial and stable. */ + *rstate = _STDENC_SDGEN_STABLE; + } else { + if (psenc->ch[0] == '\033') + *rstate = _STDENC_SDGEN_INCOMPLETE_SHIFT; + else + *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; + } + + return 0; +} + /* ---------------------------------------------------------------------- * public interface for ctype */ diff --git a/lib/libc/citrus/modules/citrus_utf1632.c b/lib/libc/citrus/modules/citrus_utf1632.c index 5b22d3204f46..743a2d7a2353 100644 --- a/lib/libc/citrus/modules/citrus_utf1632.c +++ b/lib/libc/citrus/modules/citrus_utf1632.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_utf1632.c,v 1.3 2003/06/27 12:55:13 yamt Exp $ */ +/* $NetBSD: citrus_utf1632.c,v 1.4 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -28,7 +28,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_utf1632.c,v 1.3 2003/06/27 12:55:13 yamt Exp $"); +__RCSID("$NetBSD: citrus_utf1632.c,v 1.4 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -427,6 +427,20 @@ _citrus_UTF1632_stdenc_cstowc(_UTF1632EncodingInfo * __restrict ei, return (0); } +static __inline int +/*ARGSUSED*/ +_citrus_UTF1632_stdenc_get_state_desc_generic(_UTF1632EncodingInfo * __restrict ei, + _UTF1632State * __restrict psenc, + int * __restrict rstate) +{ + + if (psenc->chlen == 0) + *rstate = _STDENC_SDGEN_INITIAL; + else + *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; + + return 0; +} /* ---------------------------------------------------------------------- * public interface for stdenc diff --git a/lib/libc/citrus/modules/citrus_utf7.c b/lib/libc/citrus/modules/citrus_utf7.c index 92fcd0d36705..4cc1add61a91 100644 --- a/lib/libc/citrus/modules/citrus_utf7.c +++ b/lib/libc/citrus/modules/citrus_utf7.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_utf7.c,v 1.2 2005/03/14 03:43:10 tnozaki Exp $ */ +/* $NetBSD: citrus_utf7.c,v 1.3 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2004, 2005 Citrus Project, @@ -29,7 +29,7 @@ #include #if defined(LIB_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_utf7.c,v 1.2 2005/03/14 03:43:10 tnozaki Exp $"); +__RCSID("$NetBSD: citrus_utf7.c,v 1.3 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIB_SCCS and not lint */ #include @@ -511,6 +511,21 @@ _citrus_UTF7_stdenc_cstowc(_UTF7EncodingInfo * __restrict ei, return (0); } +static __inline int +/*ARGSUSED*/ +_citrus_UTF7_stdenc_get_state_desc_generic(_UTF7EncodingInfo * __restrict ei, + _UTF7State * __restrict psenc, + int * __restrict rstate) +{ + + if (psenc->chlen == 0) + *rstate = _STDENC_SDGEN_INITIAL; + else + *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; + + return 0; +} + static void /*ARGSUSED*/ _citrus_UTF7_encoding_module_uninit(_UTF7EncodingInfo *ei) @@ -526,7 +541,7 @@ _citrus_UTF7_encoding_module_init(_UTF7EncodingInfo * __restrict ei, { const char *s; - _DIAGASSERT(ei != NULL); + _DIAGASSERT(ei != NULL); /* var may be null */ memset(ei, 0, sizeof(*ei)); diff --git a/lib/libc/citrus/modules/citrus_utf8.c b/lib/libc/citrus/modules/citrus_utf8.c index 286d73859d98..d537e6bda1ca 100644 --- a/lib/libc/citrus/modules/citrus_utf8.c +++ b/lib/libc/citrus/modules/citrus_utf8.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_utf8.c,v 1.12 2005/03/11 23:32:03 christos Exp $ */ +/* $NetBSD: citrus_utf8.c,v 1.13 2005/10/29 18:02:04 tshiozak Exp $ */ /*- * Copyright (c)2002 Citrus Project, @@ -60,7 +60,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_utf8.c,v 1.12 2005/03/11 23:32:03 christos Exp $"); +__RCSID("$NetBSD: citrus_utf8.c,v 1.13 2005/10/29 18:02:04 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -363,6 +363,21 @@ _citrus_UTF8_stdenc_cstowc(_UTF8EncodingInfo * __restrict ei, return (0); } +static __inline int +/*ARGSUSED*/ +_citrus_UTF8_stdenc_get_state_desc_generic(_UTF8EncodingInfo * __restrict ei, + _UTF8State * __restrict psenc, + int * __restrict rstate) +{ + + if (psenc->chlen == 0) + *rstate = _STDENC_SDGEN_INITIAL; + else + *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; + + return 0; +} + static int /*ARGSUSED*/ _citrus_UTF8_encoding_module_init(_UTF8EncodingInfo * __restrict ei,