JavaScriptCore:

        * kjs/*: Roll KDE 3.0.2 changes in. Also switch to not using APPLE_CHANGES
	for some of the changes that we definitely want to contribute upstream.

WebCore:

	* khtml/*: Roll KDE 3.0.2 changes in. Also switch to not using APPLE_CHANGES
	for some of the changes that we definitely want to contribute upstream.

        * WebCore.pbproj/project.pbxproj: Add KWQStyle.mm, remove KWQStyle.h, moving contents
	into qstyle.h.

        * kwq/KWQApplication.mm: (QApplication::globalStrut): Remove _logNotYetImplemented().

        * kwq/KWQButton.mm: (QButton::QButton): Use plain release, not autorelease.
        * kwq/KWQComboBox.mm: (QComboBox::init): Use plain release, not autorelease.
        * kwq/KWQListBox.mm: (QListBox::QListBox): Use plain release, not autorelease.
        * kwq/KWQPainter.mm: (QPainter::drawArc): Use plain release, not autorelease.

        * kwq/KWQKHTMLPartBrowserExtension.mm: Remove import of KWQKHTMLPartImpl.h, now that
	it's always part of khtml_part.h.
        * kwq/KWQKHTMLPartImpl.cpp: Simplify.
        * kwq/KWQKHTMLPartImpl.h: Add wrapper to allow multiple inclusion. Don't include
	khtml_part.h any more, since that file now includes this one to minimize changes to
	KDE code that needs to get to functions in here.
        * kwq/KWQKHTMLPartImpl.mm:
        (KHTMLPart::onURL), (KHTMLPart::nodeActivated), (KHTMLPart::setStatusBarText):
	Moved here from khtml_part.cpp.
        * kwq/KWQLoaderImpl.mm: Include khtml_part.h instead of KWQKHTMLPartImpl.h.

        * kwq/KWQPushButton.mm:
        (buttonFontMetrics), (QPushButton::fontMetrics): Added. Used by the form code to size buttons.
        * kwq/KWQStyle.mm: Added.
        (QStyle::sizeFromContents): Added. Used by the form code to size buttons.

        * kwq/KWQStyle.h: Removed.
        * kwq/qt/qstyle.h: Moved contents of KWQStyle.h in here.
        * kwq/qt/qwidget.h: Include <qstyle.h> rather than KWQStyle.h.

        * kwq/WebCoreBridge.mm: (-[WebCoreBridge isFrameSet]): Call straight to impl.

        * kwq/kdeui/klineedit.h: Add KLineEdit::frameWidth().
        * kwq/qt/qnamespace.h: Remove GUIStyle, MacStyle, and WindowsStyle.
        * kwq/qt/qpaintdevice.h: Add QInternal, QInternal::Printer, and QPaintDevice::devType().
        * kwq/qt/qpainter.h: Add QPainter::device().
        * kwq/qt/qpushbutton.h: Add QPushButton::fontMetrics().


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1623 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/kjs/string_object.cpp b/JavaScriptCore/kjs/string_object.cpp
index 7092df0..3564876 100644
--- a/JavaScriptCore/kjs/string_object.cpp
+++ b/JavaScriptCore/kjs/string_object.cpp
@@ -57,8 +57,8 @@
   match			StringProtoFuncImp::Match	DontEnum|Function	1
   replace		StringProtoFuncImp::Replace	DontEnum|Function	2
   search		StringProtoFuncImp::Search	DontEnum|Function	1
-  slice			StringProtoFuncImp::Slice	DontEnum|Function	0
-  split			StringProtoFuncImp::Split	DontEnum|Function	1
+  slice			StringProtoFuncImp::Slice	DontEnum|Function	2
+  split			StringProtoFuncImp::Split	DontEnum|Function	2
   substr		StringProtoFuncImp::Substr	DontEnum|Function	2
   substring		StringProtoFuncImp::Substring	DontEnum|Function	2
   toLowerCase		StringProtoFuncImp::ToLowerCase	DontEnum|Function	0
@@ -196,10 +196,11 @@
   case Match:
   case Search: {
     u = s;
-    RegExp* reg = 0;
+    RegExp *reg, *tmpReg = 0;
+    RegExpImp *imp = 0;
     if (a0.isA(ObjectType) && a0.toObject(exec).inherits(&RegExpImp::info))
     {
-      RegExpImp* imp = static_cast<RegExpImp *>( a0.toObject(exec).imp() );
+      imp = static_cast<RegExpImp *>( a0.toObject(exec).imp() );
       reg = imp->regExp();
     }
     else
@@ -208,24 +209,40 @@
        *  If regexp is not an object whose [[Class]] property is "RegExp", it is
        *  replaced with the result of the expression new RegExp(regexp).
        */
-      reg = new RegExp(a0.toString(exec), RegExp::None);
+      reg = tmpReg = new RegExp(a0.toString(exec), RegExp::None);
     }
     RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->interpreter()->builtinRegExp().imp());
-    int **ovector = regExpObj->registerRegexp( reg, u );
+    int **ovector = regExpObj->registerRegexp(reg, u);
     UString mstr = reg->match(u, -1, &pos, ovector);
-    regExpObj->setSubPatterns(reg->subPatterns());
-    if (a0.isA(StringType))
-      delete reg;
     if (id == Search) {
       result = Number(pos);
-      break;
+    } else {
+      // Exec
+      if ((reg->flags() & RegExp::Global) == 0) {
+	// case without 'g' flag is handled like RegExp.prototype.exec
+	if (mstr.isNull())
+	  return Null(); // no match
+	regExpObj->setSubPatterns(reg->subPatterns());
+	result = regExpObj->arrayOfMatches(exec,mstr);
+      } else {
+	// return array of matches
+	List list;
+	int lastIndex = 0;
+	while (pos >= 0) {
+	  list.append(String(mstr));
+	  lastIndex = pos;
+	  pos += mstr.isEmpty() ? 1 : mstr.size();
+	  delete [] *ovector;
+	  mstr = reg->match(u, pos, &pos, ovector);
+	}
+	if (imp)
+	  imp->put(exec, "lastIndex", Number(lastIndex), DontDelete|DontEnum);
+	result = exec->interpreter()->builtinArray().construct(exec, list);
+      }
     }
-    if (mstr.isNull())
-      result = Null();
-    else
-      result = regExpObj->arrayOfMatches(exec,mstr);
-  }
+    delete tmpReg;
     break;
+  }
   case Replace:
     u = s;
     if (a0.type() == ObjectType && a0.toObject(exec).inherits(&RegExpImp::info)) {
@@ -328,12 +345,13 @@
 	res.put(exec,"length", Number(0));
 	break;
       }
-      int *ovector;
-      int mpos;
       pos = 0;
-      while (1) {
+      while (pos < u.size()) {
 	// TODO: back references
+        int mpos;
+        int *ovector = 0L;
 	UString mstr = reg.match(u, pos, &mpos, &ovector);
+        delete [] ovector; ovector = 0L;
 	if (mpos < 0)
 	  break;
 	pos = mpos + (mstr.isEmpty() ? 1 : mstr.size());
@@ -343,7 +361,6 @@
 	  i++;
 	}
       }
-      delete [] ovector;
     } else if (a0.type() != UndefinedType) {
       u2 = a0.toString(exec);
       if (u2.isEmpty()) {