From 053730c5b7e9f4d0e97108e01d0fce472f300edd Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Sun, 4 Oct 2020 11:51:20 +0200 Subject: [PATCH] Make OpenSSL::ParseC and OpenSSL::Ordinals treat deprecation consistently The triggering macro that decides if a symbol is to be considered deprecated is OPENSSL_NO_DEPRECATEDIN_x_y[_z]. OpenSSL::ParseC renames any OPENSSL_NO_DEPRECATED_x_y[_z] by inserting "IN". Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/13074) --- util/perl/OpenSSL/Ordinals.pm | 1 - util/perl/OpenSSL/ParseC.pm | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/util/perl/OpenSSL/Ordinals.pm b/util/perl/OpenSSL/Ordinals.pm index 7008ebf5368..8f113fb8f68 100644 --- a/util/perl/OpenSSL/Ordinals.pm +++ b/util/perl/OpenSSL/Ordinals.pm @@ -407,7 +407,6 @@ sub _parse_features { if ($def =~ m{^ZLIB$}) { $features{$&} = $op; } if ($def =~ m{^OPENSSL_USE_}) { $features{$'} = $op; } if ($def =~ m{^OPENSSL_NO_}) { $features{$'} = !$op; } - if ($def =~ m{^DEPRECATEDIN_(.*)$}) { $features{$&} = !$op; } } return %features; diff --git a/util/perl/OpenSSL/ParseC.pm b/util/perl/OpenSSL/ParseC.pm index 7e6377dd175..d7e7c40f1fb 100644 --- a/util/perl/OpenSSL/ParseC.pm +++ b/util/perl/OpenSSL/ParseC.pm @@ -75,7 +75,7 @@ my @opensslcpphandlers = ( #if$1 OPENSSL_NO_DEPRECATEDIN_$2 EOF } - } + } ); my @cpphandlers = ( ################################################################## @@ -262,17 +262,26 @@ my @opensslchandlers = ( # Deprecated stuff, by OpenSSL release. # We trick the parser by pretending that the declaration is wrapped in a - # check if the DEPRECATEDIN macro is defined or not. Callers of parse() - # will have to decide what to do with it. + # check if the OPENSSL_NO_DEPRECATEDIN_x_y[_z] macro is defined or not. + # Callers of parse() will have to decide what to do with it. { regexp => qr/(DEPRECATEDIN_\d+_\d+(?:_\d+)?)<<<\((.*)\)>>>/, massager => sub { return (<<"EOF"); -#ifndef $1 +#ifndef OPENSSL_NO_$1 $2; #endif EOF }, }, + # OSSL_DEPRECATEDIN_x_y[_z] is simply ignored. Such declarations are + # supposed to be guarded with an '#ifdef OPENSSL_NO_DEPRECATED_x_y[_z]' + { regexp => qr/OSSL_DEPRECATEDIN_\d+_\d+(?:_\d+)?\s+(.*)/, + massager => sub { return $1; }, + }, + { regexp => qr/(.*?)\s+OSSL_DEPRECATEDIN_\d+_\d+(?:_\d+)?\s+(.*)/, + massager => sub { return "$1 $2"; }, + }, + ##### # LHASH stuff -- 2.47.2