fix Bugzilla Bug 75853 CR and LF are naked ifdefs

r=dveditz, sr=scc
This commit is contained in:
timeless%mac.com 2001-04-18 05:59:43 +00:00
Родитель 50b40776d8
Коммит 46b177e406
55 изменённых файлов: 239 добавлений и 239 удалений

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

@ -723,7 +723,7 @@ cookie_SetCookieString(char * curURL, nsIPrompt *aPrompter, const char * setCook
/* terminate at any carriage return or linefeed */
for(ptr=setCookieHeaderInternal; *ptr; ptr++) {
if(*ptr == LF || *ptr == CR) {
if(*ptr == nsCRT::LF || *ptr == nsCRT::CR) {
*ptr = '\0';
break;
}
@ -1248,8 +1248,8 @@ COOKIE_Read() {
if ( !buffer.IsEmpty() ) {
PRUnichar firstChar = buffer.CharAt(0);
if (firstChar == '#' || firstChar == CR ||
firstChar == LF || firstChar == 0) {
if (firstChar == '#' || firstChar == nsCRT::CR ||
firstChar == nsCRT::LF || firstChar == 0) {
continue;
}
}

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

@ -463,8 +463,8 @@ PERMISSION_Read() {
while(CKutil_GetLine(strm,buffer) != -1) {
if ( !buffer.IsEmpty() ) {
PRUnichar firstChar = buffer.CharAt(0);
if (firstChar == '#' || firstChar == CR ||
firstChar == LF || firstChar == 0) {
if (firstChar == '#' || firstChar == nsCRT::CR ||
firstChar == nsCRT::LF || firstChar == 0) {
continue;
}
}

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

@ -1021,8 +1021,8 @@ nsXMLHttpRequest::GetStreamForWString(const PRUnichar* aStr,
nsCRT::memcpy(postData+headerSize, postData+MAX_HEADER_SIZE, charLength);
// Shove in the traling CRLF
postData[headerSize+charLength] = CR;
postData[headerSize+charLength+1] = LF;
postData[headerSize+charLength] = nsCRT::CR;
postData[headerSize+charLength+1] = nsCRT::LF;
postData[headerSize+charLength+2] = '\0';
// The new stream takes ownership of the buffer

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

@ -588,7 +588,7 @@ void Tokenizer_HandleCharacterData(void *userData, const XML_Char *s, int len) {
switch(((PRUnichar*)s)[0]){
case kNewLine:
case CR:
case nsCRT::CR:
newToken = state->tokenAllocator->CreateTokenOfType(eToken_newline,eHTMLTag_unknown);
break;
case kSpace:

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

@ -2042,7 +2042,7 @@ nsAbSync::ExtractCurrentLine()
nsString extractString;
while ( (*mProtocolOffset) &&
( (*mProtocolOffset != CR) && (*mProtocolOffset != LF) )
( (*mProtocolOffset != nsCRT::CR) && (*mProtocolOffset != nsCRT::LF) )
)
{
extractString.Append(PRUnichar(*mProtocolOffset));
@ -2054,10 +2054,10 @@ nsAbSync::ExtractCurrentLine()
else
{
while ( (*mProtocolOffset) &&
(*mProtocolOffset == CR) )
(*mProtocolOffset == nsCRT::CR) )
mProtocolOffset++;
if (*mProtocolOffset == LF)
if (*mProtocolOffset == nsCRT::LF)
mProtocolOffset++;
char *tString = extractString.ToNewCString();
@ -2074,9 +2074,9 @@ nsAbSync::ExtractCurrentLine()
nsresult
nsAbSync::AdvanceToNextLine()
{
// First, find first CR or LF...
// First, find first nsCRT::CR or nsCRT::LF...
while ( (*mProtocolOffset) &&
( (*mProtocolOffset != CR) && (*mProtocolOffset != LF) )
( (*mProtocolOffset != nsCRT::CR) && (*mProtocolOffset != nsCRT::LF) )
)
{
mProtocolOffset++;
@ -2086,10 +2086,10 @@ nsAbSync::AdvanceToNextLine()
if (*mProtocolOffset)
{
while ( (*mProtocolOffset) &&
(*mProtocolOffset != LF) )
(*mProtocolOffset != nsCRT::LF) )
mProtocolOffset++;
if (*mProtocolOffset == LF)
if (*mProtocolOffset == nsCRT::LF)
mProtocolOffset++;
}

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

@ -47,6 +47,6 @@
#define CONTENT_LENGTH_LEN /*12345678901234*/ 14
/* Provide a common means of detecting empty lines in a message. i.e. to detect the end of headers among other things...*/
#define EMPTY_MESSAGE_LINE(buf) (buf[0] == CR || buf[0] == LF || buf[0] == '\0')
#define EMPTY_MESSAGE_LINE(buf) (buf[0] == nsCRT::CR || buf[0] == nsCRT::LF || buf[0] == '\0')
#endif

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

@ -33,7 +33,7 @@
#include "nsIMsgSearchScopeTerm.h"
#include "nsIMsgSearchTerm.h"
#define EMPTY_MESSAGE_LINE(buf) (buf[0] == CR || buf[0] == LF || buf[0] == '\0')
#define EMPTY_MESSAGE_LINE(buf) (buf[0] == nsCRT::CR || buf[0] == nsCRT::LF || buf[0] == '\0')
class nsMsgSearchTerm : public nsIMsgSearchTerm
{

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

@ -150,7 +150,7 @@ PRInt32 nsMsgBodyHandler::GetNextFilterLine(char * buf, PRUint32 bufSize)
// strings. It is possible to have: To NULL CR LF From. We want to skip over these CR/LFs if they start
// at the beginning of what we think is another header.
while ((m_headers[0] == CR || m_headers[0] == LF || m_headers[0] == ' ' || m_headers[0] == '\0') && m_headersSize > 0)
while ((m_headers[0] == nsCRT::CR || m_headers[0] == nsCRT::LF || m_headers[0] == ' ' || m_headers[0] == '\0') && m_headersSize > 0)
{
m_headers++; // skip over these chars...
m_headersSize--;

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

@ -732,7 +732,7 @@ nsresult nsMsgSearchTerm::MatchBody (nsIMsgSearchScopeTerm *scope, PRUint32 offs
// ConvertToUnicode(charset, buf, compare);
if (compare.Length() > 0) {
char startChar = (char) compare.CharAt(0);
if (startChar != CR && startChar != LF)
if (startChar != nsCRT::CR && startChar != nsCRT::LF)
{
err = MatchString (compare, folderCharset, &result);
lines++;

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

@ -556,7 +556,7 @@ nsMsgI18NParseMetaCharset(nsFileSpec* fileSpec)
while (!fileStream.eof() && !fileStream.failed() &&
fileStream.is_open()) {
fileStream.readline(buffer, 512);
if (*buffer == CR || *buffer == LF || *buffer == 0)
if (*buffer == nsCRT::CR || *buffer == nsCRT::LF || *buffer == 0)
continue;
for (int i = 0; i < (int)PL_strlen(buffer); i++) {

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

@ -107,8 +107,8 @@ nsMsgLineBuffer::SetLookingForCRLF(PRBool b)
PRInt32 nsMsgLineBuffer::BufferInput(const char *net_buffer, PRInt32 net_buffer_size)
{
int status = 0;
if (m_bufferPos > 0 && m_buffer && m_buffer[m_bufferPos - 1] == CR &&
net_buffer_size > 0 && net_buffer[0] != LF) {
if (m_bufferPos > 0 && m_buffer && m_buffer[m_bufferPos - 1] == nsCRT::CR &&
net_buffer_size > 0 && net_buffer[0] != nsCRT::LF) {
/* The last buffer ended with a CR. The new buffer does not start
with a LF. This old buffer should be shipped out and discarded. */
PR_ASSERT(m_bufferSize > m_bufferPos);
@ -135,15 +135,15 @@ PRInt32 nsMsgLineBuffer::BufferInput(const char *net_buffer, PRInt32 net_buffer_
seeing a line terminator. This is to catch the case of the
buffers splitting a CRLF pair, as in "FOO\r\nBAR\r" "\nBAZ\r\n".
*/
if (*s == CR || *s == LF) {
if (*s == nsCRT::CR || *s == nsCRT::LF) {
newline = s;
if (newline[0] == CR) {
if (newline[0] == nsCRT::CR) {
if (s == net_buffer_end - 1) {
/* CR at end - wait for the next character. */
newline = 0;
break;
}
else if (newline[1] == LF) {
else if (newline[1] == nsCRT::LF) {
/* CRLF seen; swallow both. */
newline++;
}
@ -154,7 +154,7 @@ PRInt32 nsMsgLineBuffer::BufferInput(const char *net_buffer, PRInt32 net_buffer_
}
else {
/* if not looking for a CRLF, stop at CR or LF. (for example, when parsing the newsrc file). this fixes #9896, where we'd lose the last line of anything we'd parse that used CR as the line break. */
if (*s == CR || *s == LF) {
if (*s == nsCRT::CR || *s == nsCRT::LF) {
newline = s;
newline++;
break;
@ -221,8 +221,8 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
return -1;
newline = buf + length;
PR_ASSERT(newline[-1] == CR || newline[-1] == LF);
if (newline[-1] != CR && newline[-1] != LF)
PR_ASSERT(newline[-1] == nsCRT::CR || newline[-1] == nsCRT::LF);
if (newline[-1] != nsCRT::CR && newline[-1] != nsCRT::LF)
return -1;
if (!m_convertNewlinesP)
@ -230,8 +230,8 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
}
#if (MSG_LINEBREAK_LEN == 1)
else if ((newline - buf) >= 2 &&
newline[-2] == CR &&
newline[-1] == LF)
newline[-2] == nsCRT::CR &&
newline[-1] == nsCRT::LF)
{
/* CRLF -> CR or LF */
buf [length - 2] = MSG_LINEBREAK[0];
@ -244,8 +244,8 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
buf [length - 1] = MSG_LINEBREAK[0];
}
#else
else if (((newline - buf) >= 2 && newline[-2] != CR) ||
((newline - buf) >= 1 && newline[-1] != LF))
else if (((newline - buf) >= 2 && newline[-2] != nsCRT::CR) ||
((newline - buf) >= 1 && newline[-1] != nsCRT::LF))
{
/* LF -> CRLF or CR -> CRLF */
length++;

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

@ -617,12 +617,12 @@ nsresult nsMsgProtocol::PostMessage(nsIURI* url, nsIFileSpec *fileSpec)
L++;
}
if (!lastLineWasComplete || (L > 1 && line[L-2] == CR &&
line[L-1] == LF))
if (!lastLineWasComplete || (L > 1 && line[L-2] == nsCRT::CR &&
line[L-1] == nsCRT::LF))
{
/* already ok */
}
else if(L > 0 /* && (line[L-1] == LF || line[L-1] == CR) */)
else if(L > 0 /* && (line[L-1] == nsCRT::LF || line[L-1] == nsCRT::CR) */)
{
/* only add the crlf if required
* we still need to do all the
@ -632,8 +632,8 @@ nsresult nsMsgProtocol::PostMessage(nsIURI* url, nsIFileSpec *fileSpec)
if(/* add_crlf_to_line_endings */ PR_TRUE)
{
/* Change newline to CRLF. */
line[L++] = CR;
line[L++] = LF;
line[L++] = nsCRT::CR;
line[L++] = nsCRT::LF;
line[L] = 0;
}
}
@ -641,8 +641,8 @@ nsresult nsMsgProtocol::PostMessage(nsIURI* url, nsIFileSpec *fileSpec)
/* && add_crlf_to_line_endings */)
{
// jt ** empty line; output CRLF
line[L++] = CR;
line[L++] = LF;
line[L++] = nsCRT::CR;
line[L++] = nsCRT::LF;
line[L] = 0;
}

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

@ -139,7 +139,7 @@ nsMsgAttachmentHandler::AnalyzeDataChunk(const char *chunk, PRInt32 length)
m_highbit_count++;
m_unprintable_count++;
}
else if (*s < ' ' && *s != '\t' && *s != CR && *s != LF)
else if (*s < ' ' && *s != '\t' && *s != nsCRT::CR && *s != nsCRT::LF)
{
m_unprintable_count++;
m_ctl_count++;
@ -147,9 +147,9 @@ nsMsgAttachmentHandler::AnalyzeDataChunk(const char *chunk, PRInt32 length)
m_null_count++;
}
if (*s == CR || *s == LF)
if (*s == nsCRT::CR || *s == nsCRT::LF)
{
if (s+1 < end && s[0] == CR && s[1] == LF)
if (s+1 < end && s[0] == nsCRT::CR && s[1] == nsCRT::LF)
s++;
if (m_max_column < m_current_column)
m_max_column = m_current_column;

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

@ -1285,7 +1285,7 @@ mime_fix_header_1 (const char *string, PRBool addr_p, PRBool news_p)
old_size = PL_strlen (string);
new_size = old_size;
for (i = 0; i < old_size; i++)
if (string[i] == CR || string[i] == LF)
if (string[i] == nsCRT::CR || string[i] == nsCRT::LF)
new_size += 2;
new_string = (char *) PR_Malloc (new_size + 1);
@ -1301,12 +1301,12 @@ mime_fix_header_1 (const char *string, PRBool addr_p, PRBool news_p)
/* replace CR, LF, or CRLF with CRLF-TAB. */
while (*in) {
if (*in == CR || *in == LF) {
if (*in == CR && in[1] == LF)
if (*in == nsCRT::CR || *in == nsCRT::LF) {
if (*in == nsCRT::CR && in[1] == nsCRT::LF)
in++;
in++;
*out++ = CR;
*out++ = LF;
*out++ = nsCRT::CR;
*out++ = nsCRT::LF;
*out++ = '\t';
}
else
@ -1477,13 +1477,13 @@ msg_make_filename_qtext(const char *srcText, PRBool stripCRLFs)
*/
if (*s == '\\' || *s == '"' ||
(!stripCRLFs &&
(*s == CR && (*(s+1) != LF ||
(*(s+1) == LF && (s+2) < end && !IS_SPACE(*(s+2)))))))
(*s == nsCRT::CR && (*(s+1) != nsCRT::LF ||
(*(s+1) == nsCRT::LF && (s+2) < end && !IS_SPACE(*(s+2)))))))
*d++ = '\\';
if (*s == CR)
if (*s == nsCRT::CR)
{
if (stripCRLFs && *(s+1) == LF && (s+2) < end && IS_SPACE(*(s+2)))
if (stripCRLFs && *(s+1) == nsCRT::LF && (s+2) < end && IS_SPACE(*(s+2)))
s += 2; // skip CRLFLWSP
}
else
@ -2053,7 +2053,7 @@ nsMsgParseSubjectFromFile(nsFileSpec* fileSpec)
if (wasTruncated)
continue;
if (*buffer == CR || *buffer == LF || *buffer == 0)
if (*buffer == nsCRT::CR || *buffer == nsCRT::LF || *buffer == 0)
break;
if ( !PL_strncasecmp(buffer, "Subject: ", 9) )

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

@ -157,7 +157,7 @@
#define PUSH_STRING(S) \
do { PL_strcpy (buffer_tail, S); buffer_tail += PL_strlen (S); } while(0)
#define PUSH_NEWLINE() \
do { *buffer_tail++ = CR; *buffer_tail++ = LF; *buffer_tail = '\0'; } while(0)
do { *buffer_tail++ = nsCRT::CR; *buffer_tail++ = nsCRT::LF; *buffer_tail = '\0'; } while(0)
//
// Forward declarations...

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

@ -208,7 +208,7 @@ FindEOL(char *inBuf, char *buf_end)
while (buf <= buf_end)
if (*buf == 0)
return buf;
else if ( (*buf == LF) || (*buf == CR) )
else if ( (*buf == nsCRT::LF) || (*buf == nsCRT::CR) )
{
findLoc = buf;
break;
@ -221,8 +221,8 @@ FindEOL(char *inBuf, char *buf_end)
else if ((findLoc + 1) > buf_end)
return buf;
if ( (*findLoc == LF && *(findLoc+1) == CR) ||
(*findLoc == CR && *(findLoc+1) == LF))
if ( (*findLoc == nsCRT::LF && *(findLoc+1) == nsCRT::CR) ||
(*findLoc == nsCRT::CR && *(findLoc+1) == nsCRT::LF))
findLoc++; // possibly a pair.
return findLoc;
}
@ -825,14 +825,14 @@ nsMsgSendLater::BuildHeaders()
value = buf;
SEARCH_NEWLINE:
while (*buf != 0 && *buf != CR && *buf != LF)
while (*buf != 0 && *buf != nsCRT::CR && *buf != nsCRT::LF)
buf++;
if (buf+1 >= buf_end)
;
// If "\r\n " or "\r\n\t" is next, that doesn't terminate the header.
else if (buf+2 < buf_end &&
(buf[0] == CR && buf[1] == LF) &&
(buf[0] == nsCRT::CR && buf[1] == nsCRT::LF) &&
(buf[2] == ' ' || buf[2] == '\t'))
{
buf += 3;
@ -840,7 +840,7 @@ SEARCH_NEWLINE:
}
// If "\r " or "\r\t" or "\n " or "\n\t" is next, that doesn't terminate
// the header either.
else if ((buf[0] == CR || buf[0] == LF) &&
else if ((buf[0] == nsCRT::CR || buf[0] == nsCRT::LF) &&
(buf[1] == ' ' || buf[1] == '\t'))
{
buf += 2;
@ -902,9 +902,9 @@ SEARCH_NEWLINE:
PR_FREEIF(draftInfo);
}
if (*buf == CR || *buf == LF)
if (*buf == nsCRT::CR || *buf == nsCRT::LF)
{
if (*buf == CR && buf[1] == LF)
if (*buf == nsCRT::CR && buf[1] == nsCRT::LF)
buf++;
buf++;
}
@ -921,8 +921,8 @@ SEARCH_NEWLINE:
}
}
m_headers[m_headersFP++] = CR;
m_headers[m_headersFP++] = LF;
m_headers[m_headersFP++] = nsCRT::CR;
m_headers[m_headersFP++] = nsCRT::LF;
// Now we have parsed out all of the headers we need and we
// can proceed.
@ -968,11 +968,11 @@ nsMsgSendLater::DeliverQueuedLine(char *line, PRInt32 length)
// convert existing newline to CRLF
// Don't need this because the calling routine is taking care of it.
// if (length > 0 && (line[length-1] == CR ||
// (line[length-1] == LF && (length < 2 || line[length-2] != CR))))
// if (length > 0 && (line[length-1] == nsCRT::CR ||
// (line[length-1] == nsCRT::LF && (length < 2 || line[length-2] != nsCRT::CR))))
// {
// line[length-1] = CR;
// line[length++] = LF;
// line[length-1] = nsCRT::CR;
// line[length++] = nsCRT::LF;
// }
//
//
@ -1008,7 +1008,7 @@ nsMsgSendLater::DeliverQueuedLine(char *line, PRInt32 length)
PR_FREEIF(m_fcc);
}
if (line[0] == CR || line[0] == LF || line[0] == 0)
if (line[0] == nsCRT::CR || line[0] == nsCRT::LF || line[0] == 0)
{
// End of headers. Now parse them; open the temp file;
// and write the appropriate subset of the headers out.

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

@ -284,24 +284,24 @@ int nsMsgSendPart::PushBody(char* buffer, PRInt32 length)
for (; in < end; in++) {
if (m_just_hit_CR) {
m_just_hit_CR = PR_FALSE;
if (*in == LF) {
if (*in == nsCRT::LF) {
// The last thing we wrote was a CRLF from hitting a CR.
// So, we don't want to do anything from a following LF;
// we want to ignore it.
continue;
}
}
if (*in == CR || *in == LF) {
if (*in == nsCRT::CR || *in == nsCRT::LF) {
/* Write out the newline. */
*out++ = CR;
*out++ = LF;
*out++ = nsCRT::CR;
*out++ = nsCRT::LF;
status = mime_write_message_body(m_state, buffer,
out - buffer);
if (status < 0) return status;
out = buffer;
if (*in == CR) {
if (*in == nsCRT::CR) {
m_just_hit_CR = PR_TRUE;
}
@ -392,11 +392,11 @@ divide_content_headers(const char *headers,
/* Loop until we reach a newline that is not followed by whitespace.
*/
if (tail[0] == 0 ||
((tail[0] == CR || tail[0] == LF) &&
!(tail[1] == ' ' || tail[1] == '\t' || tail[1] == LF)))
((tail[0] == nsCRT::CR || tail[0] == nsCRT::LF) &&
!(tail[1] == ' ' || tail[1] == '\t' || tail[1] == nsCRT::LF)))
{
/* Swallow the whole newline. */
if (tail[0] == CR && tail[1] == LF)
if (tail[0] == nsCRT::CR && tail[1] == nsCRT::LF)
tail++;
if (*tail)
tail++;
@ -592,9 +592,9 @@ nsMsgSendPart::Write()
L = PL_strlen(content_type_header);
if (content_type_header[L-1] == LF)
if (content_type_header[L-1] == nsCRT::LF)
content_type_header[--L] = 0;
if (content_type_header[L-1] == CR)
if (content_type_header[L-1] == nsCRT::CR)
content_type_header[--L] = 0;
ct2 = PR_smprintf("%s;\r\n boundary=\"%s\"" CRLF, content_type_header, separator);
@ -692,9 +692,9 @@ nsMsgSendPart::Write()
}
int hdrLen = PL_strlen(buffer);
if ((hdrLen < 2) || (buffer[hdrLen-2] != CR)) { // if the line doesn't end with CRLF,
if ((hdrLen < 2) || (buffer[hdrLen-2] != nsCRT::CR)) { // if the line doesn't end with CRLF,
// ... make it end with CRLF.
if ( (hdrLen == 0) || ((buffer[hdrLen-1] != CR) && (buffer[hdrLen-1] != LF)) )
if ( (hdrLen == 0) || ((buffer[hdrLen-1] != nsCRT::CR) && (buffer[hdrLen-1] != nsCRT::LF)) )
hdrLen++;
buffer[hdrLen-1] = '\015';
buffer[hdrLen] = '\012';
@ -720,7 +720,7 @@ nsMsgSendPart::Write()
PUSH(line);
if (*line == CR || *line == LF) {
if (*line == nsCRT::CR || *line == nsCRT::LF) {
break; // Now can do normal reads for the body.
}
}

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

@ -517,7 +517,7 @@ char *nsIMAPGenericParser::CreateLiteral()
if (!terminatedLine)
{
if (fCurrentTokenPlaceHolder &&
*fCurrentTokenPlaceHolder == LF &&
*fCurrentTokenPlaceHolder == nsCRT::LF &&
*(fCurrentTokenPlaceHolder+1))
{
// This is a static buffer, with a CRLF between the literal size ({91}) and

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

@ -2517,7 +2517,7 @@ NS_IMETHODIMP nsImapMailFolder::CopyData(nsIInputStream *aIStream,
end = PL_strstr(start, "\r");
if (!end)
end = PL_strstr(start, "\n");
else if (*(end+1) == LF && linebreak_len == 0)
else if (*(end+1) == nsCRT::LF && linebreak_len == 0)
linebreak_len = 2;
if (linebreak_len == 0) // not initialize yet

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

@ -2882,8 +2882,8 @@ void nsImapProtocol::HandleMessageDownLoadLine(const char *line, PRBool chunkEnd
if (MSG_LINEBREAK_LEN == 1 && !canonicalLineEnding)
{
if ((endOfLine - localMessageLine) >= 2 &&
endOfLine[-2] == CR &&
endOfLine[-1] == LF)
endOfLine[-2] == nsCRT::CR &&
endOfLine[-1] == nsCRT::LF)
{
/* CRLF -> CR or LF */
endOfLine[-2] = MSG_LINEBREAK[0];
@ -2891,7 +2891,7 @@ void nsImapProtocol::HandleMessageDownLoadLine(const char *line, PRBool chunkEnd
}
else if (endOfLine > localMessageLine + 1 &&
endOfLine[-1] != MSG_LINEBREAK[0] &&
((endOfLine[-1] == CR) || (endOfLine[-1] == LF)))
((endOfLine[-1] == nsCRT::CR) || (endOfLine[-1] == nsCRT::LF)))
{
/* CR -> LF or LF -> CR */
endOfLine[-1] = MSG_LINEBREAK[0];
@ -2904,10 +2904,10 @@ void nsImapProtocol::HandleMessageDownLoadLine(const char *line, PRBool chunkEnd
}
else
{
if (((endOfLine - localMessageLine) >= 2 && endOfLine[-2] != CR) ||
((endOfLine - localMessageLine) >= 1 && endOfLine[-1] != LF))
if (((endOfLine - localMessageLine) >= 2 && endOfLine[-2] != nsCRT::CR) ||
((endOfLine - localMessageLine) >= 1 && endOfLine[-1] != nsCRT::LF))
{
if ((endOfLine[-1] == CR) || (endOfLine[-1] == LF))
if ((endOfLine[-1] == nsCRT::CR) || (endOfLine[-1] == nsCRT::LF))
{
/* LF -> CRLF or CR -> CRLF */
endOfLine[-1] = MSG_LINEBREAK[0];

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

@ -2427,7 +2427,7 @@ PRBool nsImapServerResponseParser::msg_fetch_literal(PRBool chunk, PRInt32 origi
AdvanceToNextLine();
if (ContinueParse())
{
if (lastCRLFwasCRCRLF && (*fCurrentLine == CR))
if (lastCRLFwasCRCRLF && (*fCurrentLine == nsCRT::CR))
{
char *usableCurrentLine = PL_strdup(fCurrentLine + 1);
PR_FREEIF(fCurrentLine);
@ -2453,11 +2453,11 @@ PRBool nsImapServerResponseParser::msg_fetch_literal(PRBool chunk, PRInt32 origi
*displayEndOfLine = 0;
fServerConnection.HandleMessageDownLoadLine(fCurrentLine, !lastChunk);
*displayEndOfLine = saveit;
lastCRLFwasCRCRLF = (*(displayEndOfLine - 1) == CR);
lastCRLFwasCRCRLF = (*(displayEndOfLine - 1) == nsCRT::CR);
}
else
{
lastCRLFwasCRCRLF = (*(fCurrentLine + nsCRT::strlen(fCurrentLine) - 1) == CR);
lastCRLFwasCRCRLF = (*(fCurrentLine + nsCRT::strlen(fCurrentLine) - 1) == nsCRT::CR);
fServerConnection.HandleMessageDownLoadLine(fCurrentLine, !lastChunk && (charsReadSoFar == numberOfCharsInThisChunk));
}
}

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

@ -414,7 +414,7 @@ NS_IMETHODIMP ImportMailImpl::FindMailboxes( nsIFileSpec *pLoc, nsISupportsArray
void ImportMailImpl::AddLinebreak( nsString *pStream)
{
if (pStream)
pStream->AppendWithConversion( LF);
pStream->AppendWithConversion( char(nsCRT::LF));
}
void ImportMailImpl::ReportSuccess( nsString& name, PRInt32 count, nsString *pStream)

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

@ -373,7 +373,7 @@ NS_IMETHODIMP ImportMailImpl::FindMailboxes( nsIFileSpec *pLoc, nsISupportsArray
void ImportMailImpl::AddLinebreak( nsString *pStream)
{
if (pStream)
pStream->AppendWithConversion( LF);
pStream->AppendWithConversion( char(nsCRT::LF));
}
void ImportMailImpl::ReportSuccess( nsString& name, PRInt32 count, nsString *pStream)

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

@ -378,7 +378,7 @@ NS_IMETHODIMP ImportMailImpl::FindMailboxes( nsIFileSpec *pLoc, nsISupportsArray
void ImportMailImpl::AddLinebreak( nsString *pStream)
{
if (pStream)
pStream->AppendWithConversion( LF);
pStream->AppendWithConversion( char(nsCRT::LF));
}
void ImportMailImpl::ReportSuccess( nsString& name, PRInt32 count, nsString *pStream)

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

@ -408,7 +408,7 @@ void ImportAddressImpl::ReportSuccess( nsString& name, nsString *pStream)
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsTextStringBundle::FreeString( pFmt);
pStream->AppendWithConversion( LF);
pStream->AppendWithConversion( char(nsCRT::LF));
NS_IF_RELEASE( pBundle);
}
@ -423,7 +423,7 @@ void ImportAddressImpl::ReportError( PRInt32 errorNum, nsString& name, nsString
pStream->Append( pText);
nsTextFormatter::smprintf_free( pText);
nsTextStringBundle::FreeString( pFmt);
pStream->AppendWithConversion( LF);
pStream->AppendWithConversion( char(nsCRT::LF));
NS_IF_RELEASE( pBundle);
}

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

@ -2167,7 +2167,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
end = PL_strstr(start, "\r");
if (!end)
end = PL_strstr(start, "\n");
else if (*(end+1) == LF && linebreak_len == 0)
else if (*(end+1) == nsCRT::LF && linebreak_len == 0)
linebreak_len = 2;
if (linebreak_len == 0) // not set yet
@ -2227,7 +2227,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CopyData(nsIInputStream *aIStream, PRInt32 a
end = PL_strstr(start, "\r");
if (end)
{
if (*(end+1) == LF) //need to set the linebreak_len each time
if (*(end+1) == nsCRT::LF) //need to set the linebreak_len each time
linebreak_len = 2; //CRLF
else
linebreak_len = 1; //only CR
@ -2727,7 +2727,7 @@ nsresult nsMsgLocalMailFolder::DeleteMsgsOnPop3Server(nsISupportsArray *messages
// Remove CR or LF at end of line
char *lastChar = uidl + len - 1;
while ( (lastChar > uidl) && (*lastChar == LF || *lastChar == CR) ) {
while ( (lastChar > uidl) && (*lastChar == nsCRT::LF || *lastChar == nsCRT::CR) ) {
*lastChar = '\0';
lastChar --;
}

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

@ -876,14 +876,14 @@ int nsParseMailMessageState::ParseHeaders ()
header->value = value;
SEARCH_NEWLINE:
while (*buf != 0 && *buf != CR && *buf != LF)
while (*buf != 0 && *buf != nsCRT::CR && *buf != nsCRT::LF)
buf++;
if (buf+1 >= buf_end)
;
/* If "\r\n " or "\r\n\t" is next, that doesn't terminate the header. */
else if (buf+2 < buf_end &&
(buf[0] == CR && buf[1] == LF) &&
(buf[0] == nsCRT::CR && buf[1] == nsCRT::LF) &&
(buf[2] == ' ' || buf[2] == '\t'))
{
buf += 3;
@ -891,7 +891,7 @@ int nsParseMailMessageState::ParseHeaders ()
}
/* If "\r " or "\r\t" or "\n " or "\n\t" is next, that doesn't terminate
the header either. */
else if ((buf[0] == CR || buf[0] == LF) &&
else if ((buf[0] == nsCRT::CR || buf[0] == nsCRT::LF) &&
(buf[1] == ' ' || buf[1] == '\t'))
{
buf += 2;
@ -901,10 +901,10 @@ int nsParseMailMessageState::ParseHeaders ()
if (header)
header->length = buf - header->value;
if (*buf == CR || *buf == LF)
if (*buf == nsCRT::CR || *buf == nsCRT::LF)
{
char *last = buf;
if (*buf == CR && buf[1] == LF)
if (*buf == nsCRT::CR && buf[1] == nsCRT::LF)
buf++;
buf++;
*last = 0; /* short-circuit const, and null-terminate header. */

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

@ -178,7 +178,7 @@ net_pop3_load_state(const char* searchhost,
while (!fileStream.eof() && !fileStream.failed() && fileStream.is_open())
{
fileStream.readline(buf, 512);
if (*buf == '#' || *buf == CR || *buf == LF || *buf == 0)
if (*buf == '#' || *buf == nsCRT::CR || *buf == nsCRT::LF || *buf == 0)
continue;
if (buf[0] == '*') {
/* It's a host&user line. */
@ -2384,7 +2384,7 @@ nsPop3Protocol::HandleLine(char *line, PRUint32 line_length)
}
if ((line[0] == '.') &&
((line[1] == CR) || (line[1] == LF)))
((line[1] == nsCRT::CR) || (line[1] == nsCRT::LF)))
{
m_pop3ConData->assumed_end = PR_TRUE; /* in case byte count from server is */
/* wrong, mark we may have had the end */

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

@ -338,7 +338,7 @@ nsPop3Sink::GetDummyEnvelope(void)
now = 0x7FFFFFFF;
#endif
ct = ctime(&now);
PR_ASSERT(ct[24] == CR || ct[24] == LF);
PR_ASSERT(ct[24] == nsCRT::CR || ct[24] == nsCRT::LF);
ct[24] = 0;
/* This value must be in ctime() format, with English abbreviations.
strftime("... %c ...") is no good, because it is localized. */

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

@ -1735,7 +1735,7 @@ FindCharacterSet(MimeObject *obj)
return nsnull;
}
while ( (*cTypePtr) && (*cTypePtr != CR) && (*cTypePtr != LF) )
while ( (*cTypePtr) && (*cTypePtr != nsCRT::CR) && (*cTypePtr != nsCRT::LF) )
{
tCharSet = (char *) PL_strcasestr(cTypePtr, "charset=");
if (tCharSet )
@ -1753,7 +1753,7 @@ FindCharacterSet(MimeObject *obj)
while (*ptr)
{
if ( (*ptr == ' ') || (*ptr == ';') || (*ptr == CR) || (*ptr == LF) )
if ( (*ptr == ' ') || (*ptr == ';') || (*ptr == nsCRT::CR) || (*ptr == nsCRT::LF) )
{
*ptr = '\0';
break;
@ -1861,14 +1861,14 @@ MIME_StripContinuations(char *original)
while(*p2)
{
/* p2 runs ahead at (CR and/or LF) + <space> */
if ((p2[0] == CR) || (p2[0] == LF))
if ((p2[0] == nsCRT::CR) || (p2[0] == nsCRT::LF))
{
/* move past (CR and/or LF) + whitespace following */
do
{
p2++;
}
while((*p2 == CR) || (*p2 == LF) || IS_SPACE(*p2));
while((*p2 == nsCRT::CR) || (*p2 == nsCRT::LF) || IS_SPACE(*p2));
if (*p2 == '\0') continue; /* drop out of loop at end of string*/
}

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

@ -1180,7 +1180,7 @@ static void writeQPString(OFile *fp, const char *s)
if (needsQuotedPrintable (s))
{
while (*p) {
if (*p == CR || *p == LF)
if (*p == nsCRT::CR || *p == nsCRT::LF)
{
/* Whitespace cannot be allowed to occur at the end of the line.
So we encode " \n" as " =\n\n", that is, the whitespace, a
@ -1209,7 +1209,7 @@ static void writeQPString(OFile *fp, const char *s)
}
/* If its CRLF, swallow two chars instead of one. */
if (*p == CR && *(p+1) == LF)
if (*p == nsCRT::CR && *(p+1) == nsCRT::LF)
p++;
white = PR_FALSE;
current_column = 0;

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

@ -92,23 +92,23 @@ do \
#define OUTPUT_MACHINE_NEW_LINE(c) \
do \
{ \
OUTPUT(CR); \
OUTPUT(LF); \
OUTPUT(nsCRT::CR); \
OUTPUT(nsCRT::LF); \
} while (0)
#else
#ifdef XP_MAC
#define OUTPUT_MACHINE_NEW_LINE(c) \
do \
{ \
OUTPUT(CR); \
if (c) OUTPUT(LF); \
OUTPUT(nsCRT::CR); \
if (c) OUTPUT(nsCRT::LF); \
} while (0)
#else
#define OUTPUT_MACHINE_NEW_LINE(c) \
do \
{ \
if (c) OUTPUT(CR); \
OUTPUT(LF); \
if (c) OUTPUT(nsCRT::CR); \
OUTPUT(nsCRT::LF); \
} while (0)
#endif
#endif
@ -129,7 +129,7 @@ do \
#define NEW_LINE(c) \
do \
{ \
if ((*in == CR) && (*(in + 1) == LF)) \
if ((*in == nsCRT::CR) && (*(in + 1) == nsCRT::LF)) \
{ \
in += 2; \
} \
@ -179,7 +179,7 @@ xp_word_wrap(unsigned char *str, int maxColumn, int checkQuoting,
{
if (checkQuoting && (in == beginningOfLine) && (*in == '>'))
{
while (*in && (*in != CR) && (*in != LF))
while (*in && (*in != nsCRT::CR) && (*in != nsCRT::LF))
{
OUTPUT(*in++);
}
@ -199,7 +199,7 @@ xp_word_wrap(unsigned char *str, int maxColumn, int checkQuoting,
}
else
{
if ((*in == CR) || (*in == LF))
if ((*in == nsCRT::CR) || (*in == nsCRT::LF))
{
if (in != beginningOfLine)
{
@ -711,7 +711,7 @@ convert_and_encode:
if ( ( maxLineLen - line_len < 30 ) || bChop ) {
/* chop first, then continue */
buf1 = retbuf + retbuflen;
*buf1++ = CR; *buf1++ = LF; *buf1++ = '\t';
*buf1++ = nsCRT::CR; *buf1++ = nsCRT::LF; *buf1++ = '\t';
line_len = 0;
retbuflen += 3;
*buf1 = '\0';
@ -862,8 +862,8 @@ convert_and_encode:
if ((line_len > 10) &&
((line_len + convlen) > maxLineLen))
{
*buf1++ = CR;
*buf1++ = LF;
*buf1++ = nsCRT::CR;
*buf1++ = nsCRT::LF;
*buf1++ = '\t';
line_len = 0;
iThreshold = default_iThreshold;
@ -905,8 +905,8 @@ convert_and_encode:
if ((line_len > 10) &&
((line_len + len) > maxLineLen))
{
*buf1++ = CR;
*buf1++ = LF;
*buf1++ = nsCRT::CR;
*buf1++ = nsCRT::LF;
*buf1++ = '\t';
line_len = 0;
iThreshold = default_iThreshold;
@ -914,7 +914,7 @@ convert_and_encode:
/* copy buffer from begin to buf1 stripping CRLFTAB */
for (p = begin; *p; p++)
{
if (*p == CR || *p == LF || *p == TAB)
if (*p == nsCRT::CR || *p == nsCRT::LF || *p == TAB)
len --;
else
*buf1++ = *p;
@ -924,7 +924,7 @@ convert_and_encode:
}
buf1 = buf1 + nsCRT::strlen(buf1);
if (sep == CR || sep == LF || sep == TAB) /* strip CR,LF,TAB */
if (sep == nsCRT::CR || sep == nsCRT::LF || sep == TAB) /* strip CR,LF,TAB */
*buf1 = '\0';
else
{

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

@ -126,23 +126,23 @@ convert_and_send_buffer(char* buf, int length, PRBool convert_newlines_p,
* terminated by CR then a second line that contains only NULL+LF. We need to ignore this second
* line. See bug http://bugzilla.mozilla.org/show_bug.cgi?id=61412 for more information.
***/
if (length == 2 && buf[0] == 0x00 && buf[1] == LF)
if (length == 2 && buf[0] == 0x00 && buf[1] == nsCRT::LF)
return 0;
#endif
PR_ASSERT(buf && length > 0);
if (!buf || length <= 0) return -1;
newline = buf + length;
PR_ASSERT(newline[-1] == CR || newline[-1] == LF);
if (newline[-1] != CR && newline[-1] != LF) return -1;
PR_ASSERT(newline[-1] == nsCRT::CR || newline[-1] == nsCRT::LF);
if (newline[-1] != nsCRT::CR && newline[-1] != nsCRT::LF) return -1;
if (!convert_newlines_p)
{
}
#if (MSG_LINEBREAK_LEN == 1)
else if ((newline - buf) >= 2 &&
newline[-2] == CR &&
newline[-1] == LF)
newline[-2] == nsCRT::CR &&
newline[-1] == nsCRT::LF)
{
/* CRLF -> CR or LF */
buf [length - 2] = MSG_LINEBREAK[0];
@ -155,8 +155,8 @@ convert_and_send_buffer(char* buf, int length, PRBool convert_newlines_p,
buf [length - 1] = MSG_LINEBREAK[0];
}
#else
else if (((newline - buf) >= 2 && newline[-2] != CR) ||
((newline - buf) >= 1 && newline[-1] != LF))
else if (((newline - buf) >= 2 && newline[-2] != nsCRT::CR) ||
((newline - buf) >= 1 && newline[-1] != nsCRT::LF))
{
/* LF -> CRLF or CR -> CRLF */
length++;
@ -177,8 +177,8 @@ mime_LineBuffer (const char *net_buffer, PRInt32 net_buffer_size,
void *closure)
{
int status = 0;
if (*buffer_fpP > 0 && *bufferP && (*bufferP)[*buffer_fpP - 1] == CR &&
net_buffer_size > 0 && net_buffer[0] != LF) {
if (*buffer_fpP > 0 && *bufferP && (*bufferP)[*buffer_fpP - 1] == nsCRT::CR &&
net_buffer_size > 0 && net_buffer[0] != nsCRT::LF) {
/* The last buffer ended with a CR. The new buffer does not start
with a LF. This old buffer should be shipped out and discarded. */
PR_ASSERT((PRUint32) *buffer_sizeP > *buffer_fpP);
@ -205,10 +205,10 @@ mime_LineBuffer (const char *net_buffer, PRInt32 net_buffer_size,
seeing a line terminator. This is to catch the case of the
buffers splitting a CRLF pair, as in "FOO\r\nBAR\r" "\nBAZ\r\n".
*/
if (*s == CR || *s == LF)
if (*s == nsCRT::CR || *s == nsCRT::LF)
{
newline = s;
if (newline[0] == CR)
if (newline[0] == nsCRT::CR)
{
if (s == net_buffer_end - 1)
{
@ -216,7 +216,7 @@ mime_LineBuffer (const char *net_buffer, PRInt32 net_buffer_size,
newline = 0;
break;
}
else if (newline[1] == LF)
else if (newline[1] == nsCRT::LF)
/* CRLF seen; swallow both. */
newline++;
}

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

@ -143,7 +143,7 @@ MimeExternalBody_parse_line (char *line, PRInt32 length, MimeObject *obj)
/* If this line is blank, we're now done parsing headers, and should
create a dummy body to show that. Gag.
*/
if (*line == CR || *line == LF)
if (*line == nsCRT::CR || *line == nsCRT::LF)
{
bod->body = nsCRT::strdup("");
if (!bod->body) return MIME_OUT_OF_MEMORY;

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

@ -114,10 +114,10 @@ mime_decode_qp_buffer (MimeDecoderData *data, const char *buffer, PRInt32 length
c = token[1] - ('A' - 10);
else if (token[1] >= 'a' && token[1] <= 'f')
c = token[1] - ('a' - 10);
else if (token[1] == CR || token[1] == LF)
else if (token[1] == nsCRT::CR || token[1] == nsCRT::LF)
{
/* =\n means ignore the newline. */
if (token[1] == CR && token[2] == LF)
if (token[1] == nsCRT::CR && token[2] == nsCRT::LF)
; /* swallow all three chars */
else
{
@ -346,13 +346,13 @@ mime_decode_uue_buffer (MimeDecoderData *data,
*out++ = *input_buffer++;
input_length--;
if (out[-1] == CR || out[-1] == LF)
if (out[-1] == nsCRT::CR || out[-1] == nsCRT::LF)
{
/* If we just copied a CR, and an LF is waiting, grab it too.
*/
if (out[-1] == CR &&
if (out[-1] == nsCRT::CR &&
input_length > 0 &&
*input_buffer == LF)
*input_buffer == nsCRT::LF)
input_buffer++, input_length--;
/* We have a line. */
@ -363,7 +363,7 @@ mime_decode_uue_buffer (MimeDecoderData *data,
/* Ignore blank lines.
*/
if (*line == CR || *line == LF)
if (*line == nsCRT::CR || *line == nsCRT::LF)
{
*line = 0;
continue;
@ -376,14 +376,14 @@ mime_decode_uue_buffer (MimeDecoderData *data,
if (out == line_end)
{
out--;
out[-1] = CR;
out[-1] = nsCRT::CR;
out[0] = 0;
}
/* If we didn't get a complete line, simply return; we'll be called
with the rest of this line next time.
*/
if (out[-1] != CR && out[-1] != LF)
if (out[-1] != nsCRT::CR && out[-1] != nsCRT::LF)
{
PR_ASSERT (input_length == 0);
break;
@ -399,8 +399,8 @@ mime_decode_uue_buffer (MimeDecoderData *data,
line[0] == 'e' &&
line[1] == 'n' &&
line[2] == 'd' &&
(line[3] == CR ||
line[3] == LF))
(line[3] == nsCRT::CR ||
line[3] == nsCRT::LF))
{
/* done! */
data->uue_state = UUE_END;
@ -645,8 +645,8 @@ mime_uuencode_write_line(MimeEncoderData *data)
data->uue_line_buf[0] = ENC(data->line_byte_count);
/* Tack a CRLF onto the end. */
data->uue_line_buf[data->current_column++] = CR;
data->uue_line_buf[data->current_column++] = LF;
data->uue_line_buf[data->current_column++] = nsCRT::CR;
data->uue_line_buf[data->current_column++] = nsCRT::LF;
/* Write the line to output. */
data->write_buffer((const char*)data->uue_line_buf, data->current_column,
@ -885,7 +885,7 @@ mime_encode_qp_buffer (MimeEncoderData *data, const char *buffer, PRInt32 size)
*/
for (; in < end; in++)
{
if (*in == CR || *in == LF)
if (*in == nsCRT::CR || *in == nsCRT::LF)
{
/* Whitespace cannot be allowed to occur at the end of
@ -902,8 +902,8 @@ mime_encode_qp_buffer (MimeEncoderData *data, const char *buffer, PRInt32 size)
}
/* Now write out the newline. */
*out++ = CR;
*out++ = LF;
*out++ = nsCRT::CR;
*out++ = nsCRT::LF;
white = PR_FALSE;
status = data->write_buffer (out_buffer, (out - out_buffer),
@ -912,7 +912,7 @@ mime_encode_qp_buffer (MimeEncoderData *data, const char *buffer, PRInt32 size)
out = out_buffer;
/* If its CRLF, swallow two chars instead of one. */
if (in[0] == CR && in[1] == LF)
if (in[0] == nsCRT::CR && in[1] == nsCRT::LF)
in++;
out = out_buffer;
@ -973,8 +973,8 @@ mime_encode_qp_buffer (MimeEncoderData *data, const char *buffer, PRInt32 size)
if (data->current_column >= 73) /* soft line break: "=\r\n" */
{
*out++ = '=';
*out++ = CR;
*out++ = LF;
*out++ = nsCRT::CR;
*out++ = nsCRT::LF;
status = data->write_buffer (out_buffer, (out - out_buffer),
data->closure);
@ -1030,8 +1030,8 @@ MimeEncoderDestroy (MimeEncoderData *data, PRBool abort_p)
if (data->in_buffer_count > 1)
n = n | (((PRUint32) data->in_buffer[1]) << 8);
buf2[0] = CR;
buf2[1] = LF;
buf2[0] = nsCRT::CR;
buf2[1] = nsCRT::LF;
for (j = 18; j >= 0; j -= 6)
{

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

@ -126,7 +126,7 @@ MimeHeaders_parse_line (const char *buffer, PRInt32 size, MimeHeaders *hdrs)
PR_ASSERT(!hdrs->done_p);
if (hdrs->done_p) return -1;
if (!buffer || size == 0 || *buffer == CR || *buffer == LF)
if (!buffer || size == 0 || *buffer == nsCRT::CR || *buffer == nsCRT::LF)
{
/* If this is a blank line, we're done.
*/
@ -237,10 +237,10 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs)
end = hdrs->all_headers + hdrs->all_headers_fp;
for (s = hdrs->all_headers; s <= end-1; s++)
{
if (s <= (end-1) && s[0] == CR && s[1] == LF) /* CRLF -> LF */
if (s <= (end-1) && s[0] == nsCRT::CR && s[1] == nsCRT::LF) /* CRLF -> LF */
s++;
if ((s[0] == CR || s[0] == LF) && /* we're at a newline, and */
if ((s[0] == nsCRT::CR || s[0] == nsCRT::LF) && /* we're at a newline, and */
(s >= (end-1) || /* we're at EOF, or */
!(s[1] == ' ' || s[1] == '\t'))) /* next char is nonwhite */
hdrs->heads_size++;
@ -265,7 +265,7 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs)
while (s <= end)
{
SEARCH_NEWLINE:
while (s <= end-1 && *s != CR && *s != LF)
while (s <= end-1 && *s != nsCRT::CR && *s != nsCRT::LF)
s++;
if (s+1 >= end)
@ -273,7 +273,7 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs)
/* If "\r\n " or "\r\n\t" is next, that doesn't terminate the header. */
else if (s+2 < end &&
(s[0] == CR && s[1] == LF) &&
(s[0] == nsCRT::CR && s[1] == nsCRT::LF) &&
(s[2] == ' ' || s[2] == '\t'))
{
s += 3;
@ -281,7 +281,7 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs)
}
/* If "\r " or "\r\t" or "\n " or "\n\t" is next, that doesn't terminate
the header either. */
else if ((s[0] == CR || s[0] == LF) &&
else if ((s[0] == nsCRT::CR || s[0] == nsCRT::LF) &&
(s[1] == ' ' || s[1] == '\t'))
{
s += 2;
@ -291,8 +291,8 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs)
/* At this point, `s' points before a header-terminating newline.
Move past that newline, and store that new position in `heads'.
*/
if (*s == CR) s++;
if (*s == LF) s++;
if (*s == nsCRT::CR) s++;
if (*s == nsCRT::LF) s++;
if (s < end)
{
@ -790,7 +790,7 @@ MIME_StripContinuations(char *original)
while(*p2)
{
/* p2 runs ahead at (CR and/or LF) */
if ((p2[0] == CR) || (p2[0] == LF))
if ((p2[0] == nsCRT::CR) || (p2[0] == nsCRT::LF))
{
p2++;
} else {
@ -824,7 +824,7 @@ mime_decode_filename(char *name, const char *charset,
{
/* Remove backslashes when they are used to escape special characters. */
if ((*s == '\\') &&
((*(s+1) == CR) || (*(s+1) == LF) || (*(s+1) == '"') || (*(s+1) == '\\')))
((*(s+1) == nsCRT::CR) || (*(s+1) == nsCRT::LF) || (*(s+1) == '"') || (*(s+1) == '\\')))
s++; /* take whatever char follows the backslash */
if (*s)
*d++ = *s++;

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

@ -1871,7 +1871,7 @@ ResetChannelCharset(MimeObject *obj)
{
char *ptr2 = cSet;
while ( (*cSet) && (*cSet != ' ') && (*cSet != ';') &&
(*cSet != CR) && (*cSet != LF) && (*cSet != '"') )
(*cSet != nsCRT::CR) && (*cSet != nsCRT::LF) && (*cSet != '"') )
ptr2++;
if (*cSet) {

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

@ -149,7 +149,7 @@ MimeMessage_parse_line (char *line, PRInt32 length, MimeObject *obj)
char *tPtr = obj->headers->munged_subject;
while (*tPtr)
{
if ( (*tPtr == CR) || (*tPtr == LF) )
if ( (*tPtr == nsCRT::CR) || (*tPtr == nsCRT::LF) )
{
*tPtr = '\0';
break;
@ -180,7 +180,7 @@ MimeMessage_parse_line (char *line, PRInt32 length, MimeObject *obj)
called with a line that doesn't end in a newline is when that line
is the last line.
*/
nl = (length > 0 && (line[length-1] == CR || line[length-1] == LF));
nl = (length > 0 && (line[length-1] == nsCRT::CR || line[length-1] == nsCRT::LF));
#ifdef MIME_DRAFTS
if ( !mime_typep (kid, (MimeObjectClass*) &mimeMessageClass) &&
@ -250,7 +250,7 @@ MimeMessage_parse_line (char *line, PRInt32 length, MimeObject *obj)
/* If this line is blank, we're now done parsing headers, and should
examine our content-type to create our "body" part.
*/
if (*line == CR || *line == LF)
if (*line == nsCRT::CR || *line == nsCRT::LF)
{
status = MimeMessage_close_headers(obj);
if (status < 0) return status;

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

@ -316,8 +316,8 @@ MimeMultipartSigned_parse_line (char *line, PRInt32 length, MimeObject *obj)
*/
/* Remove the trailing newline... */
if (length > 0 && line[length-1] == LF) length--;
if (length > 0 && line[length-1] == CR) length--;
if (length > 0 && line[length-1] == nsCRT::LF) length--;
if (length > 0 && line[length-1] == nsCRT::CR) length--;
PR_ASSERT(sig->xlation_closure);
@ -524,8 +524,8 @@ MimeMultipartSigned_parse_child_line (MimeObject *obj,
*/
/* Remove the trailing newline... */
if (length > 0 && line[length-1] == LF) length--;
if (length > 0 && line[length-1] == CR) length--;
if (length > 0 && line[length-1] == nsCRT::LF) length--;
if (length > 0 && line[length-1] == nsCRT::CR) length--;
PR_ASSERT(sig->part_buffer);
PR_ASSERT(first_line_p ==

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

@ -198,7 +198,7 @@ MimeMultipart_parse_line (char *line, PRInt32 length, MimeObject *obj)
// If this line is blank, we're now done parsing headers, and should
// now examine the content-type to create this "body" part.
//
if (*line == CR || *line == LF)
if (*line == nsCRT::CR || *line == nsCRT::LF)
{
status = ((MimeMultipartClass *) obj->clazz)->create_child(obj);
if (status < 0) return status;
@ -531,8 +531,8 @@ MimeMultipart_parse_child_line (MimeObject *obj, char *line, PRInt32 length,
*/
/* Remove the trailing newline... */
if (length > 0 && line[length-1] == LF) length--;
if (length > 0 && line[length-1] == CR) length--;
if (length > 0 && line[length-1] == nsCRT::LF) length--;
if (length > 0 && line[length-1] == nsCRT::CR) length--;
if (!first_line_p)
{

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

@ -96,7 +96,7 @@ MimeSunAttachment_check_boundary(MimeObject *obj, const char *line,
line[0] == '-' && line[1] == '-' && line[2] == '-' && line[3] == '-' &&
line[4] == '-' && line[5] == '-' && line[6] == '-' && line[7] == '-' &&
line[8] == '-' && line[9] == '-' &&
(line[10] == CR || line[10] == LF))
(line[10] == nsCRT::CR || line[10] == nsCRT::LF))
return MimeMultipartBoundaryTypeSeparator;
else
return MimeMultipartBoundaryTypeNone;

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

@ -159,8 +159,8 @@ MimeUntypedText_parse_line (char *line, PRInt32 length, MimeObject *obj)
// just eat it and continue and if we really get more data, we'll open
// up the subpart then.
//
if (line[0] == CR) return 0;
if (line[0] == LF) return 0;
if (line[0] == nsCRT::CR) return 0;
if (line[0] == nsCRT::LF) return 0;
PR_ASSERT(!begin_line_p);
status = MimeUntypedText_open_subpart (obj,
@ -412,8 +412,8 @@ MimeUntypedText_uu_begin_line_p(const char *line, PRInt32 length,
name[(line+length)-s] = 0;
/* take off newline. */
if (name[nsCRT::strlen(name)-1] == LF) name[nsCRT::strlen(name)-1] = 0;
if (name[nsCRT::strlen(name)-1] == CR) name[nsCRT::strlen(name)-1] = 0;
if (name[nsCRT::strlen(name)-1] == nsCRT::LF) name[nsCRT::strlen(name)-1] = 0;
if (name[nsCRT::strlen(name)-1] == nsCRT::CR) name[nsCRT::strlen(name)-1] = 0;
/* Now try and figure out a type.
*/
@ -493,8 +493,8 @@ MimeUntypedText_binhex_begin_line_p(const char *line, PRInt32 length,
static PRBool
MimeUntypedText_binhex_end_line_p(const char *line, PRInt32 length)
{
if (length > 0 && line[length-1] == LF) length--;
if (length > 0 && line[length-1] == CR) length--;
if (length > 0 && line[length-1] == nsCRT::LF) length--;
if (length > 0 && line[length-1] == nsCRT::CR) length--;
if (length != 0 && length != 64)
return PR_TRUE;

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

@ -1407,8 +1407,8 @@ msg_format_Header_addresses (const char *names, const char *addrs,
{
if (out > result && out[-1] == ' ')
out--;
*out++ = CR;
*out++ = LF;
*out++ = nsCRT::CR;
*out++ = nsCRT::LF;
*out++ = '\t';
column = 8;
}

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

@ -1114,7 +1114,7 @@ nsMsgNewsFolder::HandleNewsrcLine(char* line, PRUint32 line_size)
nsresult rv;
/* guard against blank line lossage */
if (line[0] == '#' || line[0] == CR || line[0] == LF) return 0;
if (line[0] == '#' || line[0] == nsCRT::CR || line[0] == nsCRT::LF) return 0;
line[line_size] = 0;

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

@ -859,7 +859,7 @@ nsFtpState::Process() {
mNextState = FTP_ERROR;
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) FAILED\n", this));
} else {
char *lf = PL_strchr(mResponseMsg.get(), LF);
char *lf = PL_strchr(mResponseMsg.get(), nsCRT::LF);
if (lf && lf+1 && *(lf+1))
// we have a double response
// need to read again...
@ -1542,7 +1542,7 @@ nsFtpState::R_retr() {
// this can happen if the server sends back two
// responses before we've processed the first one.
PRInt32 loc = -1;
loc = mResponseMsg.FindChar(LF);
loc = mResponseMsg.FindChar(nsCRT::LF);
if (loc > -1) {
PRInt32 err;
nsCAutoString response;

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

@ -2519,7 +2519,7 @@ nsHTTPChannel::Authenticate(const char *aChallenge, PRBool aProxyAuth)
// go thru each to see if we support that.
for (const char *eol = aChallenge-1; eol != 0;) {
const char* bol = eol+1;
eol = PL_strchr(bol, LF);
eol = PL_strchr(bol, nsCRT::LF);
if (eol)
authLine.Assign(bol, eol-bol);
else

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

@ -166,7 +166,7 @@ nsresult nsHTTPHeaderArray::SetHeader(nsIAtom* aHeader,
// we can't use the standard comma because there
// set-cookie headers that include commas in the cookie value
// contrary to the specs not allowing it.
entry->mValue.Append(LF);
entry->mValue.Append(char(nsCRT::LF));
entry->mValue.Append(aValue);
} else {
// delimit each value from the others using a comma

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

@ -859,7 +859,7 @@ nsWriteLineToString(nsIInputStream* in,
for (; count>0; --count) {
c = *p++;
(*writeCount)++;
if (c == LF) {
if (c == nsCRT::LF) {
info->haveLF = PR_TRUE;
break;
}
@ -910,7 +910,7 @@ nsresult nsHTTPServerListener::ParseStatusLine(nsIInputStream* in,
}
// Wait for more data to arrive before processing the header...
if (bL > 0 && mHeaderBuffer.CharAt(bL - 1) != LF) return NS_OK;
if (bL > 0 && mHeaderBuffer.CharAt(bL - 1) != nsCRT::LF) return NS_OK;
LOG(("\tParseStatusLine [this=%x].\tGot Status-Line:%s\n",
this, mHeaderBuffer.get()));
@ -983,7 +983,7 @@ nsresult nsHTTPServerListener::ParseHTTPHeader(nsIInputStream* in,
// If last character in the header string is a LF, then the header
// may be complete...
//
newlineOffset = mHeaderBuffer.FindChar(LF, PR_FALSE, newlineOffset);
newlineOffset = mHeaderBuffer.FindChar(nsCRT::LF, PR_FALSE, newlineOffset);
if (newlineOffset == -1)
return NS_OK;

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

@ -128,7 +128,7 @@ nsFTPDirListingConv::Convert(nsIInputStream *aFromStream,
convertedData.Append("300: ");
convertedData.Append(spec);
convertedData.Append(LF);
convertedData.Append(char(nsCRT::LF));
// END 300:
// build up the column heading; 200:
@ -304,7 +304,7 @@ nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt,
indexFormat.Append("300: ");
indexFormat.Append(spec);
indexFormat.Append(LF);
indexFormat.Append(char(nsCRT::LF));
nsMemory::Free(spec);
// END 300:
@ -731,9 +731,9 @@ nsFTPDirListingConv::DigestBufferLines(char *aBuffer, nsCAutoString &aString) {
PRBool cr = PR_FALSE;
// while we have new lines, parse 'em into application/http-index-format.
while ( line && (eol = PL_strchr(line, LF)) ) {
while ( line && (eol = PL_strchr(line, nsCRT::LF)) ) {
// yank any carriage returns too.
if (eol > line && *(eol-1) == CR) {
if (eol > line && *(eol-1) == nsCRT::CR) {
eol--;
*eol = '\0';
cr = PR_TRUE;
@ -984,7 +984,7 @@ nsFTPDirListingConv::DigestBufferLines(char *aBuffer, nsCAutoString &aString) {
}
aString.Append(' ');
aString.Append(LF); // complete this line
aString.Append(char(nsCRT::LF)); // complete this line
// END 201:
NS_DELETEXPCOM(thisEntry);

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

@ -79,7 +79,7 @@ nsGopherDirListingConv::Convert(nsIInputStream *aFromStream,
convertedData.Append("300: ");
convertedData.Append(spec);
convertedData.Append(LF);
convertedData.Append(char(nsCRT::LF));
// END 300:
//Column headings
@ -197,7 +197,7 @@ nsGopherDirListingConv::OnDataAvailable(nsIRequest *request,
indexFormat.Append("300: ");
indexFormat.Append(spec.get());
indexFormat.Append(LF);
indexFormat.Append(char(nsCRT::LF));
// END 300:
// build up the column heading; 200:
@ -278,9 +278,9 @@ nsGopherDirListingConv::DigestBufferLines(char* aBuffer, nsCAutoString& aString)
PRBool cr = PR_FALSE;
// while we have new lines, parse 'em into application/http-index-format.
while (line && (eol = PL_strchr(line, LF)) ) {
while (line && (eol = PL_strchr(line, nsCRT::LF)) ) {
// yank any carriage returns too.
if (eol > line && *(eol-1) == CR) {
if (eol > line && *(eol-1) == nsCRT::CR) {
eol--;
*eol = '\0';
cr = PR_TRUE;
@ -393,7 +393,7 @@ nsGopherDirListingConv::DigestBufferLines(char* aBuffer, nsCAutoString& aString)
aString.Append("DIRECTORY");
else
aString.Append("FILE");
aString.Append(LF);
aString.Append(char(nsCRT::LF));
}
} else {
NS_WARNING("Error parsing gopher directory response.\n");

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

@ -218,7 +218,7 @@ nsMultiMixedConv::OnDataAvailable(nsIRequest *request, nsISupports *context,
// if we don't have a channel already, then we don't even
// have enough info to start a part, go ahead and buffer
// enough to collect a boundary token.
if (!mPartChannel || !(cursor[bufLen-1] == LF) )
if (!mPartChannel || !(cursor[bufLen-1] == nsCRT::LF) )
bufAmt = PR_MIN(mTokenLen - 1, bufLen);
}
@ -443,8 +443,8 @@ nsMultiMixedConv::SendData(char *aBuffer, PRUint32 aLen) {
PRInt8
nsMultiMixedConv::PushOverLine(char *&aPtr, PRUint32 &aLen) {
PRInt8 chars = 0;
if (*aPtr == CR || *aPtr == LF) {
if (aPtr[1] == LF)
if (*aPtr == nsCRT::CR || *aPtr == nsCRT::LF) {
if (aPtr[1] == nsCRT::LF)
chars++;
chars++;
}
@ -464,9 +464,9 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr,
PRUint8 lineFeedIncrement = 1;
while ( (cursorLen > 0)
&& (newLine = PL_strchr(cursor, LF)) ) {
&& (newLine = PL_strchr(cursor, nsCRT::LF)) ) {
// adjust for linefeeds
if ( (newLine > cursor) && (newLine[-1] == CR) ) { // CRLF
if ( (newLine > cursor) && (newLine[-1] == nsCRT::CR) ) { // CRLF
lineFeedIncrement = 2;
newLine--;
}

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

@ -588,7 +588,7 @@ void Tokenizer_HandleCharacterData(void *userData, const XML_Char *s, int len) {
switch(((PRUnichar*)s)[0]){
case kNewLine:
case CR:
case nsCRT::CR:
newToken = state->tokenAllocator->CreateTokenOfType(eToken_newline,eHTMLTag_unknown);
break;
case kSpace:

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

@ -1694,8 +1694,8 @@ Fix4xCookies(nsIFileSpec * profilePath) {
while (GetCookieLine(inStream,inBuffer) != -1){
/* skip line if it is a comment or null line */
if (inBuffer.CharAt(0) == '#' || inBuffer.CharAt(0) == CR ||
inBuffer.CharAt(0) == LF || inBuffer.CharAt(0) == 0) {
if (inBuffer.CharAt(0) == '#' || inBuffer.CharAt(0) == nsCRT::CR ||
inBuffer.CharAt(0) == nsCRT::LF || inBuffer.CharAt(0) == 0) {
PutCookieLine(outStream, inBuffer);
continue;
}

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

@ -29,16 +29,6 @@
#include "prtypes.h"
#include "nsCppSharedAllocator.h"
#define CR '\015' // \r
#define LF '\012' // \n
#define VTAB '\013'
#define FF '\014'
#define TAB '\011'
#define CRSTR "\015"
#define LFSTR "\012"
#define CRLF "\015\012" /* A CR LF equivalent string */
#ifdef XP_MAC
# define NS_LINEBREAK "\015"
# define NS_LINEBREAK_LEN 1
@ -54,10 +44,8 @@
# endif /* XP_PC */
#endif /* XP_MAC */
extern const PRUnichar kIsoLatin1ToUCS2[256];
// This macro can be used in a class declaration for classes that want
// to ensure that their instance memory is zeroed.
#define NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW \
@ -97,6 +85,13 @@ extern const PRUnichar kIsoLatin1ToUCS2[256];
class NS_COM nsCRT {
public:
enum {
TAB='\t' /* Horizontal Tab */,
LF='\n' /* Line Feed */,
VTAB='\v' /* Vertical Tab */,
FF='\f' /* Form Feed */,
CR='\r' /* Carriage Return */
};
/** Copy bytes from aSrc to aDest.
@param aDest the destination address
@ -274,6 +269,11 @@ public:
static PRBool IsAsciiSpace(PRUnichar aChar);
};
#define FF '\014'
#define TAB '\011'
#define CRSTR "\015"
#define LFSTR "\012"
#define CRLF "\015\012" /* A CR LF equivalent string */
#endif /* nsCRT_h___ */

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

@ -235,9 +235,9 @@ static T* ConvertUnknownBreaks(const T* inSrc, PRInt32& ioLen, const char* destB
while (src < srcEnd)
{
if (*src == CR)
if (*src == nsCRT::CR)
{
if (src < srcEnd && src[1] == LF)
if (src < srcEnd && src[1] == nsCRT::LF)
{
// CRLF
finalLen += destBreakLen;
@ -249,7 +249,7 @@ static T* ConvertUnknownBreaks(const T* inSrc, PRInt32& ioLen, const char* destB
finalLen += destBreakLen;
}
}
else if (*src == LF)
else if (*src == nsCRT::LF)
{
// Lone LF
finalLen += destBreakLen;
@ -271,9 +271,9 @@ static T* ConvertUnknownBreaks(const T* inSrc, PRInt32& ioLen, const char* destB
while (src < srcEnd)
{
if (*src == CR)
if (*src == nsCRT::CR)
{
if (src < srcEnd && src[1] == LF)
if (src < srcEnd && src[1] == nsCRT::LF)
{
// CRLF
AppendLinebreak(dst, destBreak);
@ -285,7 +285,7 @@ static T* ConvertUnknownBreaks(const T* inSrc, PRInt32& ioLen, const char* destB
AppendLinebreak(dst, destBreak);
}
}
else if (*src == LF)
else if (*src == nsCRT::LF)
{
// Lone LF
AppendLinebreak(dst, destBreak);