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
This commit is contained in:
beard%netscape.com 2002-01-10 22:03:16 +00:00
parent ed70d129b9
commit ef6f78e3cf
2 changed files with 6 additions and 6 deletions

View File

@ -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;
}

View File

@ -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;