Bug 702475 - delimiter, the third argument of nsTextAddress::ReadRecord and ReadRecordNumber, is not used at all. r=bienvenu
--- a/mailnews/import/text/src/nsTextAddress.cpp
+++ b/mailnews/import/text/src/nsTextAddress.cpp
@@ -108,21 +108,21 @@ nsresult nsTextAddress::ImportAddresses(
nsCOMPtr<nsILineInputStream> lineStream(do_QueryInterface(inputStream, &rv));
NS_ENSURE_SUCCESS(rv, rv);
bool more = true;
nsCString line;
// Skip the first record if the user has requested it.
if (skipRecord)
- rv = ReadRecord(lineStream, line, m_delim, &more);
+ rv = ReadRecord(lineStream, line, &more);
while (!(*pAbort) && more && NS_SUCCEEDED( rv)) {
// Read the line in
- rv = ReadRecord(lineStream, line, m_delim, &more);
+ rv = ReadRecord(lineStream, line, &more);
if (NS_SUCCEEDED(rv)) {
// Now proces it to add it to the database
rv = ProcessLine(line.get(), line.Length(), errors);
if (NS_FAILED(rv)) {
IMPORT_LOG0( "*** Error processing text record.\n");
}
}
@@ -140,17 +140,17 @@ nsresult nsTextAddress::ImportAddresses(
if (NS_FAILED(rv)) {
IMPORT_LOG0( "*** Error reading the address book - probably incorrect ending\n");
return NS_ERROR_FAILURE;
}
return pDb->Commit(nsAddrDBCommitType::kLargeCommit);
}
-nsresult nsTextAddress::ReadRecord(nsILineInputStream *aLineStream, nsCString &aLine, char delim, bool *aMore)
+nsresult nsTextAddress::ReadRecord(nsILineInputStream *aLineStream, nsCString &aLine, bool *aMore)
{
bool more = true;
PRUint32 numQuotes = 0;
nsresult rv;
nsCString line;
// ensure aLine is empty
aLine.Truncate();
@@ -182,17 +182,17 @@ nsresult nsTextAddress::ReadRecord(nsILi
}
// Continue whilst everything is ok, and we have an odd number of quotes.
} while (NS_SUCCEEDED(rv) && (numQuotes % 2 != 0));
*aMore = more;
return rv;
}
-nsresult nsTextAddress::ReadRecordNumber(nsIFile *aSrc, nsCString &aLine, char delim, PRInt32 rNum)
+nsresult nsTextAddress::ReadRecordNumber(nsIFile *aSrc, nsCString &aLine, PRInt32 rNum)
{
nsCOMPtr<nsIInputStream> inputStream;
nsresult rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), aSrc);
if (NS_FAILED(rv)) {
IMPORT_LOG0( "*** Error opening address file for reading\n");
return rv;
}
@@ -207,17 +207,17 @@ nsresult nsTextAddress::ReadRecordNumber
}
nsCOMPtr<nsILineInputStream> lineStream(do_QueryInterface(inputStream, &rv));
NS_ENSURE_SUCCESS(rv, rv);
bool more = true;
while (more && (rIndex <= rNum)) {
- rv = ReadRecord(lineStream, aLine, delim, &more);
+ rv = ReadRecord(lineStream, aLine, &more);
if (NS_FAILED(rv)) {
inputStream->Close();
return rv;
}
if (rIndex == rNum) {
inputStream->Close();
return NS_OK;
}
--- a/mailnews/import/text/src/nsTextAddress.h
+++ b/mailnews/import/text/src/nsTextAddress.h
@@ -59,24 +59,24 @@ public:
nsTextAddress();
virtual ~nsTextAddress();
nsresult ImportAddresses(bool *pAbort, const PRUnichar *pName, nsIFile *pSrc, nsIAddrDatabase *pDb, nsIImportFieldMap *fieldMap, nsString& errors, PRUint32 *pProgress);
nsresult DetermineDelim(nsIFile *pSrc);
char GetDelim( void) { return( m_delim);}
- static nsresult ReadRecordNumber(nsIFile *pSrc, nsCString &aLine, char delim, PRInt32 rNum);
+ static nsresult ReadRecordNumber(nsIFile *pSrc, nsCString &aLine, PRInt32 rNum);
static bool GetField(const char *pLine, PRInt32 maxLen, PRInt32 index, nsCString& field, char delim);
private:
nsresult ProcessLine(const char *pLine, PRInt32 len, nsString& errors);
static PRInt32 CountFields(const char *pLine, PRInt32 maxLen, char delim);
- static nsresult ReadRecord(nsILineInputStream *pSrc, nsCString &aLine, char delim, bool *aMore);
+ static nsresult ReadRecord(nsILineInputStream *pSrc, nsCString &aLine, bool *aMore);
char m_delim;
PRInt32 m_LFCount;
PRInt32 m_CRCount;
nsIAddrDatabase *m_database;
nsIImportFieldMap *m_fieldMap;
nsCOMPtr<nsIImportService> m_pService;
};
--- a/mailnews/import/text/src/nsTextImport.cpp
+++ b/mailnews/import/text/src/nsTextImport.cpp
@@ -600,17 +600,17 @@ NS_IMETHODIMP ImportAddressImpl::GetSamp
if (!fileExists) {
*pFound = PR_FALSE;
*pStr = NS_strdup(&term);
return NS_OK;
}
nsCString line;
- rv = nsTextAddress::ReadRecordNumber(m_fileLoc, line, m_delim, index);
+ rv = nsTextAddress::ReadRecordNumber(m_fileLoc, line, index);
if (NS_SUCCEEDED( rv)) {
nsString str;
nsCString field;
nsString uField;
PRInt32 fNum = 0;
while (nsTextAddress::GetField(line.get(), line.Length(), fNum, field, m_delim)) {
if (fNum)
str.Append(PRUnichar('\n'));