if (col != -1) {
if (col) {
nsGlobalHistory::GetSources(nsIRDFResource* aProperty,                            nsIRDFNode* aTarget,                            PRBool aTruthValue,                            nsISimpleEnumerator** aSources){  // XXX TODO: make sure each URL in history is connected back to  // NC:HistoryRoot.  NS_PRECONDITION(aProperty != nsnull, "null ptr");  if (! aProperty)    return NS_ERROR_NULL_POINTER;  NS_PRECONDITION(aTarget != nsnull, "null ptr");  if (! aTarget)    return NS_ERROR_NULL_POINTER;  nsresult rv;  if (aProperty == kNC_URL) {    // Call GetSource() and return a singleton enumerator for the URL.    nsCOMPtr<nsIRDFResource> source;    rv = GetSource(aProperty, aTarget, aTruthValue, getter_AddRefs(source));    if (NS_FAILED(rv)) return rv;    return NS_NewSingletonEnumerator(aSources, source);  }  else {    // See if aProperty is something we understand, and create an    // URLEnumerator to select URLs with the appropriate value.    mdb_column col = -1; // == "not a property that I grok"    void* value = nsnull;    PRInt32 len = 0;    if (aProperty == kNC_Date) {      nsCOMPtr<nsIRDFDate> date = do_QueryInterface(aTarget);      if (date) {        PRInt64 n;        rv = date->GetValue(&n);        if (NS_FAILED(rv)) return rv;        char buf[64];        rv = PRInt64ToChars(n, buf, sizeof(buf));        if (NS_FAILED(rv)) return rv;        len = PL_strlen(buf);        value = nsAllocator::Alloc(len + 1);        if (! value)          return NS_ERROR_OUT_OF_MEMORY;        PL_strcpy(buf, NS_STATIC_CAST(char*, value));        col = kToken_LastVisitDateColumn;      }    }    else if (aProperty == kNC_VisitCount) {      NS_NOTYETIMPLEMENTED("sorry");    }    else if (aProperty == kNC_Name) {      nsCOMPtr<nsIRDFLiteral> name = do_QueryInterface(aTarget);      if (name) {        PRUnichar* p;        rv = name->GetValue(&p);        if (NS_FAILED(rv)) return rv;        len = nsCRT::strlen(p) * sizeof(PRUnichar);        value = p;        col = kToken_NameColumn;      }    }    else if (aProperty == kNC_Referrer) {      col = kToken_ReferrerColumn;      nsCOMPtr<nsIRDFResource> referrer = do_QueryInterface(aTarget);      if (referrer) {        char* p;        rv = referrer->GetValue(&p);        if (NS_FAILED(rv)) return rv;        len = PL_strlen(p);        value = p;        col = kToken_ReferrerColumn;      }    }    if (col != -1) {      // The URLEnumerator takes ownership of the bytes allocated in |value|.      URLEnumerator* result = new URLEnumerator(kToken_URLColumn, col, value, len);      if (! result)        return NS_ERROR_OUT_OF_MEMORY;      rv = result->Init(mEnv, mTable);      if (NS_FAILED(rv)) return rv;      *aSources = result;      NS_ADDREF(*aSources);      return NS_OK;    }  }  return NS_NewEmptyEnumerator(aSources);}