Skip to content

Commit eebfbad

Browse files
committed
Keep line directives in tokenized output
1 parent 162eb96 commit eebfbad

2 files changed

Lines changed: 3 additions & 25 deletions

File tree

simplecpp.cpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -640,23 +640,6 @@ static bool isStringLiteralPrefix(const std::string &str)
640640
str == "R" || str == "uR" || str == "UR" || str == "LR" || str == "u8R";
641641
}
642642

643-
void simplecpp::TokenList::lineDirective(unsigned int fileIndex_, unsigned int line, Location &location)
644-
{
645-
if (fileIndex_ != location.fileIndex || line >= location.line) {
646-
location.fileIndex = fileIndex_;
647-
location.line = line;
648-
return;
649-
}
650-
651-
if (line + 2 >= location.line) {
652-
location.line = line;
653-
while (cback()->op != '#')
654-
deleteToken(back());
655-
deleteToken(back());
656-
return;
657-
}
658-
}
659-
660643
static const std::string COMMENT_END("*/");
661644

662645
void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename, OutputList *outputList)
@@ -726,17 +709,13 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
726709
if (!ppTok || !ppTok->number)
727710
continue;
728711

729-
const unsigned int line = std::atol(ppTok->str().c_str());
730-
ppTok = advanceAndSkipComments(ppTok);
712+
location.line = std::atol(ppTok->str().c_str());
731713

732-
unsigned int fileindex;
714+
ppTok = advanceAndSkipComments(ppTok);
733715

734716
if (ppTok && ppTok->str()[0] == '\"')
735-
fileindex = fileIndex(replaceAll(ppTok->str().substr(1U, ppTok->str().size() - 2U),"\\\\","\\"));
736-
else
737-
fileindex = location.fileIndex;
717+
location.fileIndex = fileIndex(replaceAll(ppTok->str().substr(1U, ppTok->str().size() - 2U),"\\\\","\\"));
738718

739-
lineDirective(fileindex, line, location);
740719
}
741720

742721
continue;

simplecpp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,6 @@ namespace simplecpp {
396396
void constFoldQuestionOp(Token *&tok1);
397397

398398
std::string readUntil(Stream &stream, const Location &location, char start, char end, OutputList *outputList);
399-
void lineDirective(unsigned int fileIndex_, unsigned int line, Location &location);
400399

401400
const Token* lastLineTok(int maxsize=1000) const;
402401
const Token* isLastLinePreprocessor(int maxsize=1000) const;

0 commit comments

Comments
 (0)