@@ -703,47 +703,45 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
703703 const Token * const llNextToken = llTok->next ;
704704 if (!llTok->next )
705705 continue ;
706- // #file "file.c"
707- if (llNextToken->str () == " file" &&
708- llNextToken->next &&
709- llNextToken->next ->str ()[0 ] == ' \" ' )
710- {
711- const Token *strtok = cback ();
712- while (strtok->comment )
713- strtok = strtok->previous ;
714- loc.push (location);
715- location.fileIndex = fileIndex (strtok->str ().substr (1U , strtok->str ().size () - 2U ));
716- location.line = 1U ;
717- }
718- // #3 "file.c"
719- // #line 3 "file.c"
720- else if ((llNextToken->number &&
721- llNextToken->next &&
722- llNextToken->next ->str ()[0 ] == ' \" ' ) ||
723- (llNextToken->str () == " line" &&
724- llNextToken->next &&
725- llNextToken->next ->number &&
726- llNextToken->next ->next &&
727- llNextToken->next ->next ->str ()[0 ] == ' \" ' ))
728- {
729- const Token *strtok = cback ();
730- while (strtok->comment )
731- strtok = strtok->previous ;
732- const Token *numtok = strtok->previous ;
733- while (numtok->comment )
734- numtok = numtok->previous ;
735- lineDirective (fileIndex (replaceAll (strtok->str ().substr (1U , strtok->str ().size () - 2U )," \\\\ " ," \\ " )),
736- std::atol (numtok->str ().c_str ()), &location);
737- }
738- // #line 3
739- else if (llNextToken->str () == " line" &&
740- llNextToken->next &&
741- llNextToken->next ->number )
742- {
743- const Token *numtok = cback ();
744- while (numtok->comment )
745- numtok = numtok->previous ;
746- lineDirective (location.fileIndex , std::atol (numtok->str ().c_str ()), &location);
706+ if (llNextToken->next ) {
707+ // #file "file.c"
708+ if (llNextToken->str () == " file" &&
709+ llNextToken->next ->str ()[0 ] == ' \" ' )
710+ {
711+ const Token *strtok = cback ();
712+ while (strtok->comment )
713+ strtok = strtok->previous ;
714+ loc.push (location);
715+ location.fileIndex = fileIndex (strtok->str ().substr (1U , strtok->str ().size () - 2U ));
716+ location.line = 1U ;
717+ }
718+ // #3 "file.c"
719+ // #line 3 "file.c"
720+ else if ((llNextToken->number &&
721+ llNextToken->next ->str ()[0 ] == ' \" ' ) ||
722+ (llNextToken->str () == " line" &&
723+ llNextToken->next ->number &&
724+ llNextToken->next ->next &&
725+ llNextToken->next ->next ->str ()[0 ] == ' \" ' ))
726+ {
727+ const Token *strtok = cback ();
728+ while (strtok->comment )
729+ strtok = strtok->previous ;
730+ const Token *numtok = strtok->previous ;
731+ while (numtok->comment )
732+ numtok = numtok->previous ;
733+ lineDirective (fileIndex (replaceAll (strtok->str ().substr (1U , strtok->str ().size () - 2U )," \\\\ " ," \\ " )),
734+ std::atol (numtok->str ().c_str ()), &location);
735+ }
736+ // #line 3
737+ else if (llNextToken->str () == " line" &&
738+ llNextToken->next ->number )
739+ {
740+ const Token *numtok = cback ();
741+ while (numtok->comment )
742+ numtok = numtok->previous ;
743+ lineDirective (location.fileIndex , std::atol (numtok->str ().c_str ()), &location);
744+ }
747745 }
748746 // #endfile
749747 else if (llNextToken->str () == " endfile" && !loc.empty ())
0 commit comments