$OpenBSD: patch-libproxy_modules_pacrunner_mozjs_cpp,v 1.1 2013/08/10 12:46:23 ajacoutot Exp $

Support for mozjs-17.0 (from Fedora).
https://bugs.freedesktop.org/show_bug.cgi?id=59830
https://bugzilla.gnome.org/show_bug.cgi?id=690982

--- libproxy/modules/pacrunner_mozjs.cpp.orig	Fri Mar  9 18:46:11 2012
+++ libproxy/modules/pacrunner_mozjs.cpp	Sat Aug 10 10:18:18 2013
@@ -19,6 +19,7 @@
 
 #include <cstring> // ?
 #include <unistd.h> // gethostname
+#include <stdint.h>
 
 #include "../extension_pacrunner.hpp"
 using namespace libproxy;
@@ -76,12 +77,12 @@ static JSBool dnsResolve_(JSContext *cx, jsval hostnam
 		return true;
 }
 
-static JSBool dnsResolve(JSContext *cx, uintN /*argc*/, jsval *vp) {
+static JSBool dnsResolve(JSContext *cx, uint32_t /*argc*/, jsval *vp) {
 	jsval *argv = JS_ARGV(cx, vp);
 	return dnsResolve_(cx, argv[0], vp);
 }
 
-static JSBool myIpAddress(JSContext *cx, uintN /*argc*/, jsval *vp) {
+static JSBool myIpAddress(JSContext *cx, uint32_t /*argc*/, jsval *vp) {
 	char *hostname = (char *) JS_malloc(cx, 1024);
 	if (!gethostname(hostname, 1023)) {
 		JSString *myhost = JS_NewStringCopyN(cx, hostname, strlen(hostname));
@@ -98,7 +99,12 @@ static JSBool myIpAddress(JSContext *cx, uintN /*argc*
 static JSClass cls = {
 		"global", JSCLASS_GLOBAL_FLAGS,
 		JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-		JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
+		JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub,
+#if JS_VERSION == 186      
+		NULL,
+#else
+		JS_FinalizeStub,
+#endif
 		NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
 };
 
@@ -117,7 +123,11 @@ class mozjs_pacrunner : public pacrunner { (public)
 	    //JS_SetOptions(this->jsctx, JSOPTION_VAROBJFIX);
 	    //JS_SetVersion(this->jsctx, JSVERSION_LATEST);
 	    //JS_SetErrorReporter(cx, reportError);
+#if JS_VERSION == 186
+		if (!(this->jsglb = JS_NewGlobalObject(this->jsctx, &cls, NULL))) goto error;
+#else
 		if (!(this->jsglb = JS_NewCompartmentAndGlobalObject(this->jsctx, &cls, NULL))) goto error;
+#endif
 		if (!JS_InitStandardClasses(this->jsctx, this->jsglb))            goto error;
 
 		// Define Javascript functions
