PRUint32 numberOfMessages = 0; char *uidString = PL_strdup(idString);  if (uidString) {  char curChar = *uidString; PRBool isRange = PR_FALSE; PRInt32 curToken; PRInt32 saveStartToken=0;  for (char *curCharPtr = uidString; curChar && *curCharPtr;) { char *currentKeyToken = curCharPtr; curChar = *curCharPtr; while (curChar != ':' && curChar != ',' && curChar != '\0') curChar = *curCharPtr++; *(curCharPtr - 1) = '\0'; curToken = atol(currentKeyToken); if (isRange) { while (saveStartToken < curToken) { numberOfMessages++; saveStartToken++; } }  numberOfMessages++; isRange = (curChar == ':'); if (isRange) saveStartToken = curToken + 1; } PR_Free(uidString); } return numberOfMessages;
return CountMessagesInIdString((const char *) idString.GetBuffer());
PRUint32 nsImapProtocol::CountMessagesInIdString(const char *idString){  PRUint32 numberOfMessages = 0;  char *uidString = PL_strdup(idString);  if (uidString)  {    // This is in the form <id>,<id>, or <id1>:<id2>    char curChar = *uidString;    PRBool isRange = PR_FALSE;    PRInt32 curToken;    PRInt32 saveStartToken=0;    for (char *curCharPtr = uidString; curChar && *curCharPtr;)    {      char *currentKeyToken = curCharPtr;      curChar = *curCharPtr;      while (curChar != ':' && curChar != ',' && curChar != '\0')        curChar = *curCharPtr++;      *(curCharPtr - 1) = '\0';      curToken = atol(currentKeyToken);      if (isRange)      {        while (saveStartToken < curToken)        {          numberOfMessages++;          saveStartToken++;        }      }      numberOfMessages++;      isRange = (curChar == ':');      if (isRange)        saveStartToken = curToken + 1;    }    PR_Free(uidString);  }  return numberOfMessages;}