[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] environ and iconv on FreeBSD
From: |
Paolo Bonzini |
Subject: |
Re: [Help-smalltalk] environ and iconv on FreeBSD |
Date: |
Sat, 11 May 2013 18:38:29 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 |
Il 10/05/2013 07:53, Holger Hans Peter Freyther ha scritto:
> Dear Paolo,
>
> compiling libgst on FreeBSD caued a compilation error on FreeBSD.
>
> --- a/libgst/cint.c
> +++ b/libgst/cint.c
> @@ -396,6 +396,8 @@ my_putenv (const char *str)
> return (putenv (clone));
> }
>
> +extern char **environ;
> +
> static char **
> get_environ (void)
> {
>
>
Please add AC_CHECK_DECL to configure.ac, and guard this by #ifdef
HAVE_DECL_ENVIRON.
> and running the Grease tests caused a segfault. This is due FreeBSD
> GNU libiconv doesn't understand 'utf8' it must be 'UTF-8' and the
> calls to iconv_open do not check the return value, e.g it is
> (iconv_t) -1 in case of error.
>
> diff --git a/packages/iconv/iconv.c b/packages/iconv/iconv.c
> index 80c97c6..3125a3c 100644
> --- a/packages/iconv/iconv.c
> +++ b/packages/iconv/iconv.c
> @@ -74,6 +74,9 @@ iconvWrapper (iconv_t handle, OOP readBufferOOP, int
> readPos,
>
> gst_object bytesLeft, readBuffer, writeBuffer;
>
> + //if (handle == (iconv_t) -1)
> + // return 0;
> +
> readBuffer = OOP_TO_OBJ (readBufferOOP);
> inbuf = &STRING_OOP_AT (readBuffer, readPos);
> inbytesleft = readCount;
> @@ -92,11 +95,33 @@ iconvWrapper (iconv_t handle, OOP readBufferOOP, int
> readPos,
> return (save_errno != EILSEQ);
> }
>
> +iconv_t my_iconv_open(const char *_tocode, const char *_fromcode)
> +{
> + const char *fromcode = _fromcode;
> + const char *tocode = _tocode;
> + if (strcmp(tocode, "utf8") == 0)
> + tocode = "UTF-8";
> + if (strcmp(fromcode, "utf8") == 0)
> + fromcode = "UTF-8";
> +
> + iconv_t res = iconv_open(tocode, fromcode);
> + if (res == (iconv_t) -1)
> + printf("Got error for '%s' '%s'\n", tocode, fromcode);
> + return res;
> +}
> +
> +int my_iconv_close(iconv_t cd)
> +{
> + if (cd != (iconv_t) -1)
> + iconv_close(cd);
> + return 0;
> +}
> +
> void
> gst_initModule (VMProxy * proxy)
> {
> vmProxy = proxy;
> - vmProxy->defineCFunc ("iconv_open", iconv_open);
> - vmProxy->defineCFunc ("iconv_close", iconv_close);
> + vmProxy->defineCFunc ("iconv_open", my_iconv_open);
> + vmProxy->defineCFunc ("iconv_close", my_iconv_close);
> vmProxy->defineCFunc ("iconvWrapper", iconvWrapper);
> }
Please do this in the Smalltalk code instead... we can generalize it to
a list of aliases later.
>
> and the complex test is failing in raisedTo but I didn't debug this one. So
> how
> should we move forward on these two issues?
Paolo