PRUint32 currentInd = 0; while (currentInd < aNewSelected->Length()) { PRInt32 nextInd = aNewSelected->FindChar(',', currentInd); if (nextInd == -1) { nextInd = aNewSelected->Length();
for (PRInt32 i = 0; i < (PRInt32)len; i++) { nsCOMPtr<nsIDOMHTMLOptionElement> option; mOptions->ItemAsOption(i, getter_AddRefs(option)); if (option) { nsAutoString value; option->GetValue(value); if (aNewSelected->ContainsOption(i, value)) { SetOptionsSelectedByIndex(i, i, PR_TRUE, PR_FALSE, PR_TRUE, PR_TRUE, nsnull); }
nsHTMLSelectElement::RestoreStateTo(nsAString* aNewSelected){  if (!mIsDoneAddingChildren) {    mRestoreState = new nsString;    if (!mRestoreState) {      return NS_OK;    }    *mRestoreState = *aNewSelected;    return NS_OK;  }  PRUint32 len;  GetLength(&len);  // First clear all  SetOptionsSelectedByIndex(-1, -1, PR_TRUE, PR_TRUE, PR_TRUE, PR_TRUE, nsnull);  // Next set the proper ones  PRUint32 currentInd = 0;  while (currentInd < aNewSelected->Length()) {    PRInt32 nextInd = aNewSelected->FindChar(',', currentInd);    if (nextInd == -1) {      nextInd = aNewSelected->Length();    }    nsDependentSubstring s = Substring(*aNewSelected,                                       currentInd, (nextInd-currentInd));    PRInt32 i = atoi(NS_ConvertUCS2toUTF8(s).get());    SetOptionsSelectedByIndex(i, i, PR_TRUE, PR_FALSE, PR_TRUE, PR_TRUE, nsnull);    currentInd = (PRUint32)nextInd+1;  }  //CheckSelectSomething();  return NS_OK;}