char cbuf[100]; PRInt32 index = 0; while (index < aResult.Length()) { if (aResult.CharAt(index++) == '&') { PRInt32 start = index - 1; PRUnichar e = aResult.CharAt(index); if (e == '#') {  index++; char* cp = cbuf; char* limit = cp + sizeof(cbuf) - 1; PRBool ok = PR_FALSE; PRInt32 slen = aResult.Length(); while ((index < slen) && (cp < limit)) { PRUnichar e = aResult.CharAt(index); if (e == ';') { index++; ok = PR_TRUE; break; } if ((e >= '0') && (e <= '9')) { *cp++ = char(e); index++; continue; } break; } if (!ok || (cp == cbuf)) { continue; } *cp = '\0'; if (cp - cbuf > 5) { continue; } PRInt32 ch = PRInt32( ::atoi(cbuf) ); if (ch > 65535) { continue; }    aResult.Cut(start, index - start); aResult.Insert(PRUnichar(ch), start); index = start + 1; } else if (((e >= 'A') && (e <= 'Z')) || ((e >= 'a') && (e <= 'z'))) {  index++; char* cp = cbuf; char* limit = cp + sizeof(cbuf) - 1; *cp++ = char(e); PRBool ok = PR_FALSE; PRInt32 slen = aResult.Length(); while ((index < slen) && (cp < limit)) { PRUnichar e = aResult.CharAt(index); if (e == ';') { index++; ok = PR_TRUE; break; } if (((e >= '0') && (e <= '9')) || ((e >= 'A') && (e <= 'Z')) || ((e >= 'a') && (e <= 'z'))) { *cp++ = char(e); index++; continue; } break; } if (!ok || (cp == cbuf)) { continue; } *cp = '\0'; PRInt32 ch = NS_EntityToUnicode(cbuf); if (ch < 0) { continue; }    aResult.Cut(start, index - start); aResult.Insert(PRUnichar(ch), start); index = start + 1; } else if (e == '{') {   } } }
GetAttributeValueAt(const nsIParserNode& aNode,                    PRInt32 aIndex,                    nsString& aResult){  // Copy value  const nsString& value = aNode.GetValueAt(aIndex);  aResult.Truncate();  aResult.Append(value);  // strip quotes if present  PRUnichar first = aResult.First();  if ((first == '"') || (first == '\'')) {    if (aResult.Last() == first) {      aResult.Cut(0, 1);      PRInt32 pos = aResult.Length() - 1;      if (pos >= 0) {        aResult.Cut(pos, 1);      }    } else {      // Mismatched quotes - leave them in    }  }}