From e10a783bb38cc47753c9c0f04b85ca27b358ed73 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 23 Apr 2021 09:44:59 +0200 Subject: [PATCH] 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 --- scripts/generate_errors.pl | 4 ++-- scripts/generate_features.pl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/generate_errors.pl b/scripts/generate_errors.pl index ed17a0dbdf..606714f991 100755 --- a/scripts/generate_errors.pl +++ b/scripts/generate_errors.pl @@ -56,7 +56,7 @@ my @high_level_modules = qw( CIPHER DHM ECP MD my $line_separator = $/; 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 = ; close(FORMAT_FILE); @@ -66,7 +66,7 @@ my @files = <$include_dir/*.h>; my @necessary_include_files; my @matches; 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]+/, ); push(@matches, @grep_res); close FILE; diff --git a/scripts/generate_features.pl b/scripts/generate_features.pl index 74a95279be..6b1dcbf897 100755 --- a/scripts/generate_features.pl +++ b/scripts/generate_features.pl @@ -45,13 +45,13 @@ my @sections = ( "System support", "mbed TLS modules", my $line_separator = $/; 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 = ; close(FORMAT_FILE); $/ = $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 $in_section = 0;