Preprocessor: Refactoring previous fix

This commit is contained in:
Daniel Marjamäki 2012-12-02 20:17:25 +01:00
parent cb06d07ae7
commit b08ba5b575
1 changed files with 5 additions and 4 deletions

View File

@ -153,11 +153,11 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename)
if (ch == '\\') { if (ch == '\\') {
unsigned char chNext; unsigned char chNext;
unsigned int spaces = 0; std::string spaces;
#ifdef __GNUC__ #ifdef __GNUC__
// gcc-compatibility: ignore spaces // gcc-compatibility: ignore spaces
for (;; spaces++) { for (;; spaces += ' ') {
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))) {
@ -175,8 +175,9 @@ std::string Preprocessor::read(std::istream &istr, const std::string &filename)
if (chNext == '\n' || chNext == '\r') { if (chNext == '\n' || chNext == '\r') {
++newlines; ++newlines;
(void)readChar(istr,bom); // Skip the "<backslash><newline>" (void)readChar(istr,bom); // Skip the "<backslash><newline>"
} else } else {
code << "\\" << (spaces?" ":""); code << "\\" << spaces;
}
} else { } else {
code << char(ch); code << char(ch);