Skip to content

Commit

Permalink
Bring back the Rhino regex patch to use native Java regex.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Robinson committed May 29, 2009
1 parent b8be5d3 commit 5446e1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Objective-J/Tools/objj/lib/objj/objjc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var File = require("file");
var window = require("browser/window");

require("./regexp-rhino-patch");

var exported = ["OBJJ_HOME", "objj_preprocess",
"FRAGMENT_FILE", "FRAGMENT_LOCAL",
"MARKER_CODE", "MARKER_IMPORT_STD", "MARKER_IMPORT_LOCAL",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
importClass(java.util.ArrayList);
importClass(java.util.List);
importClass(java.util.regex.Matcher);
importClass(java.util.regex.Pattern);
importClass(java.util.regex.PatternSyntaxException);

var CachedRegexData = [];

function regexDataFromRegex(aRegex)
Expand Down Expand Up @@ -37,10 +31,10 @@ function regexDataFromRegex(aRegex)
source = source.replace("(?<!\\\\)\\{(?!\\d)", "\\\\{", "g");
source = source.replace("(?<!(\\d,?|\\\\))\\}", "\\\\}", "g");

return CachedRegexData[string] = { pattern:Pattern.compile(source, 0), flags:flags };
return CachedRegexData[string] = { pattern:java.util.regex.Pattern.compile(source, 0), flags:flags };
}

String.prototype.match = function(regex)
function newMatch(regex)
{
var regexData = regexDataFromRegex(regex);

Expand Down Expand Up @@ -74,3 +68,6 @@ String.prototype.match = function(regex)

return groups;
}

if (system.platform === "rhino")
String.prototype.match = newMatch;

0 comments on commit 5446e1f

Please sign in to comment.