@@ -704,13 +704,8 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
704704 location.line = 1U ;
705705 }
706706 // #3 "file.c"
707- // #line 3 "file.c"
708- else if ((llNextToken->number &&
709- llNextToken->next ->str ()[0 ] == ' \" ' ) ||
710- (llNextToken->str () == " line" &&
711- llNextToken->next ->number &&
712- llNextToken->next ->next &&
713- llNextToken->next ->next ->str ()[0 ] == ' \" ' ))
707+ else if (llNextToken->number &&
708+ llNextToken->next ->str ()[0 ] == ' \" ' )
714709 {
715710 const Token *strtok = cback ();
716711 while (strtok->comment )
@@ -722,13 +717,22 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
722717 std::atol (numtok->str ().c_str ()), &location);
723718 }
724719 // #line 3
720+ // #line 3 "file.c"
725721 else if (llNextToken->str () == " line" &&
726722 llNextToken->next ->number )
727723 {
728- const Token *numtok = cback ();
729- while (numtok->comment )
730- numtok = numtok->previous ;
731- lineDirective (location.fileIndex , std::atol (numtok->str ().c_str ()), &location);
724+ const Token *backtok = cback ();
725+ while (backtok->comment )
726+ backtok = backtok->previous ;
727+ // TODO: skip comments?
728+ if (llNextToken->next ->next && llNextToken->next ->next ->str ()[0 ] == ' \" ' )
729+ {
730+ lineDirective (fileIndex (replaceAll (backtok->str ().substr (1U , backtok->str ().size () - 2U )," \\\\ " ," \\ " )),
731+ std::atol (backtok->str ().c_str ()), &location);
732+ }
733+ else {
734+ lineDirective (location.fileIndex , std::atol (backtok->str ().c_str ()), &location);
735+ }
732736 }
733737 }
734738 // #endfile
0 commit comments