Skip to content

Commit cb7a0b0

Browse files
committed
fixed #578 - removed support for #file and #endfile
1 parent 3c2a660 commit cb7a0b0

2 files changed

Lines changed: 6 additions & 27 deletions

File tree

simplecpp.cpp

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,6 @@ static const std::string COMMENT_END("*/");
658658

659659
void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename, OutputList *outputList)
660660
{
661-
std::stack<simplecpp::Location> loc;
662-
663661
unsigned int multiline = 0U;
664662

665663
const Token *oldLastToken = nullptr;
@@ -705,26 +703,15 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
705703
if (!llTok->next)
706704
continue;
707705
if (llNextToken->next) {
708-
// #file "file.c"
709-
if (llNextToken->str() == "file" &&
710-
llNextToken->next->str()[0] == '\"')
711-
{
712-
const Token *strtok = cback();
713-
while (strtok->comment)
714-
strtok = strtok->previous;
715-
loc.push(location);
716-
location.fileIndex = fileIndex(strtok->str().substr(1U, strtok->str().size() - 2U));
717-
location.line = 1U;
718-
}
719706
// TODO: add support for "# 3"
720707
// #3 "file.c"
721708
// #line 3 "file.c"
722-
else if ((llNextToken->number &&
723-
llNextToken->next->str()[0] == '\"') ||
724-
(llNextToken->str() == "line" &&
725-
llNextToken->next->number &&
726-
llNextToken->next->next &&
727-
llNextToken->next->next->str()[0] == '\"'))
709+
if ((llNextToken->number &&
710+
llNextToken->next->str()[0] == '\"') ||
711+
(llNextToken->str() == "line" &&
712+
llNextToken->next->number &&
713+
llNextToken->next->next &&
714+
llNextToken->next->next->str()[0] == '\"'))
728715
{
729716
const Token *strtok = cback();
730717
while (strtok->comment)
@@ -745,12 +732,6 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
745732
lineDirective(location.fileIndex, std::atol(numtok->str().c_str()), location);
746733
}
747734
}
748-
// #endfile
749-
else if (llNextToken->str() == "endfile" && !loc.empty())
750-
{
751-
location = loc.top();
752-
loc.pop();
753-
}
754735
}
755736

756737
continue;

test.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,8 +2454,6 @@ static void location11()
24542454
preprocess(code));
24552455
}
24562456

2457-
// TODO: test #file/#endfile
2458-
24592457
static void missingHeader1()
24602458
{
24612459
const char code[] = "#include \"notexist.h\"\n";

0 commit comments

Comments
 (0)