Bug #379070 --> remove nsCRT methods from mailnews\news.

Patch by Frank Wein <bugzilla@mcsmurf.de>

sr=neil
This commit is contained in:
scott%scott-macgregor.org 2007-06-14 03:14:51 +00:00
Родитель db899a8bbd
Коммит 0dcbc6fdb8
7 изменённых файлов: 25 добавлений и 59 удалений

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

@ -44,7 +44,6 @@
#include "pratom.h" #include "pratom.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsCRT.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsNewsFolder.h" #include "nsNewsFolder.h"

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

@ -72,7 +72,6 @@
#include "prmem.h" #include "prmem.h"
#include "prprf.h" #include "prprf.h"
#include "nsCRT.h"
#include "nsMsgUtils.h" #include "nsMsgUtils.h"
#include "nsMsgDatabase.h" #include "nsMsgDatabase.h"

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

@ -66,8 +66,6 @@
#include "nsINntpUrl.h" #include "nsINntpUrl.h"
#include "nsCRT.h"
#include "prtime.h" #include "prtime.h"
#include "prlog.h" #include "prlog.h"
#include "prerror.h" #include "prerror.h"
@ -1359,9 +1357,9 @@ nsNNTPProtocol::ParseURL(nsIURI * aURL, char ** aGroup, char ** aMessageID,
PR_LOG(NNTP,PR_LOG_ALWAYS,("(%p) fullPath = %s",this, fullPath.get())); PR_LOG(NNTP,PR_LOG_ALWAYS,("(%p) fullPath = %s",this, fullPath.get()));
if (fullPath.First() == '/') if (fullPath.First() == '/')
group = nsCRT::strdup(fullPath.get()+1); group = NS_strdup(fullPath.get()+1);
else else
group = nsCRT::strdup(fullPath.get()); group = ToNewCString(fullPath);
// more to do here, but for now, this works. // more to do here, but for now, this works.
// only escape if we are doing a search // only escape if we are doing a search
@ -1373,7 +1371,7 @@ nsNNTPProtocol::ParseURL(nsIURI * aURL, char ** aGroup, char ** aMessageID,
group = 0; group = 0;
} }
else if (!*group) { else if (!*group) {
nsCRT::free(group); NS_Free(group);
group = 0; group = 0;
} }
@ -1400,7 +1398,7 @@ nsNNTPProtocol::ParseURL(nsIURI * aURL, char ** aGroup, char ** aMessageID,
break; break;
if (*s) { if (*s) {
command_specific_data = nsCRT::strdup (s); command_specific_data = NS_strdup(s);
*s = 0; *s = 0;
if (!command_specific_data) { if (!command_specific_data) {
status = MK_OUT_OF_MEMORY; status = MK_OUT_OF_MEMORY;
@ -1848,7 +1846,7 @@ PRInt32 nsNNTPProtocol::GetPropertiesResponse(nsIInputStream * inputStream, PRUi
if ('.' != line[0]) if ('.' != line[0])
{ {
char *propertyName = nsCRT::strdup(line); char *propertyName = NS_strdup(line);
if (propertyName) if (propertyName)
{ {
char *space = PL_strchr(propertyName, ' '); char *space = PL_strchr(propertyName, ' ');
@ -2565,7 +2563,7 @@ PRInt32 nsNNTPProtocol::ReadArticle(nsIInputStream * inputStream, PRUint32 lengt
/* Don't send content-type to mime parser if we're doing a cancel /* Don't send content-type to mime parser if we're doing a cancel
because it confuses mime parser into not parsing. because it confuses mime parser into not parsing.
*/ */
if (m_typeWanted != CANCEL_WANTED || nsCRT::strncmp(outputBuffer, "Content-Type:", 13)) if (m_typeWanted != CANCEL_WANTED || strncmp(outputBuffer, "Content-Type:", 13))
{ {
// if we are attempting to cancel, we want to snarf the headers and save the aside, which is what // if we are attempting to cancel, we want to snarf the headers and save the aside, which is what
// ParseHeaderForCancel() does. // ParseHeaderForCancel() does.
@ -3138,13 +3136,11 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng
char rate_buf[RATE_STR_BUF_LEN]; char rate_buf[RATE_STR_BUF_LEN];
PR_snprintf(rate_buf,RATE_STR_BUF_LEN,"%.1f", rate); PR_snprintf(rate_buf,RATE_STR_BUF_LEN,"%.1f", rate);
nsAutoString rateStr;
rateStr.Append(NS_ConvertASCIItoUTF16(rate_buf));
nsAutoString numGroupsStr; nsAutoString numGroupsStr;
numGroupsStr.AppendInt(mNumGroupsListed); numGroupsStr.AppendInt(mNumGroupsListed);
NS_ConvertASCIItoUTF16 rateStr(rate_buf);
const PRUnichar *formatStrings[3] = { numGroupsStr.get(), bytesStr.get(), rateStr.get() }; const PRUnichar *formatStrings[3] = { numGroupsStr.get(), bytesStr.get(), rateStr.get()};
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("bytesReceived").get(), rv = bundle->FormatStringFromName(NS_LITERAL_STRING("bytesReceived").get(),
formatStrings, 3, formatStrings, 3,
getter_Copies(statusString)); getter_Copies(statusString));

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

@ -37,7 +37,6 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsNewsDownloadDialogArgs.h" #include "nsNewsDownloadDialogArgs.h"
#include "nsCRT.h"
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
nsNewsDownloadDialogArgs::nsNewsDownloadDialogArgs() nsNewsDownloadDialogArgs::nsNewsDownloadDialogArgs()

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

@ -1252,7 +1252,7 @@ nsNntpIncomingServer::HandleLine(const char* line, PRUint32 line_size)
} }
} }
else { else {
if (nsCRT::strncmp(line,"begingroups", 11) == 0) { if (strncmp(line,"begingroups", 11) == 0) {
mHasSeenBeginGroups = PR_TRUE; mHasSeenBeginGroups = PR_TRUE;
} }
char*equalPos = (char *) PL_strchr(line, '='); char*equalPos = (char *) PL_strchr(line, '=');

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

@ -57,7 +57,6 @@
#include "nsMsgBaseCID.h" #include "nsMsgBaseCID.h"
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
#include "nsIPrefService.h" #include "nsIPrefService.h"
#include "nsCRT.h" // for nsCRT::strtok
#include "nsNntpService.h" #include "nsNntpService.h"
#include "nsIChannel.h" #include "nsIChannel.h"
#include "nsILoadGroup.h" #include "nsILoadGroup.h"
@ -225,7 +224,7 @@ nsNntpService::CreateMessageIDURL(nsIMsgFolder *folder, nsMsgKey key, char **url
uri = rootFolderURI.get(); uri = rootFolderURI.get();
uri += '/'; uri += '/';
uri += escapedMessageID; uri += escapedMessageID;
*url = nsCRT::strdup(uri.get()); *url = ToNewCString(uri);
PR_FREEIF(escapedMessageID); PR_FREEIF(escapedMessageID);
@ -509,7 +508,7 @@ nsNntpService::DecomposeNewsURI(const char *uri, nsIMsgFolder **folder, nsMsgKey
{ {
nsresult rv; nsresult rv;
// if we fix DecomposeNewsMessage to handle news message scheme, we could use it exclusively // if we fix DecomposeNewsMessage to handle news message scheme, we could use it exclusively
if (nsCRT::strncmp(uri, kNewsMessageRootURI, kNewsMessageRootURILen) == 0) if (strncmp(uri, kNewsMessageRootURI, kNewsMessageRootURILen) == 0)
{ {
rv = DecomposeNewsMessageURI(uri, folder, aMsgKey); rv = DecomposeNewsMessageURI(uri, folder, aMsgKey);
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
@ -796,42 +795,33 @@ nsNntpService::GenerateNewsHeaderValsForPosting(const char *newsgroupsList, char
// we are not going to allow the user to cross post to multiple hosts. // we are not going to allow the user to cross post to multiple hosts.
// if we detect that, we stop and return error. // if we detect that, we stop and return error.
// nsCRT::strtok is going destroy what we pass to it, so we need to make a copy of newsgroupsNames.
char *list = nsCRT::strdup(newsgroupsList);
char *token = nsnull;
char *rest = list;
nsCAutoString host; nsCAutoString host;
nsCAutoString str; nsCAutoString str;
nsCAutoString newsgroups; nsCAutoString newsgroups;
token = nsCRT::strtok(rest, ",", &rest); nsCStringArray list;
while (token && *token) list.ParseString(newsgroupsList, ",");
for (PRInt32 index = 0; index < list.Count(); index++)
{ {
str = token; list[index]->StripWhitespace();
str.StripWhitespace(); if (!list[index]->IsEmpty())
if (!str.IsEmpty())
{ {
nsCAutoString currentHost; nsCAutoString currentHost;
nsCAutoString theRest; nsCAutoString theRest;
// does str start with "news:/"? // does str start with "news:/"?
if (str.Find(kNewsRootURI) == 0) if (StringBeginsWith(*list[index], NS_LITERAL_CSTRING(kNewsRootURI)))
{ {
// we have news://group or news://host/group // we have news://group or news://host/group
// set theRest to what's after news:// // set theRest to what's after news://
str.Right(theRest, str.Length() - kNewsRootURILen /* for news:/ */ - 1 /* for the slash */); list[index]->Right(theRest, list[index]->Length() - kNewsRootURILen /* for news:/ */ - 1 /* for the slash */);
} }
else if (str.Find(":/") != -1) else if (list[index]->Find(":/") != -1)
{ {
// we have x:/y where x != news. this is bad, return failure // we have x:/y where x != news. this is bad, return failure
CRTFREEIF(list);
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
else else
{ theRest = *list[index];
theRest = str;
}
// theRest is "group" or "host/group" // theRest is "group" or "host/group"
PRInt32 slashpos = theRest.FindChar('/'); PRInt32 slashpos = theRest.FindChar('/');
@ -847,10 +837,7 @@ nsNntpService::GenerateNewsHeaderValsForPosting(const char *newsgroupsList, char
NS_ASSERTION(!currentGroup.IsEmpty(), "currentGroup is empty"); NS_ASSERTION(!currentGroup.IsEmpty(), "currentGroup is empty");
if (currentGroup.IsEmpty()) if (currentGroup.IsEmpty())
{
CRTFREEIF(list);
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
// build up the newsgroups // build up the newsgroups
if (!newsgroups.IsEmpty()) if (!newsgroups.IsEmpty())
@ -862,39 +849,26 @@ nsNntpService::GenerateNewsHeaderValsForPosting(const char *newsgroupsList, char
// str is "group" // str is "group"
rv = FindHostFromGroup(currentHost, str); rv = FindHostFromGroup(currentHost, str);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
{
CRTFREEIF(list);
return rv; return rv;
}
// build up the newsgroups // build up the newsgroups
if (!newsgroups.IsEmpty()) if (!newsgroups.IsEmpty())
newsgroups += ","; newsgroups += ",";
newsgroups += str; newsgroups += *list[index];
} }
if (!currentHost.IsEmpty()) if (!currentHost.IsEmpty())
{ {
if (host.IsEmpty()) if (host.IsEmpty())
{
host = currentHost; host = currentHost;
}
else else
{ {
if (!host.Equals(currentHost)) if (!host.Equals(currentHost))
{
CRTFREEIF(list);
return NS_ERROR_NNTP_NO_CROSS_POSTING; return NS_ERROR_NNTP_NO_CROSS_POSTING;
} }
} }
}
str = "";
currentHost = ""; currentHost = "";
} }
token = nsCRT::strtok(rest, ",", &rest);
} }
CRTFREEIF(list);
*newshostHeaderVal = ToNewCString(host); *newshostHeaderVal = ToNewCString(host);
if (!*newshostHeaderVal) return NS_ERROR_OUT_OF_MEMORY; if (!*newshostHeaderVal) return NS_ERROR_OUT_OF_MEMORY;
@ -1248,7 +1222,7 @@ NS_IMETHODIMP nsNntpService::GetNewNews(nsINntpIncomingServer *nntpServer, const
server = do_QueryInterface(nntpServer); server = do_QueryInterface(nntpServer);
/* double check that it is a "news:/" url */ /* double check that it is a "news:/" url */
if (nsCRT::strncmp(uri, kNewsRootURI, kNewsRootURILen) == 0) if (strncmp(uri, kNewsRootURI, kNewsRootURILen) == 0)
{ {
nsCOMPtr<nsIURI> aUrl; nsCOMPtr<nsIURI> aUrl;
rv = ConstructNntpUrl(uri, aUrlListener, aMsgWindow, nsnull, nsINntpUrl::ActionGetNewNews, getter_AddRefs(aUrl)); rv = ConstructNntpUrl(uri, aUrlListener, aMsgWindow, nsnull, nsINntpUrl::ActionGetNewNews, getter_AddRefs(aUrl));

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

@ -48,7 +48,6 @@
#include "prmem.h" #include "prmem.h"
#include "plstr.h" #include "plstr.h"
#include "prprf.h" #include "prprf.h"
#include "nsCRT.h"
#include "nsNewsUtils.h" #include "nsNewsUtils.h"
#include "nsISupportsObsolete.h" #include "nsISupportsObsolete.h"