[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] environ and iconv on FreeBSD
From: |
Holger Hans Peter Freyther |
Subject: |
[Help-smalltalk] environ and iconv on FreeBSD |
Date: |
Fri, 10 May 2013 07:53:01 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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)
{
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);
}
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?
- [Help-smalltalk] environ and iconv on FreeBSD,
Holger Hans Peter Freyther <=