diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-11-24 02:08:40 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-11-24 02:08:40 +0000 |
commit | e34b0f2902588bbbfaf55829692e32c3c7134b74 (patch) | |
tree | 3d74df649b5b0bf80b4f6070e360f405516caec5 /iconv/iconv.c | |
parent | f43ce637b5f35b350b4dff6810dd6a7421fbb952 (diff) | |
download | glibc-e34b0f2902588bbbfaf55829692e32c3c7134b74.zip glibc-e34b0f2902588bbbfaf55829692e32c3c7134b74.tar.gz glibc-e34b0f2902588bbbfaf55829692e32c3c7134b74.tar.bz2 |
Update.cvs/libc-ud-971123
1997-11-24 03:01 Ulrich Drepper <drepper@cygnus.com>
* elf/dl-support.c: Call __libc_init_secure to make sure
__libc_enable_secure is defined early.
* sysdeps/generic/enbl-secure.c: Change function name to
__libc_init_secure and make it global instead of a constructor.
* iconv/gconv.c: Fix lots of bugs.
* iconv/gconv.h: Likewise.
* iconv/gconv_builtin.h: Likewise.
* iconv/gconv_close.c: Likewise.
* iconv/gconv_conf.c: Likewise.
* iconv/gconv_db.c: Likewise.
* iconv/gconv_dl.c: Likewise.
* iconv/gconv_open.c: Likewise.
* iconv/gconv_simple.c: Likewise.
* iconv/iconv.c: Likewise.
* iconv/iconv_close.c: Likewise.
* iconv/iconv_open.c: Likewise.
* wcsmbs/Makefile (routines): Add wmemrtowcs and wmemrtombs.
* wcsmbs/wchar.h: Add prototypes for wmemrtowcs and wmemrtombs.
* wcsmbs/wmemrtombs.c: New file.
* wcsmbs/wmemrtowcs.c: New file.
Diffstat (limited to 'iconv/iconv.c')
-rw-r--r-- | iconv/iconv.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/iconv/iconv.c b/iconv/iconv.c index e5b0eb7..8804e85 100644 --- a/iconv/iconv.c +++ b/iconv/iconv.c @@ -19,9 +19,12 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <errno.h> #include <iconv.h> #include <gconv.h> +#include <assert.h> + size_t iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, @@ -29,10 +32,39 @@ iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, { gconv_t gcd = (gconv_t) cd; size_t converted; + int result; + + result = __gconv (gcd, inbuf, inbytesleft, outbuf, outbytesleft, &converted); + switch (result) + { + case GCONV_ILLEGAL_DESCRIPTOR: + __set_errno (EBADF); + converted = (size_t) -1L; + break; + + case GCONV_ILLEGAL_INPUT: + __set_errno (EILSEQ); + converted = (size_t) -1L; + break; + + case GCONV_FULL_OUTPUT: + __set_errno (E2BIG); + converted = (size_t) -1L; + break; + + case GCONV_INCOMPLETE_INPUT: + __set_errno (EINVAL); + converted = (size_t) -1L; + break; + + case GCONV_EMPTY_INPUT: + case GCONV_OK: + /* Nothing. */ + break; - if (__gconv (gcd, inbuf, inbytesleft, outbuf, outbytesleft, &converted) - != GCONV_OK) - return (size_t) -1; + default: + assert (!"Nothing like this should happen"); + } return converted; } |