diff options
author | Paul Joseph Davis <davisp@apache.org> | 2011-09-08 05:00:10 +0000 |
---|---|---|
committer | Paul Joseph Davis <davisp@apache.org> | 2011-09-08 05:00:10 +0000 |
commit | 71081311b2b11ed923869ce5bd11ce7b0fd1da2c (patch) | |
tree | 85c5613959f8435e4b3de922765b01ecb945477d /src/couchdb/priv/couch_js/utf8.c | |
parent | 61ca44e384ca10b0b7bf68123c79ed43715ea9c9 (diff) |
Fix CouchJS compatibility with older SpiderMonkey.
This is a backport of the work to make CouchJS build against all of the
major versions of SpiderMonkey. Thanks to Randall Leeds and Chris
Coulson for the original patches.
Backport based on r1137464 and r1164346
Fixes COUCHDB-1078
Fixes COUCHDB-1260
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1166525 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/priv/couch_js/utf8.c')
-rw-r--r-- | src/couchdb/priv/couch_js/utf8.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/couchdb/priv/couch_js/utf8.c b/src/couchdb/priv/couch_js/utf8.c index 699a6fee..d6064267 100644 --- a/src/couchdb/priv/couch_js/utf8.c +++ b/src/couchdb/priv/couch_js/utf8.c @@ -11,6 +11,7 @@ // the License. #include <jsapi.h> +#include "config.h" static int enc_char(uint8 *utf8Buffer, uint32 ucs4Char) @@ -121,7 +122,7 @@ char* enc_string(JSContext* cx, jsval arg, size_t* buflen) { JSString* str = NULL; - jschar* src = NULL; + const jschar* src = NULL; char* bytes = NULL; size_t srclen = 0; size_t byteslen = 0; @@ -129,8 +130,12 @@ enc_string(JSContext* cx, jsval arg, size_t* buflen) str = JS_ValueToString(cx, arg); if(!str) goto error; +#ifdef HAVE_JS_GET_STRING_CHARS_AND_LENGTH + src = JS_GetStringCharsAndLength(cx, str, &srclen); +#else src = JS_GetStringChars(str); srclen = JS_GetStringLength(str); +#endif if(!enc_charbuf(src, srclen, NULL, &byteslen)) goto error; @@ -283,4 +288,4 @@ error: success: return str; -}
\ No newline at end of file +} |