line.Cut(0, 5);   inDirInput = PR_FALSE;  if (line.Find("next", PR_TRUE) == 0) { inDirInput = PR_TRUE; if (whichButtons) *whichButtons |= kHaveNext; }  if (line.Find("prev", PR_TRUE) == 0) { inDirInput = PR_TRUE; if (whichButtons) *whichButtons |= kHavePrev; }  if (inDirInput) line.Cut(0, 4);  line.Trim(" \t");
line.Cut(0, 6); line = line.Trim(" \t");
InternetSearchDataSource::GetInputs(const PRUnichar *dataUni, nsString &userVar,  const nsString &text, nsString &input, PRInt16 direction, PRUint16 pageNumber,  PRUint16 *whichButtons){	nsString	buffer(dataUni);	nsresult	rv = NS_OK;	PRBool		inSection = PR_FALSE;  PRBool        inDirInput; // directional input: "inputnext" or "inputprev"	while(buffer.Length() > 0)	{		PRInt32 eol = buffer.FindCharInSet("\r\n", 0);		if (eol < 0)	break;		nsAutoString	line;		if (eol > 0)		{			buffer.Left(line, eol);		}		buffer.Cut(0, eol+1);		if (line.Length() < 1)	continue;		// skip empty lines		if (line[0] == PRUnichar('#'))	continue;	// skip comments		line.Trim(" \t");		if (inSection == PR_FALSE)		{			if (line[0] != PRUnichar('<'))	continue;			line.Cut(0, 1);			inSection = PR_TRUE;		}		PRInt32	len = line.Length();		if (len > 0)		{			if (line[len-1] == PRUnichar('>'))			{				inSection = PR_FALSE;				line.SetLength(len-1);			}		}		if (inSection == PR_TRUE)	continue;		// look for inputs		if (line.Find("input", PR_TRUE) == 0)		{      line.Cut(0, 5);      // look for "inputnext" or "inputprev"      inDirInput = PR_FALSE;      if (line.Find("next", PR_TRUE) == 0)      {        inDirInput = PR_TRUE;        if (whichButtons)          *whichButtons |= kHaveNext;      }      if (line.Find("prev", PR_TRUE) == 0)      {        inDirInput = PR_TRUE;        if (whichButtons)          *whichButtons |= kHavePrev;      }      if (inDirInput)        line.Cut(0, 4);      			line.Trim(" \t");						// first look for name attribute			nsAutoString	nameAttrib;			PRInt32	nameOffset = line.Find("name", PR_TRUE);			if (nameOffset >= 0)			{				PRInt32 equal = line.FindChar(PRUnichar('='), nameOffset);				if (equal >= 0)				{					PRInt32	startQuote = line.FindChar(PRUnichar('\"'), equal + 1);					if (startQuote >= 0)					{						PRInt32	endQuote = line.FindChar(PRUnichar('\"'), startQuote + 1);						if (endQuote > 0)						{							line.Mid(nameAttrib, startQuote+1, endQuote-startQuote-1);							line.Cut(0, endQuote + 1);						}					}					else					{						nameAttrib = line;						nameAttrib.Cut(0, equal+1);						nameAttrib.Trim(" \t");						PRInt32 space = nameAttrib.FindCharInSet(" \t", 0);						if (space > 0)						{							nameAttrib.Truncate(space);							line.Cut(0, equal+1+space);						}						else						{							line.Truncate();						}					}				}			}			if (nameAttrib.Length() <= 0)	continue;			// first look for value attribute			nsAutoString	valueAttrib;      PRInt32  valueOffset;      if (!inDirInput)        valueOffset = line.Find("value", PR_TRUE);      else        valueOffset = line.Find("factor", PR_TRUE);			if (valueOffset >= 0)			{				PRInt32 equal = line.FindChar(PRUnichar('='), valueOffset);				if (equal >= 0)				{					PRInt32	startQuote = line.FindChar(PRUnichar('\"'), equal + 1);					if (startQuote >= 0)					{						PRInt32	endQuote = line.FindChar(PRUnichar('\"'), startQuote + 1);						if (endQuote >= 0)						{							line.Mid(valueAttrib, startQuote+1, endQuote-startQuote-1);						}					}					else					{						// if value attribute's "value" isn't quoted, get the first word... ?						valueAttrib = line;						valueAttrib.Cut(0, equal+1);						valueAttrib.Trim(" \t");						PRInt32 space = valueAttrib.FindCharInSet(" \t>", 0);						if (space > 0)						{							valueAttrib.Truncate(space);						}					}				}			}			else if (line.Find("user", PR_TRUE) >= 0)			{				userVar = nameAttrib;				valueAttrib.Assign(text);			}						// XXX should ignore if  mode=browser  is specified			// XXX need to do this better			if (line.RFind("mode=browser", PR_TRUE) >= 0)				continue;			if ((nameAttrib.Length() > 0) && (valueAttrib.Length() > 0))			{				if (input.Length() > 0)				{					input.Append(NS_LITERAL_STRING("&"));				}				input += nameAttrib;        input.Append(NS_LITERAL_STRING("="));        if (!inDirInput)				input += valueAttrib;        else          input.AppendInt( computeIndex(valueAttrib, pageNumber, direction) );			}		}	}	return(rv);}