diff --git a/lib/libc/citrus/modules/citrus_iconv_std.c b/lib/libc/citrus/modules/citrus_iconv_std.c index 92b23d79b4ef..981f2d587d97 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.5 2003/07/12 15:39:20 tshiozak Exp $ */ +/* $NetBSD: citrus_iconv_std.c,v 1.6 2003/09/01 06:16:13 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.5 2003/07/12 15:39:20 tshiozak Exp $"); +__RCSID("$NetBSD: citrus_iconv_std.c,v 1.6 2003/09/01 06:16:13 tshiozak Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -463,7 +463,7 @@ _citrus_iconv_std_iconv_convert(struct _citrus_iconv * __restrict cv, if (in==NULL || *in==NULL) { /* special cases */ if (out!=NULL && *out!=NULL) { - /* init output state */ + /* init output state and store the shift sequence */ save_encoding_state(&sc->sc_src_encoding); save_encoding_state(&sc->sc_dst_encoding); szrout = 0; @@ -481,9 +481,11 @@ _citrus_iconv_std_iconv_convert(struct _citrus_iconv * __restrict cv, } *out += szrout; *outbytes -= szrout; - } - *invalids = 0; + } else + /* otherwise, discard the shift sequence */ + init_encoding_state(&sc->sc_dst_encoding); init_encoding_state(&sc->sc_src_encoding); + *invalids = 0; return 0; } diff --git a/lib/libc/iconv/iconv.3 b/lib/libc/iconv/iconv.3 index d4c4ba20e98a..11ce6c5d4e86 100644 --- a/lib/libc/iconv/iconv.3 +++ b/lib/libc/iconv/iconv.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: iconv.3,v 1.6 2003/08/22 14:05:03 kleink Exp $ +.\" $NetBSD: iconv.3,v 1.7 2003/09/01 06:16:14 tshiozak Exp $ .\" .\" Copyright (c)2003 Citrus Project, .\" All rights reserved. @@ -121,22 +121,33 @@ returns the number of such There are two special cases of .Fn iconv : .Bl -tag -width 0123 -.It "(src == NULL || *src == NULL) \*[Am]\*[Am] dst != NULL \*[Am]\*[Am] *dst != NULL" -If the destination codeset is stateful, -.Fa iconv -places the destination into its initial state and stores the shift -sequence for switching to the initial state in the buffer pointed -to by +.It "src == NULL || *src == NULL" +.\" +If the source and/or destination codesets are stateful, +.Fn iconv +places these into their initial state. +.Pp +If both +.Fa dst +and +.Fa *dst +are non-NULL, +.Fn iconv +stores the shift sequence for the destination switching to the initial state +in the buffer pointed to by .Fa *dst . The buffer size is specified by the value pointed to by .Fa dstleft as above. .Fn iconv will fail if the buffer is too small to store the shift sequence. -.It "(src == NULL || *src == NULL) \*[Am]\*[Am] (dst == NULL || *dst == NULL)" -If the source codeset is stateful, -.Fa iconv -places the source into its initial state. +.Pp +On the other hand, +.Fa dst +or +.Fa *dst +may be NULL. In this case, the shift sequence for the destination switching +to the initial state is discarded. .El .\" ---------------------------------------------------------------------- .Sh RETURN VALUES