Have mkerr.pl treat already existing multiline string defs properly
authorRichard Levitte <levitte@openssl.org>
Wed, 8 Apr 2015 17:26:11 +0000 (19:26 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 8 Apr 2015 19:44:43 +0000 (21:44 +0200)
Since source reformat, we ended up with some error reason string
definitions that spanned two lines.  That in itself is fine, but we
sometimes edited them to provide better strings than what could be
automatically determined from the reason macro, for example:

    {ERR_REASON(SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER),
     "Peer haven't sent GOST certificate, required for selected ciphersuite"},

However, mkerr.pl didn't treat those two-line definitions right, and
they ended up being retranslated to whatever the macro name would
indicate, for example:

    {ERR_REASON(SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER),
     "No gost certificate sent by peer"},

Clearly not what we wanted.  This change fixes this problem.

Reviewed-by: Matt Caswell <matt@openssl.org>
util/mkerr.pl

index 96c705e16bf3a8ec41ca1bc810c4d273bf4bf0c2..8a51588c881495f3317e1c3ec79da86db12291da 100644 (file)
@@ -535,14 +535,21 @@ EOF
        # First, read any existing reason string definitions:
        my %err_reason_strings;
        if (open(IN,"<$cfile")) {
        # First, read any existing reason string definitions:
        my %err_reason_strings;
        if (open(IN,"<$cfile")) {
+               my $line = "";
                while (<IN>) {
                while (<IN>) {
-                       if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) {
-                               $err_reason_strings{$1} = $2;
-                       }
-                       if (/\b${lib}_F_(\w*)\b.*\"(.*)\"/) {
-                               if (!exists $ftrans{$1} && ($1 ne $2)) {
-                                       print STDERR "WARNING: Mismatched function string $2\n";
-                                       $ftrans{$1} = $2;
+                       chomp;
+                       $_ = $line . $_;
+                       $line = "";
+                       if (/{ERR_(FUNC|REASON)\(/) {
+                               if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) {
+                                       $err_reason_strings{$1} = $2;
+                               } elsif (/\b${lib}_F_(\w*)\b.*\"(.*)\"/) {
+                                       if (!exists $ftrans{$1} && ($1 ne $2)) {
+                                               print STDERR "WARNING: Mismatched function string $2\n";
+                                               $ftrans{$1} = $2;
+                                       }
+                               } else {
+                                       $line = $_;
                                }
                        }
                }
                                }
                        }
                }