X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=encoding.c;h=1104f681999a6e2664f73e38c60cd0a4e0cf69ad;hb=fdcc3ac19960afc4ee198a82cb397afa34ca6a67;hp=9d842cced378336f6b5dea1e959062127cdd855c;hpb=a54348309c92f4d7a2dd66b4055122a7be19ca28;p=gedcom-parse.git diff --git a/encoding.c b/encoding.c index 9d842cc..1104f68 100644 --- a/encoding.c +++ b/encoding.c @@ -1,3 +1,12 @@ +/* This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + + (C) 2001 by The Genes Development Team + Original author: Peter Verthez (Peter.Verthez@advalvas.be) +*/ + /* $Id$ */ /* $Name$ */ @@ -105,7 +114,7 @@ void set_encoding_width(ENCODING enc) } static char conv_buf[MAXGEDCLINELEN * 2]; -static int conv_buf_size; +static size_t conv_buf_size; int open_conv_to_internal(char* fromcode) { @@ -135,7 +144,6 @@ void close_conv_to_internal() char* to_internal(char* str, size_t len) { - size_t insize; size_t outsize = MAXGEDCLINELEN * 2; char *wrptr = int_buf; char *rdptr = conv_buf; @@ -143,15 +151,13 @@ char* to_internal(char* str, size_t len) /* can't use strcpy, because possible null bytes from unicode */ memcpy(conv_buf + conv_buf_size, str, len); conv_buf_size += len; - insize = conv_buf_size; /* set up output buffer (empty it) */ memset(int_buf, 0, sizeof(int_buf)); /* do the conversion */ - iconv(cd_to_internal, &rdptr, &insize, &wrptr, &outsize); + iconv(cd_to_internal, &rdptr, &conv_buf_size, &wrptr, &outsize); /* then shift what is left over to the head of the input buffer */ - memmove(conv_buf, rdptr, insize); - memset(conv_buf + insize, 0, sizeof(conv_buf) - insize); - conv_buf_size = insize; + memmove(conv_buf, rdptr, conv_buf_size); + memset(conv_buf + conv_buf_size, 0, sizeof(conv_buf) - conv_buf_size); return int_buf; }