@@ -688,19 +688,26 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
688688 if (!isLastLinePreprocessor ())
689689 continue ;
690690 const std::string lastline (lastLine ());
691+ // #file "file.c"
691692 if (lastline == " # file %str%" ) {
692693 const Token *strtok = cback ();
693694 while (strtok->comment )
694695 strtok = strtok->previous ;
695696 loc.push (location);
696697 location.fileIndex = fileIndex (strtok->str ().substr (1U , strtok->str ().size () - 2U ));
697698 location.line = 1U ;
698- } else if (lastline == " # line %num%" ) {
699+ }
700+ // #line 3
701+ // TODO: add support for "# 3"
702+ else if (lastline == " # line %num%" ) {
699703 const Token *numtok = cback ();
700704 while (numtok->comment )
701705 numtok = numtok->previous ;
702706 lineDirective (location.fileIndex , std::atol (numtok->str ().c_str ()), &location);
703- } else if (lastline == " # %num% %str%" || lastline == " # line %num% %str%" ) {
707+ }
708+ // # 3 "file.c" - not supported by Visual Studio
709+ // #line 3 "file.c"
710+ else if (lastline == " # %num% %str%" || lastline == " # line %num% %str%" ) {
704711 const Token *strtok = cback ();
705712 while (strtok->comment )
706713 strtok = strtok->previous ;
@@ -710,7 +717,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
710717 lineDirective (fileIndex (replaceAll (strtok->str ().substr (1U , strtok->str ().size () - 2U )," \\\\ " ," \\ " )),
711718 std::atol (numtok->str ().c_str ()), &location);
712719 }
713- // #endfile
720+ // #endfile - only supported by Visual Studio(?)
714721 else if (lastline == " # endfile" && !loc.empty ()) {
715722 location = loc.top ();
716723 loc.pop ();
0 commit comments