Permalink
Browse files

Apparently there are two different function signatures for the iconv …

…function. Account for that.
  • Loading branch information...
1 parent d8f9431 commit 5cf686b4d94d255defa5bcbd86dc200a41029dda @paulbaumgart paulbaumgart committed Feb 5, 2011
Showing with 17 additions and 10 deletions.
  1. +9 −9 configure
  2. +8 −1 src/binary-engine.cc
View
@@ -1,12 +1,12 @@
-echo "#include <JavaScriptCore/JavaScript.h>" > .check_JavaScript_h.h
-if gcc -E .check_JavaScript_h.h -framework JavaScriptCore &>/dev/null; then
- echo '#define HAVE_JAVASCRIPT_H 1' > include/config.h
- echo 'Detected <JavaScriptCore/JavaScript.h>'
+if echo "#include <JavaScriptCore/JavaScript.h>" | cpp &> /dev/null; then
+ echo "#define HAVE_JAVASCRIPT_H" > include/config.h
else
- echo '#ifdef HAVE_JAVASCRIPT_H' > include/config.h
- echo '#undef HAVE_JAVASCRIPT_H' >> include/config.h
- echo '#endif' >> include/config.h
- echo 'No <JavaScriptCore/JavaScript.h> detected. Using <JavaScriptCore/JavaScriptCore.h> instead.'
+ echo "#undef HAVE_JAVASCRIPT_H" > include/config.h
fi
-rm -f .check_JavaScript_h.h
+if echo "#include <iconv.h>" | cpp | egrep -C2 "size_t[\w]+iconv" |\
+ tr -d "\n" | egrep "const[\w]+char" &> /dev/null; then
+ echo "#define ICONV_REQUIRES_CONST_POINTER" > include/config.h
+else
+ echo "#undef ICONV_REQUIRES_CONST_POINTER" > include/config.h
+fi
View
@@ -185,13 +185,20 @@ int transcode(char *src, size_t srcLength, char **dstOut, size_t *dstLengthOut,
}
char *src_buf = src, *dst_buf = dst;
+
+#ifdef ICONV_REQUIRES_CONST_POINTER
+ const char **src_buf_ptr = &src_buf;
+#else
+ char **src_buf_ptr = &src_buf;
+#endif
+
size_t src_bytes_left = (size_t)srcLength, dst_bytes_left = (size_t)dst_length, converted=0;
while (dst_bytes_left > 0)
{
if (src_bytes_left == 0)
break;
- if ((converted = iconv(cd, &src_buf, &src_bytes_left, &dst_buf, &dst_bytes_left)) == (size_t)-1)
+ if ((converted = iconv(cd, src_buf_ptr, &src_bytes_left, &dst_buf, &dst_bytes_left)) == (size_t)-1)
{
if (errno != EINVAL)
{

0 comments on commit 5cf686b

Please sign in to comment.