void nsEudoraAddress::SplitString(nsCString& val1, nsCString& val2)
{
  nsCString  temp;

  // Find the last line if there is more than one!
  int32_t idx = val1.RFind("\x0D\x0A");
  int32_t  cnt = 2;
  if (idx == -1) {
    cnt = 1;
    idx = val1.RFindChar(13);
  }
  if (idx == -1)
    idx= val1.RFindChar(10);
  if (idx != -1) {
    val2 = Substring(val1, idx + cnt);
    val1.SetLength(idx);
    SanitizeValue(val1);
  }
}
void nsEudoraAddress::SplitString( nsCString& val1, nsCString& val2)
{
  nsCString  temp;

  // Find the last line if there is more than one!
  PRInt32 idx = val1.RFind( "\x0D\x0A");
  PRInt32  cnt = 2;
  if (idx == -1) {
    cnt = 1;
    idx = val1.RFindChar( 13);
  }
  if (idx == -1)
    idx= val1.RFindChar( 10);
  if (idx != -1) {
    val1.Right( val2, val1.Length() - idx - cnt);
    val1.Left( temp, idx);
    val1 = temp;
    SanitizeValue( val1);
  }
}
static void
GetBasename(const nsCString& aPath, nsACString& aOut)
{
  nsCString out;
  int32_t idx = aPath.RFind("/");
  if (idx == -1) {
    out.Assign(aPath);
  } else {
    out.Assign(Substring(aPath, idx + 1));
  }

  // On Android, some entries in /dev/ashmem end with "(deleted)" (e.g.
  // "/dev/ashmem/libxul.so(deleted)").  We don't care about this modifier, so
  // cut it off when getting the entry's basename.
  if (EndsWithLiteral(out, "(deleted)")) {
    out.Assign(Substring(out, 0, out.RFind("(deleted)")));
  }
  out.StripChars(" ");

  aOut.Assign(out);
}
static nsCString
MakeNiceFileName(const nsCString & aFileName)
{
  nsCString niceName = aFileName;
  int32_t niceNameLength = aFileName.RFind(".");
  NS_ASSERTION(niceNameLength != kNotFound, "aFileName doesn't have a '.'?");
  while (niceNameLength > 0) {
    char chr = aFileName[niceNameLength - 1];
    if (!std::isalpha(chr))
      niceNameLength--;
    else
      break;
  }

  // If it turns out that niceNameLength <= 0, we'll fall back and use the
  // entire aFileName (which we've already taken care of, a few lines back).
  if (niceNameLength > 0) {
    niceName.Truncate(niceNameLength);
  }

  ToLowerCase(niceName);
  return niceName;
}
/* parses NewsMessageURI */
nsresult
nsParseNewsMessageURI(const char* uri, nsCString& group, nsMsgKey *key)
{
  NS_ENSURE_ARG_POINTER(uri);
  NS_ENSURE_ARG_POINTER(key);

  nsAutoCString uriStr(uri);
  int32_t keySeparator = uriStr.FindChar('#');
  if(keySeparator != -1)
  {
    int32_t keyEndSeparator = MsgFindCharInSet(uriStr, "?&", keySeparator);

    // Grab between the last '/' and the '#' for the key
    group = StringHead(uriStr, keySeparator);
    int32_t groupSeparator = group.RFind("/");
    if (groupSeparator == -1)
      return NS_ERROR_FAILURE;

    // Our string APIs don't let us unescape into the same buffer from earlier,
    // so escape into a temporary
    nsAutoCString unescapedGroup;
    MsgUnescapeString(Substring(group, groupSeparator + 1), 0, unescapedGroup);
    group = unescapedGroup;

    nsAutoCString keyStr;
    if (keyEndSeparator != -1)
      keyStr = Substring(uriStr, keySeparator + 1, keyEndSeparator - (keySeparator + 1));
    else
      keyStr = Substring(uriStr, keySeparator + 1);
    nsresult errorCode;
    *key = keyStr.ToInteger(&errorCode);

    return errorCode;
  }
  return NS_ERROR_FAILURE;
}