Accept Windows line endings on inputs on any platform

Accept Windows line endings in input files on any platform. This makes
the scripts work even when running a Unix perl with a source tree that
has Windows line endings, as happens for example on our Travis Windows
instances. This change is harmless in the common case where the input
has the platform's default line endings.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2021-04-23 09:44:59 +02:00
parent 6e245c6e95
commit a4d3273fc7
2 changed files with 4 additions and 4 deletions

View File

@ -56,7 +56,7 @@ my @high_level_modules = qw( CIPHER DHM ECP MD
my $line_separator = $/; my $line_separator = $/;
undef $/; undef $/;
open(FORMAT_FILE, "$error_format_file") or die "Opening error format file '$error_format_file': $!"; open(FORMAT_FILE, '<:crlf', "$error_format_file") or die "Opening error format file '$error_format_file': $!";
my $error_format = <FORMAT_FILE>; my $error_format = <FORMAT_FILE>;
close(FORMAT_FILE); close(FORMAT_FILE);
@ -66,7 +66,7 @@ my @files = <$include_dir/*.h>;
my @necessary_include_files; my @necessary_include_files;
my @matches; my @matches;
foreach my $file (@files) { foreach my $file (@files) {
open(FILE, "$file"); open(FILE, '<:crlf', "$file");
my @grep_res = grep(/^\s*#define\s+MBEDTLS_ERR_\w+\s+\-0x[0-9A-Fa-f]+/, <FILE>); my @grep_res = grep(/^\s*#define\s+MBEDTLS_ERR_\w+\s+\-0x[0-9A-Fa-f]+/, <FILE>);
push(@matches, @grep_res); push(@matches, @grep_res);
close FILE; close FILE;

View File

@ -45,13 +45,13 @@ my @sections = ( "System support", "mbed TLS modules",
my $line_separator = $/; my $line_separator = $/;
undef $/; undef $/;
open(FORMAT_FILE, "$feature_format_file") or die "Opening feature format file '$feature_format_file': $!"; open(FORMAT_FILE, '<:crlf', "$feature_format_file") or die "Opening feature format file '$feature_format_file': $!";
my $feature_format = <FORMAT_FILE>; my $feature_format = <FORMAT_FILE>;
close(FORMAT_FILE); close(FORMAT_FILE);
$/ = $line_separator; $/ = $line_separator;
open(CONFIG_H, "$include_dir/config.h") || die("Failure when opening config.h: $!"); open(CONFIG_H, '<:crlf', "$include_dir/config.h") || die("Failure when opening config.h: $!");
my $feature_defines = ""; my $feature_defines = "";
my $in_section = 0; my $in_section = 0;