done=cp<endcp;
done=(cp==endcp);
static PRInt32 GetNumericSubstring(nsCString& aString,PRUint32& aRadix) {  const char* cp=aString.GetBuffer();  PRInt32 result=NS_ERROR_ILLEGAL_VALUE;  if(cp) {        //begin by skipping over leading chars that shouldn't be part of the number...        char* to=(char*)cp;    const char* endcp=cp+aString.mLength;    PRBool  done=PR_FALSE;    while(!done){      switch(*cp) {        case '0': case '1': case '2': case '3': case '4':         case '5': case '6': case '7': case '8': case '9':        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':        case '-': case '+': case '#':           done=PR_TRUE;          break;        default:          cp++;          done=cp<endcp;          break;      } //switch    }    while(cp<endcp) {      char theChar=*cp;            if('A'<=theChar) {        if('F'>=theChar) {          aRadix=16;          *to++=theChar;        }        else if('X'==theChar) {          if('-'==aString.mStr[0])            to=&aString.mStr[1];          else to=aString.mStr;          aRadix=16;        }        else if('a'<=theChar) {          if('f'>=theChar) {            aRadix=16;            *to++='A'+(theChar-'a');          }          else if('x'==theChar) {            if('-'==aString.mStr[0])              to=&aString.mStr[1];            else to=aString.mStr;            aRadix=16;          }        }        else break; //bad char      }      else if((theChar>='0') && (theChar<='9')) {        *to++=theChar;      }      else if('-'==theChar) {        *to++=theChar;      }      else if(('#'!=theChar) && ('+'!=theChar)){        break; //terminate on invalid char!      }      cp++;    }    aString.Truncate(to-aString.mStr);    result=(0==aString.mLength) ? NS_ERROR_ILLEGAL_VALUE : NS_OK;  }  return result;}