if (nsCRT::strlen(result) > 0)
if (result[0])
nsHTTPIndexParser::ParseData(nsString* values, const char *encodingStr,                             char* aDataStr, nsIRDFResource *parentRes){  // Parse a "201" data line, using the field ordering specified in  // mFormat.  PRInt32   numFormats = mFormat.Count();  if (numFormats == 0) {    // Ignore if we haven't seen a format yet.    return NS_OK;  }  nsresult rv = NS_OK;  nsCAutoString	filename;  PRBool    isDirType = PR_FALSE;  const char* baseStr = nsnull;  parentRes->GetValueConst(&baseStr);  if (! baseStr) {    NS_ERROR("Could not reconstruct base uri\n");    return NS_ERROR_UNEXPECTED;  }  for (PRInt32 i = 0; i < numFormats; ++i) {    // If we've exhausted the data before we run out of fields, just    // bail.    if (! *aDataStr)      break;    while (*aDataStr && nsCRT::IsAsciiSpace(*aDataStr))      ++aDataStr;    char    *value = aDataStr;    if (*aDataStr == '"' || *aDataStr == '\'') {      // it's a quoted string. snarf everything up to the next quote character      const char quotechar = *(aDataStr++);      ++value;      while (*aDataStr && *aDataStr != quotechar)      	++aDataStr;      *aDataStr++ = '\0';      if (! aDataStr) {        NS_WARNING("quoted value not terminated");      }    }    else {      // it's unquoted. snarf until we see whitespace.      value = aDataStr;      while (*aDataStr && (!nsCRT::IsAsciiSpace(*aDataStr)))        ++aDataStr;      *aDataStr++ = '\0';    }    Field* field = NS_STATIC_CAST(Field*, mFormat.ElementAt(i));    if (field && field->mProperty == kHTTPIndex_Filename)    {        // don't unescape at this point, so that UnEscapeAndConvert() can        filename = value;        PRBool  success = PR_FALSE;        nsAutoString entryuri;        if (gTextToSubURI)        {            PRUnichar	*result = nsnull;            if (NS_SUCCEEDED(rv = gTextToSubURI->UnEscapeAndConvert(encodingStr, filename,                                                                    &result)) && (result))            {                if (nsCRT::strlen(result) > 0)                {                    values[i].Assign(result);                    success = PR_TRUE;                }                Recycle(result);            }            else            {                NS_WARNING("UnEscapeAndConvert error");            }        }        if (success == PR_FALSE)        {            // if unsuccessfully at charset conversion, then            // just fallback to unescape'ing in-place            nsUnescape(value);            values[i].AssignWithConversion(value);        }    }    else    {        // unescape in-place        nsUnescape(value);        values[i].AssignWithConversion(value);        if (field && field->mProperty == kHTTPIndex_Filetype)        {            if (!nsCRT::strcasecmp(value, "directory"))            {                isDirType = PR_TRUE;            }        }    }  }  // we found the filename; construct a resource for its entry  nsCAutoString entryuriC(baseStr);    // gopher resource don't point to an entry in the same directory  // like ftp uris. So the entryuriC is just a unique string, while  // the URL attribute is the destination of this element  // The naming scheme for the attributes is taken from the bookmarks  entryuriC.Append(filename);    // if its a directory, make sure it ends with a trailing slash.  // This doesn't matter for gopher, (where directories don't have  // to end in a trailing /), because the filename is used for the URL  // attribute.  if (isDirType == PR_TRUE)    {      entryuriC.Append('/');    }    nsCOMPtr<nsIRDFResource> entry;  rv = gRDF->GetResource(entryuriC, getter_AddRefs(entry));  // At this point, we'll (hopefully) have found the filename and  // constructed a resource for it, stored in entry. So now take a  // second pass through the values and add as statements to the RDF  // datasource.  if (entry && NS_SUCCEEDED(rv)) {    nsCOMPtr<nsIRDFLiteral> URLVal;    nsString url;    // For gopher, the target is the filename. We still have to do all    // the above string manipulation though, because we need the entryuric    // as the key for the RDF data source    if (!strncmp(entryuriC, kGopherProtocol, sizeof(kGopherProtocol)-1))      url.AssignWithConversion(filename);    else      url.AssignWithConversion(entryuriC);    rv = gRDF->GetLiteral(url.GetUnicode(), getter_AddRefs(URLVal));    if (NS_SUCCEEDED(rv)) {      mDataSource->Assert(entry, kHTTPIndex_URL, URLVal, PR_TRUE);      for (PRInt32 indx = 0; indx < numFormats; ++indx) {        Field* field = NS_STATIC_CAST(Field*, mFormat.ElementAt(indx));        if (! field)          continue;                if (mHasDescription && field->mProperty == kHTTPIndex_Filename)          continue;                nsCOMPtr<nsIRDFNode> nodeValue;        rv = (*field->mParse)(field->mProperty, values[indx], getter_AddRefs(nodeValue));        if (NS_FAILED(rv)) break;        if (nodeValue) {          // If there is a description entry, prefer that over the filename          if (mHasDescription && field->mProperty == kHTTPIndex_Description) {            rv = mDataSource->Assert(entry, kHTTPIndex_Filename, nodeValue, PR_TRUE);            if (NS_FAILED(rv)) break;          }          rv = mDataSource->Assert(entry, field->mProperty, nodeValue, PR_TRUE);          if (NS_FAILED(rv)) break;        }      }    }    // Since the definition of a directory depends on the protocol, we would have    // to do string comparisons all the time.    // But we're told if we're a container right here - so save that fact    if (isDirType)      mDataSource->Assert(entry, kHTTPIndex_IsContainer, kTrueLiteral, PR_TRUE);    else      mDataSource->Assert(entry, kHTTPIndex_IsContainer, kFalseLiteral, PR_TRUE);    //   instead of//       rv = mDataSource->Assert(parentRes, kNC_Child, entry, PR_TRUE);//       if (NS_FAILED(rv)) return rv;//   defer insertion onto a timer so that the UI isn't starved    mHTTPIndex->AddElement(parentRes, kNC_Child, entry);  }  return rv;}