Make OpenSSL::ParseC and OpenSSL::Ordinals treat deprecation consistently
authorRichard Levitte <levitte@openssl.org>
Sun, 4 Oct 2020 09:51:20 +0000 (11:51 +0200)
committerRichard Levitte <levitte@openssl.org>
Mon, 12 Oct 2020 06:29:30 +0000 (08:29 +0200)
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 <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13074)

util/perl/OpenSSL/Ordinals.pm
util/perl/OpenSSL/ParseC.pm

index 7008ebf5368f02221ef0586cadfb8f5ae4633d19..8f113fb8f687800eaee91acd81d25246c6977423 100644 (file)
@@ -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;
index 7e6377dd17543bf93b7f05e90193a7ab72ee2586..d7e7c40f1fb9af8e14b0f27389d35a24058fe4c4 100644 (file)
@@ -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