diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-07-12 18:26:36 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-07-12 18:26:36 +0000 |
commit | 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch) | |
tree | 2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /iconv/iconv_charmap.c | |
parent | 7d58530341304d403a6626d7f7a1913165fe2f32 (diff) | |
download | glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.bz2 glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip |
2.5-18.1
Diffstat (limited to 'iconv/iconv_charmap.c')
-rw-r--r-- | iconv/iconv_charmap.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/iconv/iconv_charmap.c b/iconv/iconv_charmap.c index 03a8f5fa23..a54d738120 100644 --- a/iconv/iconv_charmap.c +++ b/iconv/iconv_charmap.c @@ -1,22 +1,20 @@ /* Convert using charmaps and possibly iconv(). - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2001. - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. - The GNU C Library is distributed in the hope that it will be useful, + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <assert.h> #include <errno.h> @@ -367,19 +365,27 @@ use_to_charmap (const char *from_code, struct charmap_t *to_charmap) if (outptr != (char *) outbuf) { /* We got some output. Good, use it. */ - struct charseq *newp; + union + { + struct charseq seq; + struct + { + const char *name; + uint32_t ucs4; + int nbytes; + unsigned char bytes[outlen]; + } mem; + } new; outlen = sizeof (outbuf) - outlen; assert ((char *) outbuf + outlen == outptr); - newp = (struct charseq *) xmalloc (sizeof (struct charseq) - + outlen); - newp->name = out->name; - newp->ucs4 = out->ucs4; - newp->nbytes = outlen; - memcpy (newp->bytes, outbuf, outlen); + new.mem.name = out->name; + new.mem.ucs4 = out->ucs4; + new.mem.nbytes = outlen; + memcpy (new.mem.bytes, outbuf, outlen); - add_bytes (rettbl, newp, out); + add_bytes (rettbl, &new.seq, out); } /* Clear any possible state left behind. */ @@ -490,7 +496,7 @@ process_fd (struct convtable *tbl, int fd, FILE *output) process it in one step. */ static char *inbuf = NULL; static size_t maxlen = 0; - char *inptr = NULL; + char *inptr = inbuf; size_t actlen = 0; while (actlen < maxlen) |