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