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