@@ -463,20 +463,23 @@ void clear_exclude_list(struct exclude_list *el)
463
463
el -> filebuf = NULL ;
464
464
}
465
465
466
- static void check_trailing_spaces ( const char * fname , char * buf )
466
+ static void trim_trailing_spaces ( char * buf )
467
467
{
468
- int i , last_space = -1 , len = strlen (buf );
468
+ int i , last_space = -1 , nr_spaces , len = strlen (buf );
469
469
for (i = 0 ; i < len ; i ++ )
470
470
if (buf [i ] == '\\' )
471
471
i ++ ;
472
- else if (buf [i ] == ' ' )
473
- last_space = i ;
474
- else
472
+ else if (buf [i ] == ' ' ) {
473
+ if (last_space == -1 ) {
474
+ last_space = i ;
475
+ nr_spaces = 1 ;
476
+ } else
477
+ nr_spaces ++ ;
478
+ } else
475
479
last_space = -1 ;
476
480
477
- if (last_space == len - 1 )
478
- warning (_ ("%s: trailing spaces in '%s'. Please quote or remove them." ),
479
- fname , buf );
481
+ if (last_space != -1 && last_space + nr_spaces == len )
482
+ buf [last_space ] = '\0' ;
480
483
}
481
484
482
485
int add_excludes_from_file_to_list (const char * fname ,
@@ -530,7 +533,7 @@ int add_excludes_from_file_to_list(const char *fname,
530
533
if (buf [i ] == '\n' ) {
531
534
if (entry != buf + i && entry [0 ] != '#' ) {
532
535
buf [i - (i && buf [i - 1 ] == '\r' )] = 0 ;
533
- check_trailing_spaces ( fname , entry );
536
+ trim_trailing_spaces ( entry );
534
537
add_exclude (entry , base , baselen , el , lineno );
535
538
}
536
539
lineno ++ ;
0 commit comments