@@ -700,19 +700,26 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
700700 if (!isLastLinePreprocessor ())
701701 continue ;
702702 const std::string lastline (lastLine ());
703+ // #file "file.c"
703704 if (lastline == " # file %str%" ) {
704705 const Token *strtok = cback ();
705706 while (strtok->comment )
706707 strtok = strtok->previous ;
707708 loc.push (location);
708709 location.fileIndex = fileIndex (strtok->str ().substr (1U , strtok->str ().size () - 2U ));
709710 location.line = 1U ;
710- } else if (lastline == " # line %num%" ) {
711+ }
712+ // #line 3
713+ // TODO: add support for "# 3"
714+ else if (lastline == " # line %num%" ) {
711715 const Token *numtok = cback ();
712716 while (numtok->comment )
713717 numtok = numtok->previous ;
714718 lineDirective (location.fileIndex , std::atol (numtok->str ().c_str ()), &location);
715- } else if (lastline == " # %num% %str%" || lastline == " # line %num% %str%" ) {
719+ }
720+ // # 3 "file.c" - not supported by Visual Studio
721+ // #line 3 "file.c"
722+ else if (lastline == " # %num% %str%" || lastline == " # line %num% %str%" ) {
716723 const Token *strtok = cback ();
717724 while (strtok->comment )
718725 strtok = strtok->previous ;
@@ -722,7 +729,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
722729 lineDirective (fileIndex (replaceAll (strtok->str ().substr (1U , strtok->str ().size () - 2U )," \\\\ " ," \\ " )),
723730 std::atol (numtok->str ().c_str ()), &location);
724731 }
725- // #endfile
732+ // #endfile - only supported by Visual Studio(?)
726733 else if (lastline == " # endfile" && !loc.empty ()) {
727734 location = loc.top ();
728735 loc.pop ();
0 commit comments