From ef6f78e3cf8438bb6fbebedd5eb53486fd9de623 Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Thu, 10 Jan 2002 22:03:16 +0000 Subject: [PATCH] Avoid use of String::c_str(), use String::begin() instead. This also works around a bug in Mac OS X's bastring.h. git-svn-id: svn://10.0.0.236/trunk@111860 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js2/src/js2runtime.cpp | 6 +++--- mozilla/js2/src/jsstring.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mozilla/js2/src/js2runtime.cpp b/mozilla/js2/src/js2runtime.cpp index f41a4db5ce3..d76fb83fe26 100644 --- a/mozilla/js2/src/js2runtime.cpp +++ b/mozilla/js2/src/js2runtime.cpp @@ -2213,7 +2213,7 @@ JSValue RegExp_Constructor(Context *cx, const JSValue& thisValue, JSValue *argv, if ((argc > 1) && !argv[1].isUndefined()) flagStr = argv[1].toString(cx).string; } - REParseState *parseResult = REParse(regexpStr->c_str(), regexpStr->length(), flagStr->c_str(), flagStr->length(), false); + REParseState *parseResult = REParse(regexpStr->begin(), regexpStr->length(), flagStr->begin(), flagStr->length(), false); if (parseResult) { thisObj->mPrivate = parseResult; // XXX ECMA spec says these are DONTENUM, but SpiderMonkey and test suite disagree @@ -2289,7 +2289,7 @@ JSValue RegExp_exec(Context *cx, const JSValue& thisValue, JSValue *argv, uint32 parseResult->lastIndex = (int)(lastIndex.toInteger(cx).f64); const String *str = argv[0].toString(cx).string; - REState *regexp_result = REExecute(parseResult, str->c_str(), str->length()); + REState *regexp_result = REExecute(parseResult, str->begin(), str->length()); if (regexp_result) { JSArrayInstance *resultArray = (JSArrayInstance *)Array_Type->newInstance(cx); String *matchStr = new String(str->substr(regexp_result->endIndex, regexp_result->length)); @@ -2329,7 +2329,7 @@ static JSValue RegExp_test(Context *cx, const JSValue& thisValue, JSValue *argv, cx->reportError(Exception::typeError, "RegExp.test can only be applied to RegExp objects"); if (argc > 0) { const String *str = argv[0].toString(cx).string; - REState *regexp_result = REExecute((REParseState *)(thisObj->mPrivate), str->c_str(), str->length()); + REState *regexp_result = REExecute((REParseState *)(thisObj->mPrivate), str->begin(), str->length()); if (regexp_result) return kTrueValue; } diff --git a/mozilla/js2/src/jsstring.cpp b/mozilla/js2/src/jsstring.cpp index 984f81103b6..04d662e9ab3 100644 --- a/mozilla/js2/src/jsstring.cpp +++ b/mozilla/js2/src/jsstring.cpp @@ -128,7 +128,7 @@ static JSValue String_match(Context *cx, const JSValue& thisValue, JSValue *argv parseResult->lastIndex = 0; uint32 index = 0; while (true) { - REState *regexp_result = REExecute(parseResult, S.string->c_str(), S.string->length()); + REState *regexp_result = REExecute(parseResult, S.string->begin(), S.string->length()); if (regexp_result == NULL) break; if (parseResult->lastIndex == index) @@ -144,7 +144,7 @@ static JSValue String_match(Context *cx, const JSValue& thisValue, JSValue *argv static const String interpretDollar(Context *cx, const String *replaceStr, uint32 dollarPos, const String *searchStr, REState *regexp_result, uint32 &skip) { skip = 2; - const char16 *dollarValue = replaceStr->c_str() + dollarPos + 1; + const char16 *dollarValue = replaceStr->begin() + dollarPos + 1; switch (*dollarValue) { case '$': return cx->Dollar_StringAtom; @@ -210,7 +210,7 @@ static JSValue String_replace(Context *cx, const JSValue& thisValue, JSValue *ar while (true) { if (parseResult->flags & GLOBAL) parseResult->lastIndex = (int32)index; - regexp_result = REExecute(parseResult, S.string->c_str(), S.string->length()); + regexp_result = REExecute(parseResult, S.string->begin(), S.string->length()); if (regexp_result) { String insertString; uint32 start = 0;