Blindly try to fix mac bustage from the nsILineInputStream conversion to use CStrings.

This commit is contained in:
bsmedberg%covad.net 2004-06-17 23:34:29 +00:00
Родитель 3f739f181e
Коммит d5baacacf8
1 изменённых файлов: 7 добавлений и 12 удалений

Просмотреть файл

@ -548,7 +548,7 @@ nsDogbertProfileMigrator::FixDogbertCookies()
if (!fileOutputStream) return NS_ERROR_OUT_OF_MEMORY; if (!fileOutputStream) return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsILineInputStream> lineInputStream(do_QueryInterface(fileInputStream)); nsCOMPtr<nsILineInputStream> lineInputStream(do_QueryInterface(fileInputStream));
nsAutoString buffer, outBuffer; nsCAutoString buffer, outBuffer;
PRBool moreData = PR_FALSE; PRBool moreData = PR_FALSE;
PRUint32 written = 0; PRUint32 written = 0;
do { do {
@ -562,7 +562,6 @@ nsDogbertProfileMigrator::FixDogbertCookies()
if (buffer.IsEmpty() || buffer.CharAt(0) == '#' || if (buffer.IsEmpty() || buffer.CharAt(0) == '#' ||
buffer.CharAt(0) == nsCRT::CR || buffer.CharAt(0) == nsCRT::LF) { buffer.CharAt(0) == nsCRT::CR || buffer.CharAt(0) == nsCRT::LF) {
fileOutputStream->Write((const char*)buffer.get(), buffer.Length(), &written); fileOutputStream->Write((const char*)buffer.get(), buffer.Length(), &written);
// XXX this is wrong! you need buffer.Length() * sizeof(PRUnichar)
continue; continue;
} }
@ -578,15 +577,13 @@ nsDogbertProfileMigrator::FixDogbertCookies()
continue; continue;
// separate the expires field from the rest of the cookie line // separate the expires field from the rest of the cookie line
nsAutoString prefix, expiresString, suffix; nsCAutoString prefix, expiresString, suffix;
buffer.Mid(prefix, hostIndex, expiresIndex-hostIndex-1); buffer.Mid(prefix, hostIndex, expiresIndex-hostIndex-1);
buffer.Mid(expiresString, expiresIndex, nameIndex-expiresIndex-1); buffer.Mid(expiresString, expiresIndex, nameIndex-expiresIndex-1);
buffer.Mid(suffix, nameIndex, buffer.Length()-nameIndex); buffer.Mid(suffix, nameIndex, buffer.Length()-nameIndex);
// correct the expires field // correct the expires field
char* expiresCString = ToNewCString(expiresString); unsigned long expires = strtoul(expiresString.get(), nsnull, 10);
unsigned long expires = strtoul(expiresCString, nsnull, 10);
nsCRT::free(expiresCString);
// if the cookie is supposed to expire at the end of the session // if the cookie is supposed to expire at the end of the session
// expires == 0. don't adjust those cookies. // expires == 0. don't adjust those cookies.
@ -597,14 +594,12 @@ nsDogbertProfileMigrator::FixDogbertCookies()
// generate the output buffer and write it to file // generate the output buffer and write it to file
outBuffer = prefix; outBuffer = prefix;
outBuffer.Append(PRUnichar('\t')); outBuffer.Append('\t');
outBuffer.AppendWithConversion(dateString); outBuffer.Append(dateString);
outBuffer.Append(PRUnichar('\t')); outBuffer.Append('\t');
outBuffer.Append(suffix); outBuffer.Append(suffix);
nsCAutoString convertedBuffer; fileOutputStream->Write(outBuffer.get(), outBuffer.Length(), &written);
convertedBuffer.Assign(NS_ConvertUCS2toUTF8(outBuffer));
fileOutputStream->Write(convertedBuffer.get(), convertedBuffer.Length(), &written);
} }
while (1); while (1);