@@ -375,10 +375,9 @@ void ScriptParser::readAsNeeded() {
375375 expect (" (" );
376376 bool orig = config->asNeeded ;
377377 config->asNeeded = true ;
378- while (peek () != " )" && ! atEOF ( ))
379- addFile (unquote (next () ));
378+ while (auto tok = till ( " )" ))
379+ addFile (unquote (tok ));
380380 config->asNeeded = orig;
381- expect (" )" );
382381}
383382
384383void ScriptParser::readEntry () {
@@ -392,9 +391,8 @@ void ScriptParser::readEntry() {
392391
393392void ScriptParser::readExtern () {
394393 expect (" (" );
395- while (peek () != " )" && !atEOF ())
396- config->undefined .push_back (unquote (next ()));
397- expect (" )" );
394+ while (auto tok = till (" )" ))
395+ config->undefined .push_back (unquote (tok));
398396}
399397
400398void ScriptParser::readGroup () {
@@ -427,13 +425,12 @@ void ScriptParser::readInclude() {
427425
428426void ScriptParser::readInput () {
429427 expect (" (" );
430- while (peek () != " )" && ! atEOF ( )) {
431- if (consume ( " AS_NEEDED" ) )
428+ while (auto tok = till ( " )" )) {
429+ if (tok == " AS_NEEDED" )
432430 readAsNeeded ();
433431 else
434- addFile (unquote (next () ));
432+ addFile (unquote (tok ));
435433 }
436- expect (" )" );
437434}
438435
439436void ScriptParser::readOutput () {
@@ -712,10 +709,8 @@ static int precedence(StringRef op) {
712709
713710StringMatcher ScriptParser::readFilePatterns () {
714711 StringMatcher Matcher;
715-
716- while (peek () != " )" && !atEOF ())
717- Matcher.addPattern (SingleStringMatcher (next ()));
718- expect (" )" );
712+ while (auto tok = till (" )" ))
713+ Matcher.addPattern (SingleStringMatcher (tok));
719714 return Matcher;
720715}
721716
0 commit comments