From e29762850498ac694fa162e769a08fb9acfb29b5 Mon Sep 17 00:00:00 2001 From: "nboyd%atg.com" Date: Tue, 28 Nov 2000 16:23:24 +0000 Subject: [PATCH] Fix bug 61267. --- .../javascript/regexp/NativeRegExp.java | 18 ++++++++++++++++++ .../javascript/regexp/NativeRegExp.java | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/js/rhino/org/mozilla/javascript/regexp/NativeRegExp.java b/js/rhino/org/mozilla/javascript/regexp/NativeRegExp.java index 5db55fc44910..8a7b3ab14964 100644 --- a/js/rhino/org/mozilla/javascript/regexp/NativeRegExp.java +++ b/js/rhino/org/mozilla/javascript/regexp/NativeRegExp.java @@ -176,6 +176,24 @@ public class NativeRegExp extends ScriptableObject implements Function { Object[] args, Function funObj) { NativeRegExp thisObj = (NativeRegExp) thisVal; // XXX check cast + if (args[0] instanceof NativeRegExp) { + if (args.length > 1) { + // report error + throw NativeGlobal.constructError( + cx, "TypeError", + "only one argument may be specified " + + "if the first argument is a RegExp object", + funObj); + } + NativeRegExp thatObj = (NativeRegExp) args[0]; + thisObj.source = thatObj.source; + thisObj.lastIndex = thatObj.lastIndex; + thisObj.parenCount = thatObj.parenCount; + thisObj.flags = thatObj.flags; + thisObj.program = thatObj.program; + thisObj.ren = thatObj.ren; + return thisObj; + } String s = args.length == 0 ? "" : ScriptRuntime.toString(args[0]); String global = args.length > 1 ? ScriptRuntime.toString(args[1]) : null; diff --git a/js/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java b/js/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java index 5db55fc44910..8a7b3ab14964 100644 --- a/js/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java +++ b/js/rhino/src/org/mozilla/javascript/regexp/NativeRegExp.java @@ -176,6 +176,24 @@ public class NativeRegExp extends ScriptableObject implements Function { Object[] args, Function funObj) { NativeRegExp thisObj = (NativeRegExp) thisVal; // XXX check cast + if (args[0] instanceof NativeRegExp) { + if (args.length > 1) { + // report error + throw NativeGlobal.constructError( + cx, "TypeError", + "only one argument may be specified " + + "if the first argument is a RegExp object", + funObj); + } + NativeRegExp thatObj = (NativeRegExp) args[0]; + thisObj.source = thatObj.source; + thisObj.lastIndex = thatObj.lastIndex; + thisObj.parenCount = thatObj.parenCount; + thisObj.flags = thatObj.flags; + thisObj.program = thatObj.program; + thisObj.ren = thatObj.ren; + return thisObj; + } String s = args.length == 0 ? "" : ScriptRuntime.toString(args[0]); String global = args.length > 1 ? ScriptRuntime.toString(args[1]) : null;