nsAutoString theRightChars;
nsAutoString  theRightChars; PRInt32       theBestAltPos=kNotFound; PRUint32      theStartOffset=0;
nsresult ConsumeComment(PRUnichar aChar, nsScanner& aScanner,nsString& aString) {  static    nsAutoString gEdibles("!-");  static    nsAutoString gMinus("-");  static    nsAutoString gWhitespace("\b\t\n\r ");  nsresult  result=NS_OK;   /*********************************************************    NOTE: This algorithm does a fine job of handling comments          commonly used, but it doesn't really consume them          per spec (But then, neither does IE or Nav).   *********************************************************/  aString="<!";  nsAutoString theRightChars;  result=aScanner.GetChar(aChar);  if(NS_OK==result) {    aString+=aChar;    if(kMinus==aChar) {      result=aScanner.GetChar(aChar);      if(NS_OK==result) {        if(kMinus==aChar) {             //in this case, we're reading a long-form comment <-- xxx -->          aString+=aChar;          PRInt32 findpos=kNotFound;          result=aScanner.ReadWhile(aString,gMinus,PR_TRUE,PR_TRUE);  //get all available '---'          findpos=aString.RFind("-->");          while((kNotFound==findpos) && (NS_OK==result)) {            result=aScanner.ReadUntil(aString,kMinus,PR_TRUE);            if(NS_OK==result) {              result=aScanner.ReadWhile(aString,gMinus,PR_TRUE,PR_FALSE);  //get all available '---'              if(NS_OK==result)                result=aScanner.ReadWhile(aString,gWhitespace,PR_TRUE,PR_FALSE);  //get all available whitespace            }                        if(NS_OK==result) {              result=aScanner.GetChar(aChar);              aString+=aChar;            }                      if(NS_OK==result){              theRightChars.Truncate(0);              aString.Right(theRightChars,5);              theRightChars.StripChars(" ");                          findpos=theRightChars.RFind("-->");              if(kNotFound==findpos)                findpos=theRightChars.RFind("!>");            }          } //while          return result;        } //if      }//if    }//if  }//if  if(NS_OK==result) {     //Read up to the closing '>'    result=aScanner.ReadUntil(aString,kGreaterThan,PR_TRUE);  }  return result;}