mirror of
https://github.com/openssl/openssl.git
synced 2024-11-27 12:04:38 +08:00
be22315235
This adds the following scripts: util/lang-compress.pl: Compress source code, which language is determined by the first argument. For the moment, we know 'perl' (perlasm source code), 'C' (C source code) and 'S' (Assembler with C preprocessor directives). This removes comments and empty lines, and compresses series of horizontal spaces to one single space in the languages where that's appropriate. util/fips-checksums.sh: Takes source file names as arguments, pushes them through util/lang-compress.pl and unifdef with FIPS_MODE defined, and calculates the checksum on the result. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8871)
55 lines
1.0 KiB
Perl
Executable File
55 lines
1.0 KiB
Perl
Executable File
#! /usr/bin/env perl
|
|
#
|
|
# TEST c-compress-pl with a number of examples and what should happen to them
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use File::Basename;
|
|
|
|
my @pairs =
|
|
(
|
|
[ <<'_____'
|
|
/* A hell of a program */
|
|
#def\
|
|
ine foo/* bar */ 3
|
|
#define bar /* haha "A /* comment */ that should /* remain" */
|
|
#define haha /* hoho */ "A /* comment */ that should /* remain" */
|
|
|
|
int main() {
|
|
int x;
|
|
/* one lonely comment */
|
|
}
|
|
_____
|
|
, <<'_____'
|
|
#define foo 3
|
|
#define bar that should
|
|
#define haha "A /* comment */ that should /* remain" */
|
|
int main() {
|
|
int x;
|
|
}
|
|
_____
|
|
]
|
|
);
|
|
|
|
my $here = dirname $0;
|
|
my $c_compress = "$here/lang-compress.pl";
|
|
|
|
use FileHandle;
|
|
use IPC::Open2;
|
|
use Text::Diff;
|
|
foreach (@pairs) {
|
|
my $source = $_->[0];
|
|
my $expected = $_->[1];
|
|
my $pid = open2(\*Reader, \*Writer, "perl $c_compress 'C'");
|
|
print Writer $source;
|
|
close Writer;
|
|
|
|
local $/ = undef; # slurp
|
|
my $got = <Reader>;
|
|
|
|
if ($got ne $expected) {
|
|
print "MISMATCH:\n", diff \$expected, \$got;
|
|
}
|
|
}
|