mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Switch variants of |nsScanner::ReadUntil| to accept new string classes for |aTermSet| and to use |FindCharInReadable| instead of |nsString::FindChar|. Remove (function-scope) |static nsString|s from nsHTMLTokens.cpp. r=harishd@netscape.com sr=vidur@netscape.com b=65431
This commit is contained in:
parent
96d16a52dc
commit
9c4a46ab61
@ -527,7 +527,11 @@ PRInt32 CTextToken::GetTextLength(void) {
|
|||||||
* @return error result
|
* @return error result
|
||||||
*/
|
*/
|
||||||
nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) {
|
nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) {
|
||||||
static nsString theTerminals = NS_ConvertASCIItoUCS2("\n\r&<"); // XXXjag
|
static const PRUnichar theTerminalsChars[] =
|
||||||
|
{ PRUnichar('\n'), PRUnichar('\r'), PRUnichar('&'), PRUnichar('<'),
|
||||||
|
PRUnichar(0) };
|
||||||
|
const nsLocalString theTerminals(theTerminalsChars,
|
||||||
|
sizeof(theTerminalsChars)/sizeof(theTerminalsChars[0]) - 1);
|
||||||
nsresult result=NS_OK;
|
nsresult result=NS_OK;
|
||||||
PRBool done=PR_FALSE;
|
PRBool done=PR_FALSE;
|
||||||
nsReadingIterator<PRUnichar> origin, start, end;
|
nsReadingIterator<PRUnichar> origin, start, end;
|
||||||
@ -897,7 +901,12 @@ PRInt32 CMarkupDeclToken::GetTokenType(void) {
|
|||||||
* @return error result
|
* @return error result
|
||||||
*/
|
*/
|
||||||
nsresult CMarkupDeclToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) {
|
nsresult CMarkupDeclToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) {
|
||||||
static nsString theTerminals = NS_ConvertASCIItoUCS2("\n\r'\">"); // XXXjag
|
static const PRUnichar theTerminalsChars[] =
|
||||||
|
{ PRUnichar('\n'), PRUnichar('\r'), PRUnichar('\''), PRUnichar('"'),
|
||||||
|
PRUnichar('>'),
|
||||||
|
PRUnichar(0) };
|
||||||
|
const nsLocalString theTerminals(theTerminalsChars,
|
||||||
|
sizeof(theTerminalsChars)/sizeof(theTerminalsChars[0]) - 1);
|
||||||
nsresult result=NS_OK;
|
nsresult result=NS_OK;
|
||||||
PRBool done=PR_FALSE;
|
PRBool done=PR_FALSE;
|
||||||
PRUnichar quote=0;
|
PRUnichar quote=0;
|
||||||
@ -1520,7 +1529,12 @@ nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScann
|
|||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
nsresult ConsumeAttributeValueText(PRUnichar,nsString& aString,nsScanner& aScanner){
|
nsresult ConsumeAttributeValueText(PRUnichar,nsString& aString,nsScanner& aScanner){
|
||||||
static nsString theTerminals = NS_ConvertASCIItoUCS2("\b\t\n\r >"); // XXXjag
|
static const PRUnichar theTerminalsChars[] =
|
||||||
|
{ PRUnichar('\b'), PRUnichar('\t'), PRUnichar('\n'), PRUnichar('\r'),
|
||||||
|
PRUnichar(' '), PRUnichar('>'),
|
||||||
|
PRUnichar(0) };
|
||||||
|
const nsLocalString theTerminals(theTerminalsChars,
|
||||||
|
sizeof(theTerminalsChars)/sizeof(theTerminalsChars[0]) - 1);
|
||||||
nsresult result=aScanner.ReadUntil(aString,theTerminals,PR_FALSE);
|
nsresult result=aScanner.ReadUntil(aString,theTerminals,PR_FALSE);
|
||||||
|
|
||||||
//Let's force quotes if either the first or last char is quoted.
|
//Let's force quotes if either the first or last char is quoted.
|
||||||
@ -1569,7 +1583,12 @@ nsresult CAttributeToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 a
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//If you're here, handle an unquoted key.
|
//If you're here, handle an unquoted key.
|
||||||
static nsAutoString theTerminals = NS_ConvertASCIItoUCS2("\b\t\n\r \"=>"); // XXXjag
|
static const PRUnichar theTerminalsChars[] =
|
||||||
|
{ PRUnichar('\b'), PRUnichar('\t'), PRUnichar('\n'), PRUnichar('\r'),
|
||||||
|
PRUnichar(' '), PRUnichar('"'), PRUnichar('='), PRUnichar('>'),
|
||||||
|
PRUnichar(0) };
|
||||||
|
const nsLocalString theTerminals(theTerminalsChars,
|
||||||
|
sizeof(theTerminalsChars)/sizeof(theTerminalsChars[0]) - 1);
|
||||||
result=aScanner.ReadUntil(start,end,theTerminals,PR_FALSE);
|
result=aScanner.ReadUntil(start,end,theTerminals,PR_FALSE);
|
||||||
}
|
}
|
||||||
if (!aRetain) {
|
if (!aRetain) {
|
||||||
|
@ -1155,17 +1155,17 @@ nsresult nsScanner::ReadWhile(nsString& aString,
|
|||||||
* the set of INVALID characters
|
* the set of INVALID characters
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
nsresult nsScanner::ReadUntil(nsString& aString,
|
nsresult nsScanner::ReadUntil(nsAWritableString& aString,
|
||||||
nsString& aTerminalSet,
|
const nsAReadableString& aTerminalSet,
|
||||||
PRBool addTerminal){
|
PRBool addTerminal)
|
||||||
|
{
|
||||||
if (!mSlidingBuffer) {
|
if (!mSlidingBuffer) {
|
||||||
return kEOF;
|
return kEOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUnichar theChar=0;
|
PRUnichar theChar=0;
|
||||||
nsresult result=Peek(theChar);
|
nsresult result=Peek(theChar);
|
||||||
nsReadingIterator<PRUnichar> origin, current, end;
|
nsReadingIterator<PRUnichar> origin, current, end, setstart, setend;
|
||||||
|
|
||||||
origin = mCurrentPosition;
|
origin = mCurrentPosition;
|
||||||
current = origin;
|
current = origin;
|
||||||
@ -1175,8 +1175,9 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
|
|
||||||
theChar=*current;
|
theChar=*current;
|
||||||
if(theChar) {
|
if(theChar) {
|
||||||
PRInt32 pos=aTerminalSet.FindChar(theChar);
|
aTerminalSet.BeginReading(setstart);
|
||||||
if(kNotFound!=pos) {
|
aTerminalSet.EndReading(setend);
|
||||||
|
if (FindCharInReadable(theChar, setstart, setend)) {
|
||||||
if(addTerminal)
|
if(addTerminal)
|
||||||
current++;
|
current++;
|
||||||
AppendUnicodeTo(origin, current, aString);
|
AppendUnicodeTo(origin, current, aString);
|
||||||
@ -1208,10 +1209,10 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
* the set of INVALID characters
|
* the set of INVALID characters
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
nsresult nsScanner::ReadUntil(nsString& aString,
|
nsresult nsScanner::ReadUntil(nsAWritableString& aString,
|
||||||
nsCString& aTerminalSet,
|
const nsAReadableCString& aTerminalSet,
|
||||||
PRBool addTerminal){
|
PRBool addTerminal)
|
||||||
|
{
|
||||||
if (!mSlidingBuffer) {
|
if (!mSlidingBuffer) {
|
||||||
return kEOF;
|
return kEOF;
|
||||||
}
|
}
|
||||||
@ -1219,6 +1220,7 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
PRUnichar theChar=0;
|
PRUnichar theChar=0;
|
||||||
nsresult result=Peek(theChar);
|
nsresult result=Peek(theChar);
|
||||||
nsReadingIterator<PRUnichar> origin, current, end;
|
nsReadingIterator<PRUnichar> origin, current, end;
|
||||||
|
nsReadingIterator<char> setstart, setend;
|
||||||
|
|
||||||
origin = mCurrentPosition;
|
origin = mCurrentPosition;
|
||||||
current = origin;
|
current = origin;
|
||||||
@ -1228,8 +1230,9 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
|
|
||||||
theChar=*current;
|
theChar=*current;
|
||||||
if(theChar) {
|
if(theChar) {
|
||||||
PRInt32 pos=aTerminalSet.FindChar(theChar);
|
aTerminalSet.BeginReading(setstart);
|
||||||
if(kNotFound!=pos) {
|
aTerminalSet.EndReading(setend);
|
||||||
|
if (FindCharInReadable(theChar, setstart, setend)) {
|
||||||
if(addTerminal)
|
if(addTerminal)
|
||||||
current++;
|
current++;
|
||||||
AppendUnicodeTo(origin, current, aString);
|
AppendUnicodeTo(origin, current, aString);
|
||||||
@ -1252,16 +1255,16 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
|
|
||||||
nsresult nsScanner::ReadUntil(nsReadingIterator<PRUnichar>& aStart,
|
nsresult nsScanner::ReadUntil(nsReadingIterator<PRUnichar>& aStart,
|
||||||
nsReadingIterator<PRUnichar>& aEnd,
|
nsReadingIterator<PRUnichar>& aEnd,
|
||||||
nsString& aTerminalSet,
|
const nsAReadableString& aTerminalSet,
|
||||||
PRBool addTerminal){
|
PRBool addTerminal)
|
||||||
|
{
|
||||||
if (!mSlidingBuffer) {
|
if (!mSlidingBuffer) {
|
||||||
return kEOF;
|
return kEOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUnichar theChar=0;
|
PRUnichar theChar=0;
|
||||||
nsresult result=Peek(theChar);
|
nsresult result=Peek(theChar);
|
||||||
nsReadingIterator<PRUnichar> origin, current, end;
|
nsReadingIterator<PRUnichar> origin, current, end, setstart, setend;
|
||||||
|
|
||||||
origin = mCurrentPosition;
|
origin = mCurrentPosition;
|
||||||
current = origin;
|
current = origin;
|
||||||
@ -1271,8 +1274,9 @@ nsresult nsScanner::ReadUntil(nsReadingIterator<PRUnichar>& aStart,
|
|||||||
|
|
||||||
theChar=*current;
|
theChar=*current;
|
||||||
if(theChar) {
|
if(theChar) {
|
||||||
PRInt32 pos=aTerminalSet.FindChar(theChar);
|
aTerminalSet.BeginReading(setstart);
|
||||||
if(kNotFound!=pos) {
|
aTerminalSet.EndReading(setend);
|
||||||
|
if (FindCharInReadable(theChar, setstart, setend)) {
|
||||||
if(addTerminal)
|
if(addTerminal)
|
||||||
current++;
|
current++;
|
||||||
aStart = origin;
|
aStart = origin;
|
||||||
@ -1293,38 +1297,6 @@ nsresult nsScanner::ReadUntil(nsReadingIterator<PRUnichar>& aStart,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Consume characters until you encounter one contained in given
|
|
||||||
* input set.
|
|
||||||
*
|
|
||||||
* @update gess 3/25/98
|
|
||||||
* @param aString will contain the result of this method
|
|
||||||
* @param aTerminalSet is an ordered string that contains
|
|
||||||
* the set of INVALID characters
|
|
||||||
* @return error code
|
|
||||||
*/
|
|
||||||
nsresult nsScanner::ReadUntil(nsString& aString,
|
|
||||||
const char* aTerminalSet,
|
|
||||||
PRBool addTerminal)
|
|
||||||
{
|
|
||||||
if (!mSlidingBuffer) {
|
|
||||||
return kEOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult result=NS_OK;
|
|
||||||
if(aTerminalSet) {
|
|
||||||
PRInt32 len=nsCRT::strlen(aTerminalSet);
|
|
||||||
if(0<len) {
|
|
||||||
|
|
||||||
CBufDescriptor buf(aTerminalSet,PR_TRUE,len+1,len);
|
|
||||||
nsCAutoString theSet(buf);
|
|
||||||
|
|
||||||
result=ReadUntil(aString,theSet,addTerminal);
|
|
||||||
} //if
|
|
||||||
}//if
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consumes chars until you see the given terminalChar
|
* Consumes chars until you see the given terminalChar
|
||||||
*
|
*
|
||||||
@ -1332,9 +1304,10 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
* @param
|
* @param
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
nsresult nsScanner::ReadUntil(nsString& aString,
|
nsresult nsScanner::ReadUntil(nsAWritableString& aString,
|
||||||
PRUnichar aTerminalChar,
|
PRUnichar aTerminalChar,
|
||||||
PRBool addTerminal){
|
PRBool addTerminal)
|
||||||
|
{
|
||||||
if (!mSlidingBuffer) {
|
if (!mSlidingBuffer) {
|
||||||
return kEOF;
|
return kEOF;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,9 @@ class nsScanner {
|
|||||||
* @param addTerminal tells us whether to append terminal to aString
|
* @param addTerminal tells us whether to append terminal to aString
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
nsresult ReadUntil(nsString& aString,PRUnichar aTerminal,PRBool addTerminal);
|
nsresult ReadUntil(nsAWritableString& aString,
|
||||||
|
PRUnichar aTerminal,
|
||||||
|
PRBool addTerminal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consume characters until you find one contained in given
|
* Consume characters until you find one contained in given
|
||||||
@ -212,10 +214,28 @@ class nsScanner {
|
|||||||
* @param addTerminal tells us whether to append terminal to aString
|
* @param addTerminal tells us whether to append terminal to aString
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
nsresult ReadUntil(nsString& aString,nsString& aTermSet,PRBool addTerminal);
|
nsresult ReadUntil(nsAWritableString& aString,
|
||||||
nsresult ReadUntil(nsString& aString,nsCString& aTermSet,PRBool addTerminal);
|
const nsAReadableString& aTermSet,
|
||||||
nsresult ReadUntil(nsString& aString,const char* aTermSet,PRBool addTerminal);
|
PRBool addTerminal);
|
||||||
nsresult ReadUntil(nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd, nsString& aTerminalSet,PRBool addTerminal);
|
|
||||||
|
nsresult ReadUntil(nsAWritableString& aString,
|
||||||
|
const nsAReadableCString& aTermSet,
|
||||||
|
PRBool addTerminal);
|
||||||
|
|
||||||
|
nsresult ReadUntil(nsAWritableString& aString,
|
||||||
|
const char* aTerminalSet,
|
||||||
|
PRBool addTerminal)
|
||||||
|
{
|
||||||
|
return ReadUntil(aString,
|
||||||
|
NS_STATIC_CAST(const nsAReadableCString&,
|
||||||
|
nsLiteralCString(aTerminalSet)),
|
||||||
|
addTerminal);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult ReadUntil(nsReadingIterator<PRUnichar>& aStart,
|
||||||
|
nsReadingIterator<PRUnichar>& aEnd,
|
||||||
|
const nsAReadableString& aTerminalSet,
|
||||||
|
PRBool addTerminal);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -527,7 +527,11 @@ PRInt32 CTextToken::GetTextLength(void) {
|
|||||||
* @return error result
|
* @return error result
|
||||||
*/
|
*/
|
||||||
nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) {
|
nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) {
|
||||||
static nsString theTerminals = NS_ConvertASCIItoUCS2("\n\r&<"); // XXXjag
|
static const PRUnichar theTerminalsChars[] =
|
||||||
|
{ PRUnichar('\n'), PRUnichar('\r'), PRUnichar('&'), PRUnichar('<'),
|
||||||
|
PRUnichar(0) };
|
||||||
|
const nsLocalString theTerminals(theTerminalsChars,
|
||||||
|
sizeof(theTerminalsChars)/sizeof(theTerminalsChars[0]) - 1);
|
||||||
nsresult result=NS_OK;
|
nsresult result=NS_OK;
|
||||||
PRBool done=PR_FALSE;
|
PRBool done=PR_FALSE;
|
||||||
nsReadingIterator<PRUnichar> origin, start, end;
|
nsReadingIterator<PRUnichar> origin, start, end;
|
||||||
@ -897,7 +901,12 @@ PRInt32 CMarkupDeclToken::GetTokenType(void) {
|
|||||||
* @return error result
|
* @return error result
|
||||||
*/
|
*/
|
||||||
nsresult CMarkupDeclToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) {
|
nsresult CMarkupDeclToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) {
|
||||||
static nsString theTerminals = NS_ConvertASCIItoUCS2("\n\r'\">"); // XXXjag
|
static const PRUnichar theTerminalsChars[] =
|
||||||
|
{ PRUnichar('\n'), PRUnichar('\r'), PRUnichar('\''), PRUnichar('"'),
|
||||||
|
PRUnichar('>'),
|
||||||
|
PRUnichar(0) };
|
||||||
|
const nsLocalString theTerminals(theTerminalsChars,
|
||||||
|
sizeof(theTerminalsChars)/sizeof(theTerminalsChars[0]) - 1);
|
||||||
nsresult result=NS_OK;
|
nsresult result=NS_OK;
|
||||||
PRBool done=PR_FALSE;
|
PRBool done=PR_FALSE;
|
||||||
PRUnichar quote=0;
|
PRUnichar quote=0;
|
||||||
@ -1520,7 +1529,12 @@ nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScann
|
|||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
nsresult ConsumeAttributeValueText(PRUnichar,nsString& aString,nsScanner& aScanner){
|
nsresult ConsumeAttributeValueText(PRUnichar,nsString& aString,nsScanner& aScanner){
|
||||||
static nsString theTerminals = NS_ConvertASCIItoUCS2("\b\t\n\r >"); // XXXjag
|
static const PRUnichar theTerminalsChars[] =
|
||||||
|
{ PRUnichar('\b'), PRUnichar('\t'), PRUnichar('\n'), PRUnichar('\r'),
|
||||||
|
PRUnichar(' '), PRUnichar('>'),
|
||||||
|
PRUnichar(0) };
|
||||||
|
const nsLocalString theTerminals(theTerminalsChars,
|
||||||
|
sizeof(theTerminalsChars)/sizeof(theTerminalsChars[0]) - 1);
|
||||||
nsresult result=aScanner.ReadUntil(aString,theTerminals,PR_FALSE);
|
nsresult result=aScanner.ReadUntil(aString,theTerminals,PR_FALSE);
|
||||||
|
|
||||||
//Let's force quotes if either the first or last char is quoted.
|
//Let's force quotes if either the first or last char is quoted.
|
||||||
@ -1569,7 +1583,12 @@ nsresult CAttributeToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 a
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//If you're here, handle an unquoted key.
|
//If you're here, handle an unquoted key.
|
||||||
static nsAutoString theTerminals = NS_ConvertASCIItoUCS2("\b\t\n\r \"=>"); // XXXjag
|
static const PRUnichar theTerminalsChars[] =
|
||||||
|
{ PRUnichar('\b'), PRUnichar('\t'), PRUnichar('\n'), PRUnichar('\r'),
|
||||||
|
PRUnichar(' '), PRUnichar('"'), PRUnichar('='), PRUnichar('>'),
|
||||||
|
PRUnichar(0) };
|
||||||
|
const nsLocalString theTerminals(theTerminalsChars,
|
||||||
|
sizeof(theTerminalsChars)/sizeof(theTerminalsChars[0]) - 1);
|
||||||
result=aScanner.ReadUntil(start,end,theTerminals,PR_FALSE);
|
result=aScanner.ReadUntil(start,end,theTerminals,PR_FALSE);
|
||||||
}
|
}
|
||||||
if (!aRetain) {
|
if (!aRetain) {
|
||||||
|
@ -1155,17 +1155,17 @@ nsresult nsScanner::ReadWhile(nsString& aString,
|
|||||||
* the set of INVALID characters
|
* the set of INVALID characters
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
nsresult nsScanner::ReadUntil(nsString& aString,
|
nsresult nsScanner::ReadUntil(nsAWritableString& aString,
|
||||||
nsString& aTerminalSet,
|
const nsAReadableString& aTerminalSet,
|
||||||
PRBool addTerminal){
|
PRBool addTerminal)
|
||||||
|
{
|
||||||
if (!mSlidingBuffer) {
|
if (!mSlidingBuffer) {
|
||||||
return kEOF;
|
return kEOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUnichar theChar=0;
|
PRUnichar theChar=0;
|
||||||
nsresult result=Peek(theChar);
|
nsresult result=Peek(theChar);
|
||||||
nsReadingIterator<PRUnichar> origin, current, end;
|
nsReadingIterator<PRUnichar> origin, current, end, setstart, setend;
|
||||||
|
|
||||||
origin = mCurrentPosition;
|
origin = mCurrentPosition;
|
||||||
current = origin;
|
current = origin;
|
||||||
@ -1175,8 +1175,9 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
|
|
||||||
theChar=*current;
|
theChar=*current;
|
||||||
if(theChar) {
|
if(theChar) {
|
||||||
PRInt32 pos=aTerminalSet.FindChar(theChar);
|
aTerminalSet.BeginReading(setstart);
|
||||||
if(kNotFound!=pos) {
|
aTerminalSet.EndReading(setend);
|
||||||
|
if (FindCharInReadable(theChar, setstart, setend)) {
|
||||||
if(addTerminal)
|
if(addTerminal)
|
||||||
current++;
|
current++;
|
||||||
AppendUnicodeTo(origin, current, aString);
|
AppendUnicodeTo(origin, current, aString);
|
||||||
@ -1208,10 +1209,10 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
* the set of INVALID characters
|
* the set of INVALID characters
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
nsresult nsScanner::ReadUntil(nsString& aString,
|
nsresult nsScanner::ReadUntil(nsAWritableString& aString,
|
||||||
nsCString& aTerminalSet,
|
const nsAReadableCString& aTerminalSet,
|
||||||
PRBool addTerminal){
|
PRBool addTerminal)
|
||||||
|
{
|
||||||
if (!mSlidingBuffer) {
|
if (!mSlidingBuffer) {
|
||||||
return kEOF;
|
return kEOF;
|
||||||
}
|
}
|
||||||
@ -1219,6 +1220,7 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
PRUnichar theChar=0;
|
PRUnichar theChar=0;
|
||||||
nsresult result=Peek(theChar);
|
nsresult result=Peek(theChar);
|
||||||
nsReadingIterator<PRUnichar> origin, current, end;
|
nsReadingIterator<PRUnichar> origin, current, end;
|
||||||
|
nsReadingIterator<char> setstart, setend;
|
||||||
|
|
||||||
origin = mCurrentPosition;
|
origin = mCurrentPosition;
|
||||||
current = origin;
|
current = origin;
|
||||||
@ -1228,8 +1230,9 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
|
|
||||||
theChar=*current;
|
theChar=*current;
|
||||||
if(theChar) {
|
if(theChar) {
|
||||||
PRInt32 pos=aTerminalSet.FindChar(theChar);
|
aTerminalSet.BeginReading(setstart);
|
||||||
if(kNotFound!=pos) {
|
aTerminalSet.EndReading(setend);
|
||||||
|
if (FindCharInReadable(theChar, setstart, setend)) {
|
||||||
if(addTerminal)
|
if(addTerminal)
|
||||||
current++;
|
current++;
|
||||||
AppendUnicodeTo(origin, current, aString);
|
AppendUnicodeTo(origin, current, aString);
|
||||||
@ -1252,16 +1255,16 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
|
|
||||||
nsresult nsScanner::ReadUntil(nsReadingIterator<PRUnichar>& aStart,
|
nsresult nsScanner::ReadUntil(nsReadingIterator<PRUnichar>& aStart,
|
||||||
nsReadingIterator<PRUnichar>& aEnd,
|
nsReadingIterator<PRUnichar>& aEnd,
|
||||||
nsString& aTerminalSet,
|
const nsAReadableString& aTerminalSet,
|
||||||
PRBool addTerminal){
|
PRBool addTerminal)
|
||||||
|
{
|
||||||
if (!mSlidingBuffer) {
|
if (!mSlidingBuffer) {
|
||||||
return kEOF;
|
return kEOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUnichar theChar=0;
|
PRUnichar theChar=0;
|
||||||
nsresult result=Peek(theChar);
|
nsresult result=Peek(theChar);
|
||||||
nsReadingIterator<PRUnichar> origin, current, end;
|
nsReadingIterator<PRUnichar> origin, current, end, setstart, setend;
|
||||||
|
|
||||||
origin = mCurrentPosition;
|
origin = mCurrentPosition;
|
||||||
current = origin;
|
current = origin;
|
||||||
@ -1271,8 +1274,9 @@ nsresult nsScanner::ReadUntil(nsReadingIterator<PRUnichar>& aStart,
|
|||||||
|
|
||||||
theChar=*current;
|
theChar=*current;
|
||||||
if(theChar) {
|
if(theChar) {
|
||||||
PRInt32 pos=aTerminalSet.FindChar(theChar);
|
aTerminalSet.BeginReading(setstart);
|
||||||
if(kNotFound!=pos) {
|
aTerminalSet.EndReading(setend);
|
||||||
|
if (FindCharInReadable(theChar, setstart, setend)) {
|
||||||
if(addTerminal)
|
if(addTerminal)
|
||||||
current++;
|
current++;
|
||||||
aStart = origin;
|
aStart = origin;
|
||||||
@ -1293,38 +1297,6 @@ nsresult nsScanner::ReadUntil(nsReadingIterator<PRUnichar>& aStart,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Consume characters until you encounter one contained in given
|
|
||||||
* input set.
|
|
||||||
*
|
|
||||||
* @update gess 3/25/98
|
|
||||||
* @param aString will contain the result of this method
|
|
||||||
* @param aTerminalSet is an ordered string that contains
|
|
||||||
* the set of INVALID characters
|
|
||||||
* @return error code
|
|
||||||
*/
|
|
||||||
nsresult nsScanner::ReadUntil(nsString& aString,
|
|
||||||
const char* aTerminalSet,
|
|
||||||
PRBool addTerminal)
|
|
||||||
{
|
|
||||||
if (!mSlidingBuffer) {
|
|
||||||
return kEOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult result=NS_OK;
|
|
||||||
if(aTerminalSet) {
|
|
||||||
PRInt32 len=nsCRT::strlen(aTerminalSet);
|
|
||||||
if(0<len) {
|
|
||||||
|
|
||||||
CBufDescriptor buf(aTerminalSet,PR_TRUE,len+1,len);
|
|
||||||
nsCAutoString theSet(buf);
|
|
||||||
|
|
||||||
result=ReadUntil(aString,theSet,addTerminal);
|
|
||||||
} //if
|
|
||||||
}//if
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consumes chars until you see the given terminalChar
|
* Consumes chars until you see the given terminalChar
|
||||||
*
|
*
|
||||||
@ -1332,9 +1304,10 @@ nsresult nsScanner::ReadUntil(nsString& aString,
|
|||||||
* @param
|
* @param
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
nsresult nsScanner::ReadUntil(nsString& aString,
|
nsresult nsScanner::ReadUntil(nsAWritableString& aString,
|
||||||
PRUnichar aTerminalChar,
|
PRUnichar aTerminalChar,
|
||||||
PRBool addTerminal){
|
PRBool addTerminal)
|
||||||
|
{
|
||||||
if (!mSlidingBuffer) {
|
if (!mSlidingBuffer) {
|
||||||
return kEOF;
|
return kEOF;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,9 @@ class nsScanner {
|
|||||||
* @param addTerminal tells us whether to append terminal to aString
|
* @param addTerminal tells us whether to append terminal to aString
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
nsresult ReadUntil(nsString& aString,PRUnichar aTerminal,PRBool addTerminal);
|
nsresult ReadUntil(nsAWritableString& aString,
|
||||||
|
PRUnichar aTerminal,
|
||||||
|
PRBool addTerminal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consume characters until you find one contained in given
|
* Consume characters until you find one contained in given
|
||||||
@ -212,10 +214,28 @@ class nsScanner {
|
|||||||
* @param addTerminal tells us whether to append terminal to aString
|
* @param addTerminal tells us whether to append terminal to aString
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
nsresult ReadUntil(nsString& aString,nsString& aTermSet,PRBool addTerminal);
|
nsresult ReadUntil(nsAWritableString& aString,
|
||||||
nsresult ReadUntil(nsString& aString,nsCString& aTermSet,PRBool addTerminal);
|
const nsAReadableString& aTermSet,
|
||||||
nsresult ReadUntil(nsString& aString,const char* aTermSet,PRBool addTerminal);
|
PRBool addTerminal);
|
||||||
nsresult ReadUntil(nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd, nsString& aTerminalSet,PRBool addTerminal);
|
|
||||||
|
nsresult ReadUntil(nsAWritableString& aString,
|
||||||
|
const nsAReadableCString& aTermSet,
|
||||||
|
PRBool addTerminal);
|
||||||
|
|
||||||
|
nsresult ReadUntil(nsAWritableString& aString,
|
||||||
|
const char* aTerminalSet,
|
||||||
|
PRBool addTerminal)
|
||||||
|
{
|
||||||
|
return ReadUntil(aString,
|
||||||
|
NS_STATIC_CAST(const nsAReadableCString&,
|
||||||
|
nsLiteralCString(aTerminalSet)),
|
||||||
|
addTerminal);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult ReadUntil(nsReadingIterator<PRUnichar>& aStart,
|
||||||
|
nsReadingIterator<PRUnichar>& aEnd,
|
||||||
|
const nsAReadableString& aTerminalSet,
|
||||||
|
PRBool addTerminal);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user