Preprocessor: Fix comments (backspace -> backslash)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2011-11-13 20:27:56 +01:00
parent 00ead7fb2e
commit 68a1b69d32
1 changed files with 9 additions and 9 deletions

View File

@ -110,8 +110,8 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename,
{ {
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
// //
// handling <backspace><newline> // handling <backslash><newline>
// when this is encountered the <backspace><newline> will be "skipped". // when this is encountered the <backslash><newline> will be "skipped".
// on the next <newline>, extra newlines will be added // on the next <newline>, extra newlines will be added
std::ostringstream code; std::ostringstream code;
unsigned int newlines = 0; unsigned int newlines = 0;
@ -120,7 +120,7 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename,
if (((ch & 0x80) == 0) && (ch != '\n') && (std::isspace(ch) || std::iscntrl(ch))) if (((ch & 0x80) == 0) && (ch != '\n') && (std::isspace(ch) || std::iscntrl(ch)))
ch = ' '; ch = ' ';
// <backspace><newline>.. // <backslash><newline>..
// for gcc-compatibility the trailing spaces should be ignored // for gcc-compatibility the trailing spaces should be ignored
// for vs-compatibility the trailing spaces should be kept // for vs-compatibility the trailing spaces should be kept
// See tickets #640 and #1869 // See tickets #640 and #1869
@ -134,7 +134,7 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename,
chNext = (unsigned char)istr.peek(); chNext = (unsigned char)istr.peek();
if (chNext != '\n' && chNext != '\r' && if (chNext != '\n' && chNext != '\r' &&
(std::isspace(chNext) || std::iscntrl(chNext))) { (std::isspace(chNext) || std::iscntrl(chNext))) {
// Skip whitespace between <backspace> and <newline> // Skip whitespace between <backslash> and <newline>
(void)readChar(istr); (void)readChar(istr);
continue; continue;
} }
@ -147,13 +147,13 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename,
#endif #endif
if (chNext == '\n' || chNext == '\r') { if (chNext == '\n' || chNext == '\r') {
++newlines; ++newlines;
(void)readChar(istr); // Skip the "<backspace><newline>" (void)readChar(istr); // Skip the "<backslash><newline>"
} else } else
code << "\\"; code << "\\";
} else { } else {
code << char(ch); code << char(ch);
// if there has been <backspace><newline> sequences, add extra newlines.. // if there has been <backslash><newline> sequences, add extra newlines..
if (ch == '\n' && newlines > 0) { if (ch == '\n' && newlines > 0) {
code << std::string(newlines, '\n'); code << std::string(newlines, '\n');
newlines = 0; newlines = 0;
@ -308,8 +308,8 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
// For the error report // For the error report
unsigned int lineno = 1; unsigned int lineno = 1;
// handling <backspace><newline> // handling <backslash><newline>
// when this is encountered the <backspace><newline> will be "skipped". // when this is encountered the <backslash><newline> will be "skipped".
// on the next <newline>, extra newlines will be added // on the next <newline>, extra newlines will be added
unsigned int newlines = 0; unsigned int newlines = 0;
std::ostringstream code; std::ostringstream code;
@ -350,7 +350,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri
previous = ch; previous = ch;
} }
// if there has been <backspace><newline> sequences, add extra newlines.. // if there has been <backslash><newline> sequences, add extra newlines..
if (ch == '\n') { if (ch == '\n') {
if (previous != '\\') if (previous != '\\')
inPreprocessorLine = false; inPreprocessorLine = false;