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 */ /* terminate at any carriage return or linefeed */
for(ptr=setCookieHeaderInternal; *ptr; ptr++) { for(ptr=setCookieHeaderInternal; *ptr; ptr++) {
if(*ptr == LF || *ptr == CR) { if(*ptr == nsCRT::LF || *ptr == nsCRT::CR) {
*ptr = '\0'; *ptr = '\0';
break; break;
} }
@ -1248,8 +1248,8 @@ COOKIE_Read() {
if ( !buffer.IsEmpty() ) { if ( !buffer.IsEmpty() ) {
PRUnichar firstChar = buffer.CharAt(0); PRUnichar firstChar = buffer.CharAt(0);
if (firstChar == '#' || firstChar == CR || if (firstChar == '#' || firstChar == nsCRT::CR ||
firstChar == LF || firstChar == 0) { firstChar == nsCRT::LF || firstChar == 0) {
continue; continue;
} }
} }

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

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

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

@ -1021,8 +1021,8 @@ nsXMLHttpRequest::GetStreamForWString(const PRUnichar* aStr,
nsCRT::memcpy(postData+headerSize, postData+MAX_HEADER_SIZE, charLength); nsCRT::memcpy(postData+headerSize, postData+MAX_HEADER_SIZE, charLength);
// Shove in the traling CRLF // Shove in the traling CRLF
postData[headerSize+charLength] = CR; postData[headerSize+charLength] = nsCRT::CR;
postData[headerSize+charLength+1] = LF; postData[headerSize+charLength+1] = nsCRT::LF;
postData[headerSize+charLength+2] = '\0'; postData[headerSize+charLength+2] = '\0';
// The new stream takes ownership of the buffer // 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]){ switch(((PRUnichar*)s)[0]){
case kNewLine: case kNewLine:
case CR: case nsCRT::CR:
newToken = state->tokenAllocator->CreateTokenOfType(eToken_newline,eHTMLTag_unknown); newToken = state->tokenAllocator->CreateTokenOfType(eToken_newline,eHTMLTag_unknown);
break; break;
case kSpace: case kSpace:

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

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

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

@ -47,6 +47,6 @@
#define CONTENT_LENGTH_LEN /*12345678901234*/ 14 #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...*/ /* 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 #endif

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

@ -33,7 +33,7 @@
#include "nsIMsgSearchScopeTerm.h" #include "nsIMsgSearchScopeTerm.h"
#include "nsIMsgSearchTerm.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 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 // 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. // 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_headers++; // skip over these chars...
m_headersSize--; m_headersSize--;

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

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

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

@ -556,7 +556,7 @@ nsMsgI18NParseMetaCharset(nsFileSpec* fileSpec)
while (!fileStream.eof() && !fileStream.failed() && while (!fileStream.eof() && !fileStream.failed() &&
fileStream.is_open()) { fileStream.is_open()) {
fileStream.readline(buffer, 512); fileStream.readline(buffer, 512);
if (*buffer == CR || *buffer == LF || *buffer == 0) if (*buffer == nsCRT::CR || *buffer == nsCRT::LF || *buffer == 0)
continue; continue;
for (int i = 0; i < (int)PL_strlen(buffer); i++) { 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) PRInt32 nsMsgLineBuffer::BufferInput(const char *net_buffer, PRInt32 net_buffer_size)
{ {
int status = 0; int status = 0;
if (m_bufferPos > 0 && m_buffer && m_buffer[m_bufferPos - 1] == CR && if (m_bufferPos > 0 && m_buffer && m_buffer[m_bufferPos - 1] == nsCRT::CR &&
net_buffer_size > 0 && net_buffer[0] != LF) { net_buffer_size > 0 && net_buffer[0] != nsCRT::LF) {
/* The last buffer ended with a CR. The new buffer does not start /* 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. */ with a LF. This old buffer should be shipped out and discarded. */
PR_ASSERT(m_bufferSize > m_bufferPos); 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 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". 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; newline = s;
if (newline[0] == CR) { if (newline[0] == nsCRT::CR) {
if (s == net_buffer_end - 1) { if (s == net_buffer_end - 1) {
/* CR at end - wait for the next character. */ /* CR at end - wait for the next character. */
newline = 0; newline = 0;
break; break;
} }
else if (newline[1] == LF) { else if (newline[1] == nsCRT::LF) {
/* CRLF seen; swallow both. */ /* CRLF seen; swallow both. */
newline++; newline++;
} }
@ -154,7 +154,7 @@ PRInt32 nsMsgLineBuffer::BufferInput(const char *net_buffer, PRInt32 net_buffer_
} }
else { 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 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 = s;
newline++; newline++;
break; break;
@ -221,8 +221,8 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
return -1; return -1;
newline = buf + length; newline = buf + length;
PR_ASSERT(newline[-1] == CR || newline[-1] == LF); PR_ASSERT(newline[-1] == nsCRT::CR || newline[-1] == nsCRT::LF);
if (newline[-1] != CR && newline[-1] != LF) if (newline[-1] != nsCRT::CR && newline[-1] != nsCRT::LF)
return -1; return -1;
if (!m_convertNewlinesP) if (!m_convertNewlinesP)
@ -230,8 +230,8 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
} }
#if (MSG_LINEBREAK_LEN == 1) #if (MSG_LINEBREAK_LEN == 1)
else if ((newline - buf) >= 2 && else if ((newline - buf) >= 2 &&
newline[-2] == CR && newline[-2] == nsCRT::CR &&
newline[-1] == LF) newline[-1] == nsCRT::LF)
{ {
/* CRLF -> CR or LF */ /* CRLF -> CR or LF */
buf [length - 2] = MSG_LINEBREAK[0]; buf [length - 2] = MSG_LINEBREAK[0];
@ -244,8 +244,8 @@ PRInt32 nsMsgLineBuffer::ConvertAndSendBuffer()
buf [length - 1] = MSG_LINEBREAK[0]; buf [length - 1] = MSG_LINEBREAK[0];
} }
#else #else
else if (((newline - buf) >= 2 && newline[-2] != CR) || else if (((newline - buf) >= 2 && newline[-2] != nsCRT::CR) ||
((newline - buf) >= 1 && newline[-1] != LF)) ((newline - buf) >= 1 && newline[-1] != nsCRT::LF))
{ {
/* LF -> CRLF or CR -> CRLF */ /* LF -> CRLF or CR -> CRLF */
length++; length++;

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

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

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

@ -139,7 +139,7 @@ nsMsgAttachmentHandler::AnalyzeDataChunk(const char *chunk, PRInt32 length)
m_highbit_count++; m_highbit_count++;
m_unprintable_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_unprintable_count++;
m_ctl_count++; m_ctl_count++;
@ -147,9 +147,9 @@ nsMsgAttachmentHandler::AnalyzeDataChunk(const char *chunk, PRInt32 length)
m_null_count++; 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++; s++;
if (m_max_column < m_current_column) if (m_max_column < m_current_column)
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); old_size = PL_strlen (string);
new_size = old_size; new_size = old_size;
for (i = 0; i < old_size; i++) 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_size += 2;
new_string = (char *) PR_Malloc (new_size + 1); 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. */ /* replace CR, LF, or CRLF with CRLF-TAB. */
while (*in) { while (*in) {
if (*in == CR || *in == LF) { if (*in == nsCRT::CR || *in == nsCRT::LF) {
if (*in == CR && in[1] == LF) if (*in == nsCRT::CR && in[1] == nsCRT::LF)
in++; in++;
in++; in++;
*out++ = CR; *out++ = nsCRT::CR;
*out++ = LF; *out++ = nsCRT::LF;
*out++ = '\t'; *out++ = '\t';
} }
else else
@ -1477,13 +1477,13 @@ msg_make_filename_qtext(const char *srcText, PRBool stripCRLFs)
*/ */
if (*s == '\\' || *s == '"' || if (*s == '\\' || *s == '"' ||
(!stripCRLFs && (!stripCRLFs &&
(*s == CR && (*(s+1) != LF || (*s == nsCRT::CR && (*(s+1) != nsCRT::LF ||
(*(s+1) == LF && (s+2) < end && !IS_SPACE(*(s+2))))))) (*(s+1) == nsCRT::LF && (s+2) < end && !IS_SPACE(*(s+2)))))))
*d++ = '\\'; *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 s += 2; // skip CRLFLWSP
} }
else else
@ -2053,7 +2053,7 @@ nsMsgParseSubjectFromFile(nsFileSpec* fileSpec)
if (wasTruncated) if (wasTruncated)
continue; continue;
if (*buffer == CR || *buffer == LF || *buffer == 0) if (*buffer == nsCRT::CR || *buffer == nsCRT::LF || *buffer == 0)
break; break;
if ( !PL_strncasecmp(buffer, "Subject: ", 9) ) if ( !PL_strncasecmp(buffer, "Subject: ", 9) )

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

@ -157,7 +157,7 @@
#define PUSH_STRING(S) \ #define PUSH_STRING(S) \
do { PL_strcpy (buffer_tail, S); buffer_tail += PL_strlen (S); } while(0) do { PL_strcpy (buffer_tail, S); buffer_tail += PL_strlen (S); } while(0)
#define PUSH_NEWLINE() \ #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... // Forward declarations...

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

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

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

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

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

@ -517,7 +517,7 @@ char *nsIMAPGenericParser::CreateLiteral()
if (!terminatedLine) if (!terminatedLine)
{ {
if (fCurrentTokenPlaceHolder && if (fCurrentTokenPlaceHolder &&
*fCurrentTokenPlaceHolder == LF && *fCurrentTokenPlaceHolder == nsCRT::LF &&
*(fCurrentTokenPlaceHolder+1)) *(fCurrentTokenPlaceHolder+1))
{ {
// This is a static buffer, with a CRLF between the literal size ({91}) and // 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"); end = PL_strstr(start, "\r");
if (!end) if (!end)
end = PL_strstr(start, "\n"); 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; linebreak_len = 2;
if (linebreak_len == 0) // not initialize yet 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 (MSG_LINEBREAK_LEN == 1 && !canonicalLineEnding)
{ {
if ((endOfLine - localMessageLine) >= 2 && if ((endOfLine - localMessageLine) >= 2 &&
endOfLine[-2] == CR && endOfLine[-2] == nsCRT::CR &&
endOfLine[-1] == LF) endOfLine[-1] == nsCRT::LF)
{ {
/* CRLF -> CR or LF */ /* CRLF -> CR or LF */
endOfLine[-2] = MSG_LINEBREAK[0]; endOfLine[-2] = MSG_LINEBREAK[0];
@ -2891,7 +2891,7 @@ void nsImapProtocol::HandleMessageDownLoadLine(const char *line, PRBool chunkEnd
} }
else if (endOfLine > localMessageLine + 1 && else if (endOfLine > localMessageLine + 1 &&
endOfLine[-1] != MSG_LINEBREAK[0] && endOfLine[-1] != MSG_LINEBREAK[0] &&
((endOfLine[-1] == CR) || (endOfLine[-1] == LF))) ((endOfLine[-1] == nsCRT::CR) || (endOfLine[-1] == nsCRT::LF)))
{ {
/* CR -> LF or LF -> CR */ /* CR -> LF or LF -> CR */
endOfLine[-1] = MSG_LINEBREAK[0]; endOfLine[-1] = MSG_LINEBREAK[0];
@ -2904,10 +2904,10 @@ void nsImapProtocol::HandleMessageDownLoadLine(const char *line, PRBool chunkEnd
} }
else else
{ {
if (((endOfLine - localMessageLine) >= 2 && endOfLine[-2] != CR) || if (((endOfLine - localMessageLine) >= 2 && endOfLine[-2] != nsCRT::CR) ||
((endOfLine - localMessageLine) >= 1 && endOfLine[-1] != LF)) ((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 */ /* LF -> CRLF or CR -> CRLF */
endOfLine[-1] = MSG_LINEBREAK[0]; endOfLine[-1] = MSG_LINEBREAK[0];

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

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

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

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

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

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

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

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

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

@ -876,14 +876,14 @@ int nsParseMailMessageState::ParseHeaders ()
header->value = value; header->value = value;
SEARCH_NEWLINE: SEARCH_NEWLINE:
while (*buf != 0 && *buf != CR && *buf != LF) while (*buf != 0 && *buf != nsCRT::CR && *buf != nsCRT::LF)
buf++; buf++;
if (buf+1 >= buf_end) if (buf+1 >= buf_end)
; ;
/* If "\r\n " or "\r\n\t" is next, that doesn't terminate the header. */ /* If "\r\n " or "\r\n\t" is next, that doesn't terminate the header. */
else if (buf+2 < buf_end && 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[2] == ' ' || buf[2] == '\t'))
{ {
buf += 3; 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 /* If "\r " or "\r\t" or "\n " or "\n\t" is next, that doesn't terminate
the header either. */ 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[1] == ' ' || buf[1] == '\t'))
{ {
buf += 2; buf += 2;
@ -901,10 +901,10 @@ int nsParseMailMessageState::ParseHeaders ()
if (header) if (header)
header->length = buf - header->value; header->length = buf - header->value;
if (*buf == CR || *buf == LF) if (*buf == nsCRT::CR || *buf == nsCRT::LF)
{ {
char *last = buf; char *last = buf;
if (*buf == CR && buf[1] == LF) if (*buf == nsCRT::CR && buf[1] == nsCRT::LF)
buf++; buf++;
buf++; buf++;
*last = 0; /* short-circuit const, and null-terminate header. */ *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()) while (!fileStream.eof() && !fileStream.failed() && fileStream.is_open())
{ {
fileStream.readline(buf, 512); fileStream.readline(buf, 512);
if (*buf == '#' || *buf == CR || *buf == LF || *buf == 0) if (*buf == '#' || *buf == nsCRT::CR || *buf == nsCRT::LF || *buf == 0)
continue; continue;
if (buf[0] == '*') { if (buf[0] == '*') {
/* It's a host&user line. */ /* It's a host&user line. */
@ -2384,7 +2384,7 @@ nsPop3Protocol::HandleLine(char *line, PRUint32 line_length)
} }
if ((line[0] == '.') && 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 */ m_pop3ConData->assumed_end = PR_TRUE; /* in case byte count from server is */
/* wrong, mark we may have had the end */ /* wrong, mark we may have had the end */

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

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

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

@ -1735,7 +1735,7 @@ FindCharacterSet(MimeObject *obj)
return nsnull; return nsnull;
} }
while ( (*cTypePtr) && (*cTypePtr != CR) && (*cTypePtr != LF) ) while ( (*cTypePtr) && (*cTypePtr != nsCRT::CR) && (*cTypePtr != nsCRT::LF) )
{ {
tCharSet = (char *) PL_strcasestr(cTypePtr, "charset="); tCharSet = (char *) PL_strcasestr(cTypePtr, "charset=");
if (tCharSet ) if (tCharSet )
@ -1753,7 +1753,7 @@ FindCharacterSet(MimeObject *obj)
while (*ptr) while (*ptr)
{ {
if ( (*ptr == ' ') || (*ptr == ';') || (*ptr == CR) || (*ptr == LF) ) if ( (*ptr == ' ') || (*ptr == ';') || (*ptr == nsCRT::CR) || (*ptr == nsCRT::LF) )
{ {
*ptr = '\0'; *ptr = '\0';
break; break;
@ -1861,14 +1861,14 @@ MIME_StripContinuations(char *original)
while(*p2) while(*p2)
{ {
/* p2 runs ahead at (CR and/or LF) + <space> */ /* 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 */ /* move past (CR and/or LF) + whitespace following */
do do
{ {
p2++; 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*/ 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)) if (needsQuotedPrintable (s))
{ {
while (*p) { 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. /* Whitespace cannot be allowed to occur at the end of the line.
So we encode " \n" as " =\n\n", that is, the whitespace, a 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 its CRLF, swallow two chars instead of one. */
if (*p == CR && *(p+1) == LF) if (*p == nsCRT::CR && *(p+1) == nsCRT::LF)
p++; p++;
white = PR_FALSE; white = PR_FALSE;
current_column = 0; current_column = 0;

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

@ -92,23 +92,23 @@ do \
#define OUTPUT_MACHINE_NEW_LINE(c) \ #define OUTPUT_MACHINE_NEW_LINE(c) \
do \ do \
{ \ { \
OUTPUT(CR); \ OUTPUT(nsCRT::CR); \
OUTPUT(LF); \ OUTPUT(nsCRT::LF); \
} while (0) } while (0)
#else #else
#ifdef XP_MAC #ifdef XP_MAC
#define OUTPUT_MACHINE_NEW_LINE(c) \ #define OUTPUT_MACHINE_NEW_LINE(c) \
do \ do \
{ \ { \
OUTPUT(CR); \ OUTPUT(nsCRT::CR); \
if (c) OUTPUT(LF); \ if (c) OUTPUT(nsCRT::LF); \
} while (0) } while (0)
#else #else
#define OUTPUT_MACHINE_NEW_LINE(c) \ #define OUTPUT_MACHINE_NEW_LINE(c) \
do \ do \
{ \ { \
if (c) OUTPUT(CR); \ if (c) OUTPUT(nsCRT::CR); \
OUTPUT(LF); \ OUTPUT(nsCRT::LF); \
} while (0) } while (0)
#endif #endif
#endif #endif
@ -129,7 +129,7 @@ do \
#define NEW_LINE(c) \ #define NEW_LINE(c) \
do \ do \
{ \ { \
if ((*in == CR) && (*(in + 1) == LF)) \ if ((*in == nsCRT::CR) && (*(in + 1) == nsCRT::LF)) \
{ \ { \
in += 2; \ in += 2; \
} \ } \
@ -179,7 +179,7 @@ xp_word_wrap(unsigned char *str, int maxColumn, int checkQuoting,
{ {
if (checkQuoting && (in == beginningOfLine) && (*in == '>')) if (checkQuoting && (in == beginningOfLine) && (*in == '>'))
{ {
while (*in && (*in != CR) && (*in != LF)) while (*in && (*in != nsCRT::CR) && (*in != nsCRT::LF))
{ {
OUTPUT(*in++); OUTPUT(*in++);
} }
@ -199,7 +199,7 @@ xp_word_wrap(unsigned char *str, int maxColumn, int checkQuoting,
} }
else else
{ {
if ((*in == CR) || (*in == LF)) if ((*in == nsCRT::CR) || (*in == nsCRT::LF))
{ {
if (in != beginningOfLine) if (in != beginningOfLine)
{ {
@ -711,7 +711,7 @@ convert_and_encode:
if ( ( maxLineLen - line_len < 30 ) || bChop ) { if ( ( maxLineLen - line_len < 30 ) || bChop ) {
/* chop first, then continue */ /* chop first, then continue */
buf1 = retbuf + retbuflen; buf1 = retbuf + retbuflen;
*buf1++ = CR; *buf1++ = LF; *buf1++ = '\t'; *buf1++ = nsCRT::CR; *buf1++ = nsCRT::LF; *buf1++ = '\t';
line_len = 0; line_len = 0;
retbuflen += 3; retbuflen += 3;
*buf1 = '\0'; *buf1 = '\0';
@ -862,8 +862,8 @@ convert_and_encode:
if ((line_len > 10) && if ((line_len > 10) &&
((line_len + convlen) > maxLineLen)) ((line_len + convlen) > maxLineLen))
{ {
*buf1++ = CR; *buf1++ = nsCRT::CR;
*buf1++ = LF; *buf1++ = nsCRT::LF;
*buf1++ = '\t'; *buf1++ = '\t';
line_len = 0; line_len = 0;
iThreshold = default_iThreshold; iThreshold = default_iThreshold;
@ -905,8 +905,8 @@ convert_and_encode:
if ((line_len > 10) && if ((line_len > 10) &&
((line_len + len) > maxLineLen)) ((line_len + len) > maxLineLen))
{ {
*buf1++ = CR; *buf1++ = nsCRT::CR;
*buf1++ = LF; *buf1++ = nsCRT::LF;
*buf1++ = '\t'; *buf1++ = '\t';
line_len = 0; line_len = 0;
iThreshold = default_iThreshold; iThreshold = default_iThreshold;
@ -914,7 +914,7 @@ convert_and_encode:
/* copy buffer from begin to buf1 stripping CRLFTAB */ /* copy buffer from begin to buf1 stripping CRLFTAB */
for (p = begin; *p; p++) for (p = begin; *p; p++)
{ {
if (*p == CR || *p == LF || *p == TAB) if (*p == nsCRT::CR || *p == nsCRT::LF || *p == TAB)
len --; len --;
else else
*buf1++ = *p; *buf1++ = *p;
@ -924,7 +924,7 @@ convert_and_encode:
} }
buf1 = buf1 + nsCRT::strlen(buf1); 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'; *buf1 = '\0';
else 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 * 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. * 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; return 0;
#endif #endif
PR_ASSERT(buf && length > 0); PR_ASSERT(buf && length > 0);
if (!buf || length <= 0) return -1; if (!buf || length <= 0) return -1;
newline = buf + length; newline = buf + length;
PR_ASSERT(newline[-1] == CR || newline[-1] == LF); PR_ASSERT(newline[-1] == nsCRT::CR || newline[-1] == nsCRT::LF);
if (newline[-1] != CR && newline[-1] != LF) return -1; if (newline[-1] != nsCRT::CR && newline[-1] != nsCRT::LF) return -1;
if (!convert_newlines_p) if (!convert_newlines_p)
{ {
} }
#if (MSG_LINEBREAK_LEN == 1) #if (MSG_LINEBREAK_LEN == 1)
else if ((newline - buf) >= 2 && else if ((newline - buf) >= 2 &&
newline[-2] == CR && newline[-2] == nsCRT::CR &&
newline[-1] == LF) newline[-1] == nsCRT::LF)
{ {
/* CRLF -> CR or LF */ /* CRLF -> CR or LF */
buf [length - 2] = MSG_LINEBREAK[0]; 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]; buf [length - 1] = MSG_LINEBREAK[0];
} }
#else #else
else if (((newline - buf) >= 2 && newline[-2] != CR) || else if (((newline - buf) >= 2 && newline[-2] != nsCRT::CR) ||
((newline - buf) >= 1 && newline[-1] != LF)) ((newline - buf) >= 1 && newline[-1] != nsCRT::LF))
{ {
/* LF -> CRLF or CR -> CRLF */ /* LF -> CRLF or CR -> CRLF */
length++; length++;
@ -177,8 +177,8 @@ mime_LineBuffer (const char *net_buffer, PRInt32 net_buffer_size,
void *closure) void *closure)
{ {
int status = 0; int status = 0;
if (*buffer_fpP > 0 && *bufferP && (*bufferP)[*buffer_fpP - 1] == CR && if (*buffer_fpP > 0 && *bufferP && (*bufferP)[*buffer_fpP - 1] == nsCRT::CR &&
net_buffer_size > 0 && net_buffer[0] != LF) { net_buffer_size > 0 && net_buffer[0] != nsCRT::LF) {
/* The last buffer ended with a CR. The new buffer does not start /* 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. */ with a LF. This old buffer should be shipped out and discarded. */
PR_ASSERT((PRUint32) *buffer_sizeP > *buffer_fpP); 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 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". 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; newline = s;
if (newline[0] == CR) if (newline[0] == nsCRT::CR)
{ {
if (s == net_buffer_end - 1) if (s == net_buffer_end - 1)
{ {
@ -216,7 +216,7 @@ mime_LineBuffer (const char *net_buffer, PRInt32 net_buffer_size,
newline = 0; newline = 0;
break; break;
} }
else if (newline[1] == LF) else if (newline[1] == nsCRT::LF)
/* CRLF seen; swallow both. */ /* CRLF seen; swallow both. */
newline++; 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 /* If this line is blank, we're now done parsing headers, and should
create a dummy body to show that. Gag. create a dummy body to show that. Gag.
*/ */
if (*line == CR || *line == LF) if (*line == nsCRT::CR || *line == nsCRT::LF)
{ {
bod->body = nsCRT::strdup(""); bod->body = nsCRT::strdup("");
if (!bod->body) return MIME_OUT_OF_MEMORY; 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); c = token[1] - ('A' - 10);
else if (token[1] >= 'a' && token[1] <= 'f') else if (token[1] >= 'a' && token[1] <= 'f')
c = token[1] - ('a' - 10); 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. */ /* =\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 */ ; /* swallow all three chars */
else else
{ {
@ -346,13 +346,13 @@ mime_decode_uue_buffer (MimeDecoderData *data,
*out++ = *input_buffer++; *out++ = *input_buffer++;
input_length--; 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 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_length > 0 &&
*input_buffer == LF) *input_buffer == nsCRT::LF)
input_buffer++, input_length--; input_buffer++, input_length--;
/* We have a line. */ /* We have a line. */
@ -363,7 +363,7 @@ mime_decode_uue_buffer (MimeDecoderData *data,
/* Ignore blank lines. /* Ignore blank lines.
*/ */
if (*line == CR || *line == LF) if (*line == nsCRT::CR || *line == nsCRT::LF)
{ {
*line = 0; *line = 0;
continue; continue;
@ -376,14 +376,14 @@ mime_decode_uue_buffer (MimeDecoderData *data,
if (out == line_end) if (out == line_end)
{ {
out--; out--;
out[-1] = CR; out[-1] = nsCRT::CR;
out[0] = 0; out[0] = 0;
} }
/* If we didn't get a complete line, simply return; we'll be called /* If we didn't get a complete line, simply return; we'll be called
with the rest of this line next time. 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); PR_ASSERT (input_length == 0);
break; break;
@ -399,8 +399,8 @@ mime_decode_uue_buffer (MimeDecoderData *data,
line[0] == 'e' && line[0] == 'e' &&
line[1] == 'n' && line[1] == 'n' &&
line[2] == 'd' && line[2] == 'd' &&
(line[3] == CR || (line[3] == nsCRT::CR ||
line[3] == LF)) line[3] == nsCRT::LF))
{ {
/* done! */ /* done! */
data->uue_state = UUE_END; 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); data->uue_line_buf[0] = ENC(data->line_byte_count);
/* Tack a CRLF onto the end. */ /* Tack a CRLF onto the end. */
data->uue_line_buf[data->current_column++] = CR; data->uue_line_buf[data->current_column++] = nsCRT::CR;
data->uue_line_buf[data->current_column++] = LF; data->uue_line_buf[data->current_column++] = nsCRT::LF;
/* Write the line to output. */ /* Write the line to output. */
data->write_buffer((const char*)data->uue_line_buf, data->current_column, 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++) 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 /* 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. */ /* Now write out the newline. */
*out++ = CR; *out++ = nsCRT::CR;
*out++ = LF; *out++ = nsCRT::LF;
white = PR_FALSE; white = PR_FALSE;
status = data->write_buffer (out_buffer, (out - out_buffer), 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; out = out_buffer;
/* If its CRLF, swallow two chars instead of one. */ /* 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++; in++;
out = out_buffer; 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" */ if (data->current_column >= 73) /* soft line break: "=\r\n" */
{ {
*out++ = '='; *out++ = '=';
*out++ = CR; *out++ = nsCRT::CR;
*out++ = LF; *out++ = nsCRT::LF;
status = data->write_buffer (out_buffer, (out - out_buffer), status = data->write_buffer (out_buffer, (out - out_buffer),
data->closure); data->closure);
@ -1030,8 +1030,8 @@ MimeEncoderDestroy (MimeEncoderData *data, PRBool abort_p)
if (data->in_buffer_count > 1) if (data->in_buffer_count > 1)
n = n | (((PRUint32) data->in_buffer[1]) << 8); n = n | (((PRUint32) data->in_buffer[1]) << 8);
buf2[0] = CR; buf2[0] = nsCRT::CR;
buf2[1] = LF; buf2[1] = nsCRT::LF;
for (j = 18; j >= 0; j -= 6) 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); PR_ASSERT(!hdrs->done_p);
if (hdrs->done_p) return -1; 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. /* 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; end = hdrs->all_headers + hdrs->all_headers_fp;
for (s = hdrs->all_headers; s <= end-1; s++) 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++; 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 >= (end-1) || /* we're at EOF, or */
!(s[1] == ' ' || s[1] == '\t'))) /* next char is nonwhite */ !(s[1] == ' ' || s[1] == '\t'))) /* next char is nonwhite */
hdrs->heads_size++; hdrs->heads_size++;
@ -265,7 +265,7 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs)
while (s <= end) while (s <= end)
{ {
SEARCH_NEWLINE: SEARCH_NEWLINE:
while (s <= end-1 && *s != CR && *s != LF) while (s <= end-1 && *s != nsCRT::CR && *s != nsCRT::LF)
s++; s++;
if (s+1 >= end) 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. */ /* If "\r\n " or "\r\n\t" is next, that doesn't terminate the header. */
else if (s+2 < end && 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[2] == ' ' || s[2] == '\t'))
{ {
s += 3; 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 /* If "\r " or "\r\t" or "\n " or "\n\t" is next, that doesn't terminate
the header either. */ 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[1] == ' ' || s[1] == '\t'))
{ {
s += 2; s += 2;
@ -291,8 +291,8 @@ MimeHeaders_build_heads_list(MimeHeaders *hdrs)
/* At this point, `s' points before a header-terminating newline. /* At this point, `s' points before a header-terminating newline.
Move past that newline, and store that new position in `heads'. Move past that newline, and store that new position in `heads'.
*/ */
if (*s == CR) s++; if (*s == nsCRT::CR) s++;
if (*s == LF) s++; if (*s == nsCRT::LF) s++;
if (s < end) if (s < end)
{ {
@ -790,7 +790,7 @@ MIME_StripContinuations(char *original)
while(*p2) while(*p2)
{ {
/* p2 runs ahead at (CR and/or LF) */ /* 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++; p2++;
} else { } else {
@ -824,7 +824,7 @@ mime_decode_filename(char *name, const char *charset,
{ {
/* Remove backslashes when they are used to escape special characters. */ /* Remove backslashes when they are used to escape special characters. */
if ((*s == '\\') && 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 */ s++; /* take whatever char follows the backslash */
if (*s) if (*s)
*d++ = *s++; *d++ = *s++;

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

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

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

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

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

@ -316,8 +316,8 @@ MimeMultipartSigned_parse_line (char *line, PRInt32 length, MimeObject *obj)
*/ */
/* Remove the trailing newline... */ /* Remove the trailing newline... */
if (length > 0 && line[length-1] == LF) length--; if (length > 0 && line[length-1] == nsCRT::LF) length--;
if (length > 0 && line[length-1] == CR) length--; if (length > 0 && line[length-1] == nsCRT::CR) length--;
PR_ASSERT(sig->xlation_closure); PR_ASSERT(sig->xlation_closure);
@ -524,8 +524,8 @@ MimeMultipartSigned_parse_child_line (MimeObject *obj,
*/ */
/* Remove the trailing newline... */ /* Remove the trailing newline... */
if (length > 0 && line[length-1] == LF) length--; if (length > 0 && line[length-1] == nsCRT::LF) length--;
if (length > 0 && line[length-1] == CR) length--; if (length > 0 && line[length-1] == nsCRT::CR) length--;
PR_ASSERT(sig->part_buffer); PR_ASSERT(sig->part_buffer);
PR_ASSERT(first_line_p == 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 // If this line is blank, we're now done parsing headers, and should
// now examine the content-type to create this "body" part. // 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); status = ((MimeMultipartClass *) obj->clazz)->create_child(obj);
if (status < 0) return status; if (status < 0) return status;
@ -531,8 +531,8 @@ MimeMultipart_parse_child_line (MimeObject *obj, char *line, PRInt32 length,
*/ */
/* Remove the trailing newline... */ /* Remove the trailing newline... */
if (length > 0 && line[length-1] == LF) length--; if (length > 0 && line[length-1] == nsCRT::LF) length--;
if (length > 0 && line[length-1] == CR) length--; if (length > 0 && line[length-1] == nsCRT::CR) length--;
if (!first_line_p) 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[0] == '-' && line[1] == '-' && line[2] == '-' && line[3] == '-' &&
line[4] == '-' && line[5] == '-' && line[6] == '-' && line[7] == '-' && line[4] == '-' && line[5] == '-' && line[6] == '-' && line[7] == '-' &&
line[8] == '-' && line[9] == '-' && line[8] == '-' && line[9] == '-' &&
(line[10] == CR || line[10] == LF)) (line[10] == nsCRT::CR || line[10] == nsCRT::LF))
return MimeMultipartBoundaryTypeSeparator; return MimeMultipartBoundaryTypeSeparator;
else else
return MimeMultipartBoundaryTypeNone; 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 // just eat it and continue and if we really get more data, we'll open
// up the subpart then. // up the subpart then.
// //
if (line[0] == CR) return 0; if (line[0] == nsCRT::CR) return 0;
if (line[0] == LF) return 0; if (line[0] == nsCRT::LF) return 0;
PR_ASSERT(!begin_line_p); PR_ASSERT(!begin_line_p);
status = MimeUntypedText_open_subpart (obj, status = MimeUntypedText_open_subpart (obj,
@ -412,8 +412,8 @@ MimeUntypedText_uu_begin_line_p(const char *line, PRInt32 length,
name[(line+length)-s] = 0; name[(line+length)-s] = 0;
/* take off newline. */ /* take off newline. */
if (name[nsCRT::strlen(name)-1] == LF) 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] == CR) 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. /* Now try and figure out a type.
*/ */
@ -493,8 +493,8 @@ MimeUntypedText_binhex_begin_line_p(const char *line, PRInt32 length,
static PRBool static PRBool
MimeUntypedText_binhex_end_line_p(const char *line, PRInt32 length) MimeUntypedText_binhex_end_line_p(const char *line, PRInt32 length)
{ {
if (length > 0 && line[length-1] == LF) length--; if (length > 0 && line[length-1] == nsCRT::LF) length--;
if (length > 0 && line[length-1] == CR) length--; if (length > 0 && line[length-1] == nsCRT::CR) length--;
if (length != 0 && length != 64) if (length != 0 && length != 64)
return PR_TRUE; return PR_TRUE;

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

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

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

@ -1114,7 +1114,7 @@ nsMsgNewsFolder::HandleNewsrcLine(char* line, PRUint32 line_size)
nsresult rv; nsresult rv;
/* guard against blank line lossage */ /* 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; line[line_size] = 0;

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

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

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

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

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

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

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

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

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

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

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

@ -79,7 +79,7 @@ nsGopherDirListingConv::Convert(nsIInputStream *aFromStream,
convertedData.Append("300: "); convertedData.Append("300: ");
convertedData.Append(spec); convertedData.Append(spec);
convertedData.Append(LF); convertedData.Append(char(nsCRT::LF));
// END 300: // END 300:
//Column headings //Column headings
@ -197,7 +197,7 @@ nsGopherDirListingConv::OnDataAvailable(nsIRequest *request,
indexFormat.Append("300: "); indexFormat.Append("300: ");
indexFormat.Append(spec.get()); indexFormat.Append(spec.get());
indexFormat.Append(LF); indexFormat.Append(char(nsCRT::LF));
// END 300: // END 300:
// build up the column heading; 200: // build up the column heading; 200:
@ -278,9 +278,9 @@ nsGopherDirListingConv::DigestBufferLines(char* aBuffer, nsCAutoString& aString)
PRBool cr = PR_FALSE; PRBool cr = PR_FALSE;
// while we have new lines, parse 'em into application/http-index-format. // 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. // yank any carriage returns too.
if (eol > line && *(eol-1) == CR) { if (eol > line && *(eol-1) == nsCRT::CR) {
eol--; eol--;
*eol = '\0'; *eol = '\0';
cr = PR_TRUE; cr = PR_TRUE;
@ -393,7 +393,7 @@ nsGopherDirListingConv::DigestBufferLines(char* aBuffer, nsCAutoString& aString)
aString.Append("DIRECTORY"); aString.Append("DIRECTORY");
else else
aString.Append("FILE"); aString.Append("FILE");
aString.Append(LF); aString.Append(char(nsCRT::LF));
} }
} else { } else {
NS_WARNING("Error parsing gopher directory response.\n"); 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 // if we don't have a channel already, then we don't even
// have enough info to start a part, go ahead and buffer // have enough info to start a part, go ahead and buffer
// enough to collect a boundary token. // 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); bufAmt = PR_MIN(mTokenLen - 1, bufLen);
} }
@ -443,8 +443,8 @@ nsMultiMixedConv::SendData(char *aBuffer, PRUint32 aLen) {
PRInt8 PRInt8
nsMultiMixedConv::PushOverLine(char *&aPtr, PRUint32 &aLen) { nsMultiMixedConv::PushOverLine(char *&aPtr, PRUint32 &aLen) {
PRInt8 chars = 0; PRInt8 chars = 0;
if (*aPtr == CR || *aPtr == LF) { if (*aPtr == nsCRT::CR || *aPtr == nsCRT::LF) {
if (aPtr[1] == LF) if (aPtr[1] == nsCRT::LF)
chars++; chars++;
chars++; chars++;
} }
@ -464,9 +464,9 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr,
PRUint8 lineFeedIncrement = 1; PRUint8 lineFeedIncrement = 1;
while ( (cursorLen > 0) while ( (cursorLen > 0)
&& (newLine = PL_strchr(cursor, LF)) ) { && (newLine = PL_strchr(cursor, nsCRT::LF)) ) {
// adjust for linefeeds // adjust for linefeeds
if ( (newLine > cursor) && (newLine[-1] == CR) ) { // CRLF if ( (newLine > cursor) && (newLine[-1] == nsCRT::CR) ) { // CRLF
lineFeedIncrement = 2; lineFeedIncrement = 2;
newLine--; newLine--;
} }

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

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

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

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

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

@ -29,16 +29,6 @@
#include "prtypes.h" #include "prtypes.h"
#include "nsCppSharedAllocator.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 #ifdef XP_MAC
# define NS_LINEBREAK "\015" # define NS_LINEBREAK "\015"
# define NS_LINEBREAK_LEN 1 # define NS_LINEBREAK_LEN 1
@ -54,10 +44,8 @@
# endif /* XP_PC */ # endif /* XP_PC */
#endif /* XP_MAC */ #endif /* XP_MAC */
extern const PRUnichar kIsoLatin1ToUCS2[256]; extern const PRUnichar kIsoLatin1ToUCS2[256];
// This macro can be used in a class declaration for classes that want // This macro can be used in a class declaration for classes that want
// to ensure that their instance memory is zeroed. // to ensure that their instance memory is zeroed.
#define NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW \ #define NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW \
@ -97,6 +85,13 @@ extern const PRUnichar kIsoLatin1ToUCS2[256];
class NS_COM nsCRT { class NS_COM nsCRT {
public: 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. /** Copy bytes from aSrc to aDest.
@param aDest the destination address @param aDest the destination address
@ -274,6 +269,11 @@ public:
static PRBool IsAsciiSpace(PRUnichar aChar); 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___ */ #endif /* nsCRT_h___ */

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

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