[gjs] The old JS_GetStringCharsAndLength is not the same



commit 246b23877331552e7deed3bdd763f01fd9c6a89f
Author: Sardem FF7 <sardemff7 pub gmail com>
Date:   Fri Jan 7 15:24:09 2011 +0100

    The old JS_GetStringCharsAndLength is not the same
    
    In the same commit, they changed the arguments of
    JS_GetStringCharsAndLength so it's not compatible
    with the old one
    
    Signed-off-by: Colin Walters <walters verbum org>

 configure.ac            |    2 +-
 gjs/byteArray.c         |    8 ++++----
 gjs/jsapi-util-string.c |   16 ++++++++--------
 3 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 04fa332..db8e561 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,7 +148,7 @@ fi
 
 AC_CHECK_LIB([mozjs], [JS_GetStringBytes], AC_DEFINE([HAVE_JS_GETSTRINGBYTES], [1], [Define if we still have JS_GetStringBytes]),, [$JS_LIBS])
 AC_CHECK_LIB([mozjs], [JS_GetFunctionName], AC_DEFINE([HAVE_JS_GETFUNCTIONNAME], [1], [Define if we still have JS_GetFunctionName]),, [$JS_LIBS])
-AC_CHECK_LIB([mozjs], [JS_GetStringCharsAndLength], AC_DEFINE([HAVE_JS_GETSTRINGCHARSANDLENGTH], [1], [Define if we have JS_GetStringCharsAndLength]),, [$JS_LIBS])
+AC_CHECK_LIB([mozjs], [JS_GetStringChars], AC_DEFINE([HAVE_JS_GETSTRINGCHARS], [1], [Define if we still have JS_GetStringChars]),, [$JS_LIBS])
 
 AC_MSG_CHECKING([for mozilla-js >= 2 ])
 if `$PKG_CONFIG --exists $JS_PACKAGE '>=' 2`; then
diff --git a/gjs/byteArray.c b/gjs/byteArray.c
index d88c029..a1d1ffe 100644
--- a/gjs/byteArray.c
+++ b/gjs/byteArray.c
@@ -678,13 +678,13 @@ from_string_func(JSContext *context,
         const jschar *u16_chars;
         gsize u16_len;
 
-#ifdef HAVE_JS_GETSTRINGCHARSANDLENGTH
+#ifdef HAVE_JS_GETSTRINGCHARS
+        u16_chars = JS_GetStringChars(JSVAL_TO_STRING(argv[0]));
+        u16_len = JS_GetStringLength(JSVAL_TO_STRING(argv[0]));
+#else
         u16_chars = JS_GetStringCharsAndLength(context, JSVAL_TO_STRING(argv[0]), &u16_len);
         if (u16_chars == NULL)
             goto out;
-#else
-        u16_chars = JS_GetStringChars(JSVAL_TO_STRING(argv[0]));
-        u16_len = JS_GetStringLength(JSVAL_TO_STRING(argv[0]));
 #endif
 
         error = NULL;
diff --git a/gjs/jsapi-util-string.c b/gjs/jsapi-util-string.c
index 0266baa..90b3c70 100644
--- a/gjs/jsapi-util-string.c
+++ b/gjs/jsapi-util-string.c
@@ -50,15 +50,15 @@ gjs_try_string_to_utf8 (JSContext  *context,
         return FALSE;
     }
 
-#ifdef HAVE_JS_GETSTRINGCHARSANDLENGTH
+#ifdef HAVE_JS_GETSTRINGCHARS
+    s = JS_GetStringChars(JSVAL_TO_STRING(string_val));
+    s_length = JS_GetStringLength(JSVAL_TO_STRING(string_val));
+#else
     s = JS_GetStringCharsAndLength(context, JSVAL_TO_STRING(string_val), &s_length);
     if (s == NULL) {
         JS_EndRequest(context);
         return FALSE;
     }
-#else
-    s = JS_GetStringChars(JSVAL_TO_STRING(string_val));
-    s_length = JS_GetStringLength(JSVAL_TO_STRING(string_val));
 #endif
 
     utf8_string = g_utf16_to_utf8(s,
@@ -429,13 +429,13 @@ gjs_string_get_uint16_data(JSContext       *context,
         goto out;
     }
 
-#ifdef HAVE_JS_GETSTRINGCHARSANDLENGTH
+#ifdef HAVE_JS_GETSTRINGCHARS
+    js_data = JS_GetStringChars(JSVAL_TO_STRING(value));
+    *len_p = JS_GetStringLength(JSVAL_TO_STRING(value));
+#else
     js_data = JS_GetStringCharsAndLength(context, JSVAL_TO_STRING(value), len_p);
     if (js_data == NULL)
         goto out;
-#else
-    js_data = JS_GetStringChars(JSVAL_TO_STRING(value));
-    *len_p = JS_GetStringLength(JSVAL_TO_STRING(value));
 #endif
     *data_p = g_memdup(js_data, sizeof(*js_data)*(*len_p));
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]