@@ -375,10 +375,9 @@ void ScriptParser::readAsNeeded() {
375
375
expect (" (" );
376
376
bool orig = config->asNeeded ;
377
377
config->asNeeded = true ;
378
- while (peek () != " )" && ! atEOF ( ))
379
- addFile (unquote (next () ));
378
+ while (auto tok = till ( " )" ))
379
+ addFile (unquote (tok ));
380
380
config->asNeeded = orig;
381
- expect (" )" );
382
381
}
383
382
384
383
void ScriptParser::readEntry () {
@@ -392,9 +391,8 @@ void ScriptParser::readEntry() {
392
391
393
392
void ScriptParser::readExtern () {
394
393
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));
398
396
}
399
397
400
398
void ScriptParser::readGroup () {
@@ -427,13 +425,12 @@ void ScriptParser::readInclude() {
427
425
428
426
void ScriptParser::readInput () {
429
427
expect (" (" );
430
- while (peek () != " )" && ! atEOF ( )) {
431
- if (consume ( " AS_NEEDED" ) )
428
+ while (auto tok = till ( " )" )) {
429
+ if (tok == " AS_NEEDED" )
432
430
readAsNeeded ();
433
431
else
434
- addFile (unquote (next () ));
432
+ addFile (unquote (tok ));
435
433
}
436
- expect (" )" );
437
434
}
438
435
439
436
void ScriptParser::readOutput () {
@@ -712,10 +709,8 @@ static int precedence(StringRef op) {
712
709
713
710
StringMatcher ScriptParser::readFilePatterns () {
714
711
StringMatcher Matcher;
715
-
716
- while (peek () != " )" && !atEOF ())
717
- Matcher.addPattern (SingleStringMatcher (next ()));
718
- expect (" )" );
712
+ while (auto tok = till (" )" ))
713
+ Matcher.addPattern (SingleStringMatcher (tok));
719
714
return Matcher;
720
715
}
721
716
0 commit comments