[gjs] Silence a warning with JSLocaleToUnicode
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] Silence a warning with JSLocaleToUnicode
- Date: Wed, 16 Feb 2011 16:41:03 +0000 (UTC)
commit bd15bc75b9f4cbd60443b973eb582ebb7df69915
Author: Marc-Antoine Perennou <Marc-Antoine Perennou com>
Date: Tue Feb 15 17:58:53 2011 +0100
Silence a warning with JSLocaleToUnicode
Since upstream commit http://hg.mozilla.org/mozilla-central/rev/f971ad6ed5a5
JSLocaleToUnicode takes a const char*, not a char* for its src.
Conditionally handle this to silent a warning.
https://bugzilla.gnome.org/show_bug.cgi?id=642186
configure.ac | 22 +++++++++++++++++++++-
gjs/context.c | 10 +++++++---
2 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5ff896b..aa819a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,7 +164,7 @@ if `$PKG_CONFIG --exists $JS_PACKAGE '>=' 2`; then
, [$JS_LIBS])
AC_CHECK_LIB([mozjs], [JS_EndPC], AC_DEFINE([HAVE_JS_ENDPC], [1], [Define if we have JS_EndPC]),
, [$JS_LIBS])
- AC_CHECK_LIB([mozjs], [JS_NewCompartmentAndGlobalObject],
+ AC_CHECK_LIB([mozjs], [JS_NewCompartmentAndGlobalObject],
AC_DEFINE([HAVE_JS_NEWCOMPARTMENTANDGLOBALOBJECT], [1], [Define if we have JS_NewCompartmentAndGlobalObject]),
, [$JS_LIBS])
@@ -201,6 +201,26 @@ if test "$js_extra_cflags_needed" = yes; then
fi
AC_SUBST([JS_EXTRA_CFLAGS])
+AC_MSG_CHECKING([whether JSLocaleToUnicode takes a const char*])
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $JS_CFLAGS -Wno-unused -Werror"
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
+ #include <jsapi.h>
+ extern JSBool test_fun (JSContext*, const char*, jsval*);
+ ]],
+ [[JSLocaleToUnicode jsltu = test_fun;]]
+ )],
+ [have_jslocale_to_unicode_const=yes],
+ [have_jslocale_to_unicode_const=no])
+AC_MSG_RESULT([$have_jslocale_to_unicode_const])
+CFLAGS="$save_CFLAGS"
+
+if test "$have_jslocale_to_unicode_const" = yes; then
+ AC_DEFINE([JS_LOCALETOUNICODE_NEEDS_CONST_CHAR], [1], [Define if JSLocaleToUnicode takes a const char* for its src])
+fi
+
common_packages="gobject-2.0 >= gobject_required_version $JS_PACKAGE"
gjs_packages="gmodule-2.0 gthread-2.0 $common_packages"
gjs_gi_packages="gobject-introspection-1.0 >= 0.10.1 $common_packages"
diff --git a/gjs/context.c b/gjs/context.c
index 4d8291c..758a25a 100644
--- a/gjs/context.c
+++ b/gjs/context.c
@@ -483,9 +483,13 @@ out:
}
static JSBool
-gjs_locale_to_unicode (JSContext *context,
- char *src,
- jsval *retval)
+gjs_locale_to_unicode (JSContext *context,
+#ifdef JS_LOCALETOUNICODE_NEEDS_CONST_CHAR
+ const char *src,
+#else
+ char *src,
+#endif
+ jsval *retval)
{
JSBool success;
char *utf8;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]