Skip to content

Instantly share code, notes, and snippets.

@sideshowbarker
Created October 1, 2012 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sideshowbarker/3811142 to your computer and use it in GitHub Desktop.
Save sideshowbarker/3811142 to your computer and use it in GitHub Desktop.
diff -r ed90a83ab0fd relaxng/datatype/java/src/org/whattf/datatype/Pattern.java
--- a/relaxng/datatype/java/src/org/whattf/datatype/Pattern.java Sat Apr 21 17:35:50 2012 +0900
+++ b/relaxng/datatype/java/src/org/whattf/datatype/Pattern.java Mon Oct 01 20:44:03 2012 +0900
@@ -22,6 +22,8 @@
package org.whattf.datatype;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.EcmaError;
import org.mozilla.javascript.regexp.RegExpImpl;
import org.relaxng.datatype.DatatypeException;
@@ -58,11 +60,17 @@
throws DatatypeException {
// TODO find out what kind of thread concurrency guarantees are made
RegExpImpl rei = new RegExpImpl();
+ ContextFactory cf = new ContextFactory();
String anchoredRegex = "^(?:" + literal + ")$";
+ Context cx = cf.enterContext();
try {
- rei.compileRegExp(null, anchoredRegex, "");
- } catch (EcmaError ee) {
- throw newDatatypeException(ee.getErrorMessage());
+ try {
+ rei.compileRegExp(cx, anchoredRegex, "");
+ } catch (EcmaError ee) {
+ throw newDatatypeException(ee.getErrorMessage());
+ }
+ } finally {
+ Context.exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment